From 5b9935f737c226847e668bde0185adbc6a5a8b7b Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Wed, 5 Apr 2017 20:41:13 +0300 Subject: some experiments --- ihl/items_blocks/MachineBaseBlock.java | 950 ++++++++++++++++----------------- 1 file changed, 455 insertions(+), 495 deletions(-) (limited to 'ihl/items_blocks/MachineBaseBlock.java') diff --git a/ihl/items_blocks/MachineBaseBlock.java b/ihl/items_blocks/MachineBaseBlock.java index a2d2a98..6276e93 100644 --- a/ihl/items_blocks/MachineBaseBlock.java +++ b/ihl/items_blocks/MachineBaseBlock.java @@ -14,6 +14,7 @@ import ihl.interfaces.IEnergyNetNode; import ihl.interfaces.IMultiPowerCableHolder; import ihl.processing.chemistry.ChemicalReactorTileEntity; import ihl.processing.chemistry.CryogenicDistillerTileEntity; +import ihl.processing.chemistry.DosingPumpTileEntity; import ihl.processing.chemistry.ElectrolysisBathTileEntity; import ihl.processing.chemistry.FluidizedBedReactorTileEntity; import ihl.processing.chemistry.FractionatorBottomTileEntity; @@ -67,97 +68,70 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class MachineBaseBlock extends Block implements ITileEntityProvider{ - +public class MachineBaseBlock extends Block implements ITileEntityProvider { + MachineType type; private static List instances = new ArrayList(); - + @SideOnly(Side.CLIENT) - IIcon textureSide, - textureBack, - textureFrontMuffleFurnance, - textureTop, - textureTopAchesonFurnance, - textureTopGoldFurnace, - textureFrontGoldFurnace, - textureSideGoldFurnace, - textureFrontCryogenicDistiller, - textureTopCryogenicDistiller, - textureBackCryogenicDistiller, - textureFrontChemicalReactor, - textureLeftMachineCasing, - textureTopMachineCasing, - textureRightMachineCasing, - textureFrontMachineCasing, - textureFrontPaperMachine, - textureBackMachineCasing, - bronzeTubTop, - bronzeTubSide, - steel, - redPaint, - greenPaint, - rubberInsulatedCase, - powerPort; - - public MachineBaseBlock(MachineType type1) - { + IIcon textureSide, textureBack, textureFrontMuffleFurnance, textureTop, textureTopAchesonFurnance, + textureTopGoldFurnace, textureFrontGoldFurnace, textureSideGoldFurnace, textureFrontCryogenicDistiller, + textureTopCryogenicDistiller, textureBackCryogenicDistiller, textureFrontChemicalReactor, + textureLeftMachineCasing, textureTopMachineCasing, textureRightMachineCasing, textureFrontMachineCasing, + textureFrontPaperMachine, textureBackMachineCasing, bronzeTubTop, bronzeTubSide, steel, redPaint, + greenPaint, rubberInsulatedCase, powerPort, dosingPumpBack, dosingPumpLeftSide, dosingPumpRightSide, + dosingPumpTop, dosingPumpFront; + + public MachineBaseBlock(MachineType type1) { super(Material.iron); - this.type=type1; - this.setCreativeTab(IHLCreativeTab.tab); - this.setBlockName(type.unlocalizedName); - this.setHardness(2F); - this.setResistance(1F); - instances.add(this); + this.type = type1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName(type.unlocalizedName); + this.setHardness(2F); + this.setResistance(1F); + instances.add(this); } - - + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(IC2.platform.isSimulating()) - { - TileEntity te = world.getTileEntity(x,y,z); - if(world.getBlock(x, y+1, z)==Blocks.fire) - { - if(te instanceof DetonationSprayingMachineTileEntity) - { - ((DetonationSprayingMachineTileEntity)te).operate(); - world.setBlockToAir(x, y+1, z); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (IC2.platform.isSimulating()) { + TileEntity te = world.getTileEntity(x, y, z); + boolean isPowered = world.isBlockIndirectlyGettingPowered(x, y, z); + if (te instanceof DosingPumpTileEntity) { + DosingPumpTileEntity dpte = (DosingPumpTileEntity) te; + dpte.setPowered(isPowered); + } + + if (world.getBlock(x, y + 1, z) == Blocks.fire) { + if (te instanceof DetonationSprayingMachineTileEntity) { + ((DetonationSprayingMachineTileEntity) te).operate(); + world.setBlockToAir(x, y + 1, z); } } } } - - + @Override - public void onBlockPreDestroy(World world, int x, int y, int z, int meta) - { - if(!world.isRemote) - { + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) { + if (!world.isRemote) { TileEntity te = world.getTileEntity(x, y, z); - if(te!=null) - { - if(te instanceof IEnergyNetNode) - { + if (te != null) { + if (te instanceof IEnergyNetNode) { IEnergyNetNode ate = (IEnergyNetNode) te; - ate.removeAttachedChains(); + ate.removeAttachedChains(); } - if(te instanceof IMultiPowerCableHolder) - { + if (te instanceof IMultiPowerCableHolder) { IMultiPowerCableHolder ate = (IMultiPowerCableHolder) te; - ate.removeAttachedChains(); + ate.removeAttachedChains(); } - if(te instanceof IronWorkbenchTileEntity) - { - IronWorkbenchTileEntity iwb=(IronWorkbenchTileEntity) te; + if (te instanceof IronWorkbenchTileEntity) { + IronWorkbenchTileEntity iwb = (IronWorkbenchTileEntity) te; iwb.dropContents(); - } - else if(te instanceof IInventory) - { - IInventory inventory = (IInventory)te; - for(int i = 0; i< inventory.getSizeInventory();i++) - { - if(inventory.getStackInSlot(i)!=null)world.spawnEntityInWorld(new EntityItem(world, x, y+1, z, inventory.getStackInSlot(i))); + } else if (te instanceof IInventory) { + IInventory inventory = (IInventory) te; + for (int i = 0; i < inventory.getSizeInventory(); i++) { + if (inventory.getStackInSlot(i) != null) + world.spawnEntityInWorld(new EntityItem(world, x, y + 1, z, inventory.getStackInSlot(i))); } } } @@ -167,10 +141,9 @@ public class MachineBaseBlock extends Block implements ITileEntityProvider{ @SuppressWarnings("rawtypes") @Override - public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) - { - switch(this.type) - { + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, + Entity entity) { + switch (this.type) { case BronzeTub: this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); @@ -184,496 +157,483 @@ public class MachineBaseBlock extends Block implements ITileEntityProvider{ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); this.setBlockBoundsForItemRender(); break; - default: - super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); - break; + default: + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + break; } - } - - @Override - public void setBlockBoundsForItemRender() - { - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public static void init() - { + } + + @Override + public void setBlockBoundsForItemRender() { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public static void init() { MachineType[] var1 = MachineType.values(); - for(int i=0;i teclass1, boolean isNormalBlock1,ItemStack itemDroppedOnBlockDestroy1) - { - unlocalizedName=unlocalizedName1; - teclass=teclass1; - isNormalBlock=isNormalBlock1; - if(isNormalBlock) - { - specialBlockRendererId=0; - } - else - { - specialBlockRendererId=-2; - } - itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1; - } - MachineType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1,boolean hasSpecialBlockRenderer1, ItemStack itemDroppedOnBlockDestroy1) - { - unlocalizedName=unlocalizedName1; - teclass=teclass1; - isNormalBlock=isNormalBlock1; - hasSpecialBlockRenderer=hasSpecialBlockRenderer1; - itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1; - - } + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int metadata) { + return this.isProvidingWeakPower(world, x, y, z, metadata); + } + + public enum MachineType { + DosingPump("dosingPump", DosingPumpTileEntity.class, true, null), + IronWorkbench("ironWorkbench", IronWorkbenchTileEntity.class, false, true, null), + ElectrolysisBath("electrolysisBath", ElectrolysisBathTileEntity.class, false, IHLUtils + .getThisModItemStack("plateGraphite")), + RectifierTransformerUnit("rectifierTransformerUnit", RectifierTransformerUnitTileEntity.class, false, true, IHLUtils + .getThisModItemStack("foilSteel")), + BatterySwitchUnit("batterySwitchUnit", BatterySwitchUnitTileEntity.class, false, IHLUtils + .getThisModItemStack("foilSteel")), + FractionatorBottom("fractionatorBottom", FractionatorBottomTileEntity.class, false, IHLUtils + .getThisModItemStack("foilSteel")), + FractionatorSection("fractionatorSection", FractionatorSectionTileEntity.class, false, IHLUtils + .getThisModItemStackWithSize("ringPorcelain", 16)), + FractionatorCover("fractionatorCover", FractionatorCoverTileEntity.class, false, IHLUtils + .getThisModItemStack("foilSteel")), + RefluxCondenser("refluxCondenser", RefluxCondenserTileEntity.class, false, false, IHLUtils + .getThisModItemStack("foilSteel")), + PaperMachine("paperMachine", PaperMachineTileEntity.class, true, IHLUtils.getThisModItemStack("stickSteel")), + GaedesMercuryRotaryPump("gaedesMercuryRotaryPump", GaedesMercuryRotaryPumpTileEntity.class, false, IHLUtils + .getThisModItemStack("foilSteel")), + LabElectrolyzer("labElectrolyzer", LabElectrolyzerTileEntity.class, true, IHLUtils + .getThisModItemStack("stickGraphite")), + FluidizedBedReactor("fluidizedBedReactor", FluidizedBedReactorTileEntity.class, true, IHLUtils + .getThisModItemStack("highPressureVesselSteel")), + ChemicalReactor("chemicalReactor", ChemicalReactorTileEntity.class, true, IHLUtils + .getThisModItemStack("highPressureVesselSteel")), + CryogenicDistiller("cryogenicDistiller", CryogenicDistillerTileEntity.class, true, IHLUtils + .getThisModItemStack("highPressureVesselSteel")), + GasWeldingStation("gasWeldingStation", GasWeldingStationTileEntity.class, false, null), + WoodenRollingMachine1("woodenRollingMachinePart1", WoodenRollingMachinePart1TileEntity.class, false, IHLUtils + .getThisModItemStack("barD10Steel")), + WoodenRollingMachine2("woodenRollingMachinePart2", WoodenRollingMachinePart2TileEntity.class, false, IHLUtils + .getThisModItemStack("barD10Steel")), + WireMill("wireMill", WireMillTileEntity.class, true, IHLUtils.getThisModItemStack("stickSteel")), + VulcanizationExtrudingMold("vulcanizationExtrudingMold", VulcanizationExtrudingMoldTileEntity.class, false, IHLUtils + .getThisModItemStack("dustCarborundum")), + Extruder("extruder", ExtruderTileEntity.class, false, IHLUtils.getThisModItemStack("dustCarborundum")), + RollingMachine1("rollingMachinePart1", RollingMachinePart1TileEntity.class, false, IHLUtils + .getThisModItemStack("stickSteel")), + RollingMachine2("rollingMachinePart2", RollingMachinePart2TileEntity.class, false, IHLUtils + .getThisModItemStack("stickSteel")), + Loom("loom", LoomTileEntity.class, false, new ItemStack(Items.stick)), + Coiler("coiler", CoilerTileEntity.class, false, new ItemStack(Items.stick)), + Lathe1("lathePart1", LathePart1TileEntity.class, false, IHLUtils.getThisModItemStack("stickSteel")), + Lathe2("lathePart2", LathePart2TileEntity.class, false, IHLUtils.getOreDictItemStack("plateSteel")), + LeadOven("leadOven", LeadOvenTileEntity.class, true, IHLUtils.getThisModItemStack("dustPorcelain")), + DetonationSprayingMachine("cannonBronze", DetonationSprayingMachineTileEntity.class, false, new ItemStack( + Items.stick)), + BronzeTub("tubBronze", ImpregnatingMachineTileEntity.class, false, true, null), + AchesonFurnace("achesonFurnance", AchesonFurnanceTileEntity.class, true, new ItemStack(Items.brick)), + MuffleFurnace("muffleFurnance", MuffleFurnanceTileEntity.class, true, new ItemStack(Items.brick)); + MachineType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1, + ItemStack itemDroppedOnBlockDestroy1) { + unlocalizedName = unlocalizedName1; + teclass = teclass1; + isNormalBlock = isNormalBlock1; + if (isNormalBlock) { + specialBlockRendererId = 0; + } else { + specialBlockRendererId = -2; + } + itemDroppedOnBlockDestroy = itemDroppedOnBlockDestroy1; + } + + MachineType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1, + boolean hasSpecialBlockRenderer1, ItemStack itemDroppedOnBlockDestroy1) { + unlocalizedName = unlocalizedName1; + teclass = teclass1; + isNormalBlock = isNormalBlock1; + hasSpecialBlockRenderer = hasSpecialBlockRenderer1; + itemDroppedOnBlockDestroy = itemDroppedOnBlockDestroy1; + + } + public String unlocalizedName; Class teclass; - boolean isNormalBlock=true; - boolean hasSpecialBlockRenderer=false; - int specialBlockRendererId=-2; + boolean isNormalBlock = true; + boolean hasSpecialBlockRenderer = false; + int specialBlockRendererId = -2; ItemStack itemDroppedOnBlockDestroy; - } - + } + @Override - public int getRenderType() - { - if(this.type.hasSpecialBlockRenderer) - { + public int getRenderType() { + if (this.type.hasSpecialBlockRenderer) { return IHLMod.proxy.shareBlockRendererByMachineType(this.type); } return this.type.specialBlockRendererId; } - + @Override - public boolean isOpaqueCube() - { - return this.type==null?false:this.type.isNormalBlock; + public boolean isOpaqueCube() { + return this.type == null ? false : this.type.isNormalBlock; } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return this.type.isNormalBlock; } - + @SideOnly(Side.CLIENT) - public IIcon getAdditionalIconsForBlockRenderer(int flag) - { - switch(this.type) - { - case BronzeTub: - return this.bronzeTubSide; - default: - return this.blockIcon; + public IIcon getAdditionalIconsForBlockRenderer(int flag) { + switch (this.type) { + case BronzeTub: + return this.bronzeTubSide; + default: + return this.blockIcon; } } - } \ No newline at end of file -- cgit v1.2.3