PWR preparation

This commit is contained in:
Bob 2023-08-15 20:42:48 +02:00
parent 35d9e49f23
commit 3c6e7920b5
26 changed files with 287 additions and 16 deletions

View File

@ -875,6 +875,17 @@ public class ModBlocks {
public static Block cm_circuit;
public static Block cm_port;
public static Block custom_machine;
public static Block pwr_fuel;
public static Block pwr_control;
public static Block pwr_channel;
public static Block pwr_heatex;
public static Block pwr_neutron_source;
public static Block pwr_reflector;
public static Block pwr_casing;
public static Block pwr_controller;
public static Block pwr_block;
public static Block pwr_port;
public static Block reactor_element;
public static Block reactor_control;
@ -2036,6 +2047,17 @@ public class ModBlocks {
cm_port = new BlockCMPort(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_port").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_port");
custom_machine = new BlockCustomMachine().setBlockName("custom_machine").setCreativeTab(MainRegistry.machineTab).setLightLevel(1F).setHardness(5.0F).setResistance(10.0F);
pwr_fuel = new BlockPillar(Material.iron, RefStrings.MODID + ":pwr_fuel_top").setBlockName("pwr_fuel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_fuel_side");
pwr_control = new BlockPillar(Material.iron, RefStrings.MODID + ":pwr_control_top").setBlockName("pwr_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_control_side");
pwr_channel = new BlockPillar(Material.iron, RefStrings.MODID + ":pwr_channel_top").setBlockName("pwr_channel").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_channel_side");
pwr_heatex = new BlockGeneric(Material.iron).setBlockName("pwr_heatex").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_heatex");
pwr_neutron_source = new BlockGeneric(Material.iron).setBlockName("pwr_neutron_source").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_neutron_source");
pwr_reflector = new BlockGeneric(Material.iron).setBlockName("pwr_reflector").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_reflector");
pwr_casing = new BlockGeneric(Material.iron).setBlockName("pwr_casing").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_casing");
pwr_port = new BlockGeneric(Material.iron).setBlockName("pwr_port").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_port");
pwr_controller = new MachinePWRController(Material.iron).setBlockName("pwr_controller").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_casing_blank");
pwr_block = new BlockPWR(Material.iron).setBlockName("pwr_block").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pwr_block");
reactor_element = new BlockPillar(Material.iron, RefStrings.MODID + ":reactor_element_top", RefStrings.MODID + ":reactor_element_base").setBlockName("reactor_element").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":reactor_element_side");
reactor_control = new BlockPillar(Material.iron, RefStrings.MODID + ":reactor_control_top").setBlockName("reactor_control").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":reactor_control_side");
reactor_hatch = new ReactorHatch(Material.iron).setBlockName("reactor_hatch").setHardness(5.0F).setResistance(1000.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":brick_concrete");
@ -3366,6 +3388,18 @@ public class ModBlocks {
register(cm_circuit);
register(cm_port);
//PWR
GameRegistry.registerBlock(pwr_fuel, pwr_fuel.getUnlocalizedName());
GameRegistry.registerBlock(pwr_control, pwr_control.getUnlocalizedName());
GameRegistry.registerBlock(pwr_channel, pwr_channel.getUnlocalizedName());
GameRegistry.registerBlock(pwr_heatex, pwr_heatex.getUnlocalizedName());
GameRegistry.registerBlock(pwr_neutron_source, pwr_neutron_source.getUnlocalizedName());
GameRegistry.registerBlock(pwr_reflector, pwr_reflector.getUnlocalizedName());
GameRegistry.registerBlock(pwr_casing, pwr_casing.getUnlocalizedName());
GameRegistry.registerBlock(pwr_port, pwr_port.getUnlocalizedName());
GameRegistry.registerBlock(pwr_controller, pwr_controller.getUnlocalizedName());
GameRegistry.registerBlock(pwr_block, pwr_block.getUnlocalizedName());
//Multiblock Generators
GameRegistry.registerBlock(reactor_element, reactor_element.getUnlocalizedName());
GameRegistry.registerBlock(reactor_control, reactor_control.getUnlocalizedName());

View File

@ -47,7 +47,7 @@ public class BlockHadronCoil extends Block implements IBlockCT, ITooltipProvider
}
@Override
public boolean canConnect(IBlockAccess world, int x, int y, int z, IBlockCT block) {
public boolean canConnect(IBlockAccess world, int x, int y, int z, Block block) {
return block instanceof BlockHadronCoil;
}

View File

@ -0,0 +1,52 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.render.block.ct.CT;
import com.hbm.render.block.ct.CTStitchReceiver;
import com.hbm.render.block.ct.IBlockCT;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class BlockPWR extends Block implements IBlockCT {
@SideOnly(Side.CLIENT) protected IIcon iconPort;
public BlockPWR(Material mat) {
super(mat);
}
@Override
public int getRenderType() {
return CT.renderID;
}
@SideOnly(Side.CLIENT) public CTStitchReceiver rec;
@SideOnly(Side.CLIENT) public CTStitchReceiver recPort;
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
this.iconPort = reg.registerIcon(RefStrings.MODID + ":pwr_casing_port");
this.rec = IBlockCT.primeReceiver(reg, this.blockIcon.getIconName(), this.blockIcon);
this.recPort = IBlockCT.primeReceiver(reg, this.iconPort.getIconName(), this.iconPort);
}
@Override
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if(meta == 1) return recPort.fragCache;
return rec.fragCache;
}
@Override
public boolean canConnect(IBlockAccess world, int x, int y, int z, Block block) {
return block == ModBlocks.pwr_block || block == ModBlocks.pwr_controller;
}
}

View File

@ -0,0 +1,157 @@
package com.hbm.blocks.machine;
import java.util.HashMap;
import java.util.Map.Entry;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.util.fauxpointtwelve.BlockPos;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class MachinePWRController extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
public MachinePWRController(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return null;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":pwr_controller");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2);
if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
assemble(world, x, y, z);
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
} else {
return false;
}
}
private static HashMap<BlockPos, Block> assembly = new HashMap();
private static HashMap<BlockPos, Block> fuelRods = new HashMap();
private static boolean errored;
private static final int maxSize = 1024;
public void assemble(World world, int x, int y, int z) {
assembly.clear();
assembly.put(new BlockPos(x, y, z), this);
ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)).getOpposite();
x += dir.offsetX;
z += dir.offsetZ;
errored = false;
floodFill(world, x, y, z);
if(fuelRods.size() == 0) errored = true;
if(!errored) {
for(Entry<BlockPos, Block> entry : assembly.entrySet()) {
Block block = entry.getValue();
if(block != ModBlocks.pwr_controller) {
if(block == ModBlocks.pwr_port) {
world.setBlock(entry.getKey().getX(), entry.getKey().getY(), entry.getKey().getZ(), ModBlocks.pwr_block, 1, 3);
} else {
world.setBlock(entry.getKey().getX(), entry.getKey().getY(), entry.getKey().getZ(), ModBlocks.pwr_block, 0, 3);
}
}
}
}
assembly.clear();
}
private void floodFill(World world, int x, int y, int z) {
BlockPos pos = new BlockPos(x, y, z);
if(assembly.containsKey(pos)) return;
if(assembly.size() >= maxSize) {
errored = true;
return;
}
Block block = world.getBlock(x, y, z);
if(isValidCasing(block)) {
assembly.put(pos, block);
return;
}
if(isValidCore(block)) {
assembly.put(pos, block);
if(block == ModBlocks.pwr_fuel) fuelRods.put(pos, block);
floodFill(world, x + 1, y, z);
floodFill(world, x - 1, y, z);
floodFill(world, x, y + 1, z);
floodFill(world, x, y - 1, z);
floodFill(world, x, y, z + 1);
floodFill(world, x, y, z - 1);
return;
}
errored = true;
}
private boolean isValidCore(Block block) {
if(block == ModBlocks.pwr_fuel || block == ModBlocks.pwr_control || block == ModBlocks.pwr_channel || block == ModBlocks.pwr_heatex || block == ModBlocks.pwr_neutron_source) return true;
return false;
}
private boolean isValidCasing(Block block) {
if(block == ModBlocks.pwr_casing || block == ModBlocks.pwr_reflector || block == ModBlocks.pwr_port) return true;
return false;
}
}

View File

@ -80,7 +80,7 @@ public class CTContext {
int[] coord = dirs[j];
Block neighbor = world.getBlock(x + coord[0], y + coord[1], z + coord[2]);
if(neighbor instanceof IBlockCT && ((IBlockCT) neighbor).canConnect(world, x + coord[0], y + coord[1], z + coord[2], (IBlockCT)block)) {
if(((IBlockCT) block).canConnect(world, x + coord[0], y + coord[1], z + coord[2], neighbor)) {
cons[j] = true;
}
}

View File

@ -1,5 +1,6 @@
package com.hbm.render.block.ct;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
@ -8,7 +9,7 @@ public interface IBlockCT {
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z);
public default boolean canConnect(IBlockAccess world, int x, int y, int z, IBlockCT block) {
public default boolean canConnect(IBlockAccess world, int x, int y, int z, Block block) {
return this == block;
}

View File

@ -37,7 +37,7 @@ public class RenderBlocksCT extends RenderBlocks {
this.blockAccess = acc;
}
private void initSideInfo() {
private void initSideInfo(int side) {
if(!this.enableAO)
return;
@ -49,15 +49,42 @@ public class RenderBlocksCT extends RenderBlocks {
* it's only the color in ONE PARTICULAR SIDE. well thanks for that i think that's rather poggers, lex.
*/
float red = (colorRedTopLeft + colorRedTopRight + colorRedBottomLeft + colorRedBottomRight) / 4F;
/*float red = (colorRedTopLeft + colorRedTopRight + colorRedBottomLeft + colorRedBottomRight) / 4F;
float green = (colorGreenTopLeft + colorGreenTopRight + colorGreenBottomLeft + colorGreenBottomRight) / 4F;
float blue = (colorBlueTopLeft + colorBlueTopRight + colorBlueBottomLeft + colorBlueBottomRight) / 4F;
int light = (brightnessTopLeft + brightnessTopRight + brightnessBottomLeft + brightnessBottomRight) / 4;
int light = (brightnessTopLeft + brightnessTopRight + brightnessBottomLeft + brightnessBottomRight) / 4;*/
this.tl = new VertInfo(red, green, blue, light);
this.tr = new VertInfo(red, green, blue, light);
this.bl = new VertInfo(red, green, blue, light);
this.br = new VertInfo(red, green, blue, light);
if(side == ForgeDirection.SOUTH.ordinal()) {
this.tl = new VertInfo(colorRedTopLeft, colorGreenTopLeft, colorBlueTopLeft, brightnessTopLeft);
this.tr = new VertInfo(colorRedTopRight, colorGreenTopRight, colorBlueTopRight, brightnessTopRight);
this.bl = new VertInfo(colorRedBottomLeft, colorGreenBottomLeft, colorBlueBottomLeft, brightnessBottomLeft);
this.br = new VertInfo(colorRedBottomRight, colorGreenBottomRight, colorBlueBottomRight, brightnessBottomRight);
} else if(side == ForgeDirection.NORTH.ordinal()) {
this.tr = new VertInfo(colorRedTopLeft, colorGreenTopLeft, colorBlueTopLeft, brightnessTopLeft);
this.br = new VertInfo(colorRedTopRight, colorGreenTopRight, colorBlueTopRight, brightnessTopRight);
this.tl = new VertInfo(colorRedBottomLeft, colorGreenBottomLeft, colorBlueBottomLeft, brightnessBottomLeft);
this.bl = new VertInfo(colorRedBottomRight, colorGreenBottomRight, colorBlueBottomRight, brightnessBottomRight);
} else if(side == ForgeDirection.EAST.ordinal()) {
this.bl = new VertInfo(colorRedTopLeft, colorGreenTopLeft, colorBlueTopLeft, brightnessTopLeft);
this.tl = new VertInfo(colorRedTopRight, colorGreenTopRight, colorBlueTopRight, brightnessTopRight);
this.br = new VertInfo(colorRedBottomLeft, colorGreenBottomLeft, colorBlueBottomLeft, brightnessBottomLeft);
this.tr = new VertInfo(colorRedBottomRight, colorGreenBottomRight, colorBlueBottomRight, brightnessBottomRight);
} else if(side == ForgeDirection.WEST.ordinal()) {
this.tr = new VertInfo(colorRedTopLeft, colorGreenTopLeft, colorBlueTopLeft, brightnessTopLeft);
this.br = new VertInfo(colorRedTopRight, colorGreenTopRight, colorBlueTopRight, brightnessTopRight);
this.tl = new VertInfo(colorRedBottomLeft, colorGreenBottomLeft, colorBlueBottomLeft, brightnessBottomLeft);
this.bl = new VertInfo(colorRedBottomRight, colorGreenBottomRight, colorBlueBottomRight, brightnessBottomRight);
} else if(side == ForgeDirection.UP.ordinal()) {
this.br = new VertInfo(colorRedTopLeft, colorGreenTopLeft, colorBlueTopLeft, brightnessTopLeft);
this.bl = new VertInfo(colorRedTopRight, colorGreenTopRight, colorBlueTopRight, brightnessTopRight);
this.tr = new VertInfo(colorRedBottomLeft, colorGreenBottomLeft, colorBlueBottomLeft, brightnessBottomLeft);
this.tl = new VertInfo(colorRedBottomRight, colorGreenBottomRight, colorBlueBottomRight, brightnessBottomRight);
} else {
this.tl = new VertInfo(colorRedTopLeft, colorGreenTopLeft, colorBlueTopLeft, brightnessTopLeft);
this.tr = new VertInfo(colorRedTopRight, colorGreenTopRight, colorBlueTopRight, brightnessTopRight);
this.bl = new VertInfo(colorRedBottomLeft, colorGreenBottomLeft, colorBlueBottomLeft, brightnessBottomLeft);
this.br = new VertInfo(colorRedBottomRight, colorGreenBottomRight, colorBlueBottomRight, brightnessBottomRight);
}
this.tc = VertInfo.avg(tl, tr);
this.bc = VertInfo.avg(bl, br);
@ -82,7 +109,7 @@ public class RenderBlocksCT extends RenderBlocks {
@Override
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
initSideInfo();
initSideInfo(ForgeDirection.EAST.ordinal());
CTFace face = CTContext.faces[ForgeDirection.EAST.ordinal()];
/// ORDER: LEXICAL ///
@ -99,7 +126,7 @@ public class RenderBlocksCT extends RenderBlocks {
@Override
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
initSideInfo();
initSideInfo(ForgeDirection.WEST.ordinal());
CTFace face = CTContext.faces[ForgeDirection.WEST.ordinal()];
/// ORDER: LEXICAL ///
@ -116,7 +143,7 @@ public class RenderBlocksCT extends RenderBlocks {
@Override
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
initSideInfo();
initSideInfo(ForgeDirection.UP.ordinal());
CTFace face = CTContext.faces[ForgeDirection.UP.ordinal()];
/// ORDER: LEXICAL ///
@ -133,7 +160,7 @@ public class RenderBlocksCT extends RenderBlocks {
@Override
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
initSideInfo();
initSideInfo(ForgeDirection.DOWN.ordinal());
CTFace face = CTContext.faces[ForgeDirection.DOWN.ordinal()];
/// ORDER: LEXICAL ///
@ -150,7 +177,7 @@ public class RenderBlocksCT extends RenderBlocks {
@Override
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
initSideInfo();
initSideInfo(ForgeDirection.SOUTH.ordinal());
CTFace face = CTContext.faces[ForgeDirection.SOUTH.ordinal()];
/// ORDER: LEXICAL ///
@ -167,7 +194,7 @@ public class RenderBlocksCT extends RenderBlocks {
@Override
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
initSideInfo();
initSideInfo(ForgeDirection.NORTH.ordinal());
CTFace face = CTContext.faces[ForgeDirection.NORTH.ordinal()];
/// ORDER: LEXICAL ///

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 842 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B