From 5cb4c6e24033cf337812390d99a6817d24d21eab Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Sun, 12 Feb 2017 20:43:03 +0300 Subject: Removed explosion radius limitations. Explosion calculation optimized (reduced memory usage). One more detonator and explosive pack recipe. GT6 recipes for both chemical reactors and cryogenic distiller. Max stack size of muffle furnace is limited to 32. A lot of old features are removed. --- ihl/ClientProxy.java | 34 +- ihl/IHLMod.java | 486 ++----- ihl/IHLModConfig.java | 99 +- ihl/IHLModInfo.java | 2 +- ihl/collector/ChargerEjectorBlock.java | 90 -- ihl/collector/ChargerEjectorContainer.java | 92 -- ihl/collector/ChargerEjectorGui.java | 128 -- ihl/collector/ChargerEjectorModel.java | 150 -- ihl/collector/ChargerEjectorRender.java | 92 -- ihl/collector/ChargerEjectorTileEntity.java | 522 ------- ihl/collector/CollectorEntity.java | 959 ------------- ihl/collector/CollectorHeavyEntity.java | 305 ---- ihl/collector/CollectorHeavyItem.java | 35 - ihl/collector/CollectorItem.java | 203 --- ihl/collector/CollectorItemRender.java | 112 -- ihl/collector/CollectorModel.java | 110 -- ihl/collector/CollectorRender.java | 112 -- ihl/collector/GlassBoxContainer.java | 45 - ihl/collector/GlassBoxGui.java | 44 - ihl/collector/GlassBoxRender.java | 47 - ihl/collector/GlassBoxTileEntity.java | 193 --- ihl/collector/GuiMultiTextureButton.java | 44 - ihl/collector/InvSlotMultiCharge.java | 96 -- ihl/crop_harvestors/BlowerBlock.java | 169 --- ihl/crop_harvestors/BlowerContainer.java | 89 -- ihl/crop_harvestors/BlowerGui.java | 58 - ihl/crop_harvestors/BlowerTileEntity.java | 1065 -------------- ihl/datanet/Contact.java | 254 ---- ihl/datanet/DataCableItem.java | 177 --- ihl/datanet/DataGrid.java | 60 - ihl/datanet/DataNet.java | 127 -- ihl/datanet/GuiInvisibleButton.java | 22 - ihl/datanet/RedstoneSignalConverterContainer.java | 100 -- ihl/datanet/RedstoneSignalConverterGui.java | 139 -- ihl/datanet/RedstoneSignalConverterTileEntity.java | 508 ------- ihl/enviroment/SpotlightTileEntity.java | 2 +- ihl/explosion/ChunkAndWorldLoadEventHandler.java | 72 +- ihl/explosion/DetonatorMiniGUI.java | 76 +- ihl/explosion/ExplosionEntityFX.java | 2 +- ihl/explosion/ExplosionVectorBlockV2.java | 686 ++++----- ihl/explosion/ExplosiveBlock.java | 4 +- ihl/explosion/ExplosiveTileEntity.java | 97 +- ihl/explosion/PileTileEntity.java | 83 +- ihl/flexible_cable/IronWorkbenchTileEntity.java | 393 +++--- ihl/flexible_cable/SetOfDiesMiniGUI.java | 81 +- ihl/guidebook/IHLGuidebookContainer.java | 30 - ihl/guidebook/IHLGuidebookGui.java | 276 ---- ihl/guidebook/IHLGuidebookInventory.java | 123 -- ihl/guidebook/IHLGuidebookItem.java | 63 - ihl/guidebook/IHLGuidebookSlot.java | 20 - ihl/handpump/AdvancedHandPump.java | 5 +- ihl/handpump/BlockWithCoordinates.java | 29 +- ihl/handpump/XYZ.java | 26 + ihl/i_hate_liquids/BlockDynamicLiquidPlus.java | 80 -- ihl/i_hate_liquids/IHLBucketHandler.java | 21 - ihl/i_hate_liquids/IHLEventHandler.java | 59 - ihl/i_hate_liquids/InvisibleMagicanEntity.java | 458 ------ ihl/i_hate_liquids/XYZ.java | 26 - ihl/interfaces/IDataCableHolder.java | 12 - ihl/interfaces/IDataNode.java | 21 - ihl/interfaces/ItemMiniGUI.java | 26 +- ihl/items_blocks/FlexibleCableItem.java | 15 +- ihl/items_blocks/IHLBucketHandler.java | 20 + ihl/items_blocks/IHLItemBlock.java | 43 - ihl/items_blocks/ItemSubstance.java | 514 ++++--- ihl/items_blocks/MachineBaseBlock.java | 150 +- ihl/model/FlexibleCableItemRender.java | 257 ++-- ihl/model/IHLToolRenderer.java | 15 - ihl/model/RenderGameOverlayEventHandler.java | 38 - ihl/model/SwitchBoxBlockRender.java | 127 -- .../ElectrolysisBathRecipeHandler.java | 7 + ihl/processing/chemistry/ElectrolysisBathGui.java | 3 +- .../invslots/InvSlotSignalProcessor.java | 123 -- ihl/processing/metallurgy/CrucibleInventory.java | 173 +-- ihl/processing/metallurgy/CrucibleSlot.java | 16 +- .../metallurgy/MuffleFurnanceTileEntity.java | 121 +- ihl/processing/metallurgy/PassiveBlock.java | 99 -- .../VacuumInductionMeltingFurnaceContainer.java | 77 -- .../VacuumInductionMeltingFurnaceGui.java | 85 -- .../VacuumInductionMeltingFurnaceTileEntity.java | 200 --- ihl/recipes/RecipeInputOreDictionaryList.java | 241 ++-- ihl/recipes/RecipeInputWire.java | 113 +- ihl/recipes/UniversalRecipeInput.java | 2 +- ihl/recipes/UniversalRecipeManager.java | 337 ++--- ihl/tunneling_shield/BlockItemRender.java | 206 --- ihl/tunneling_shield/DriverBlock.java | 109 -- ihl/tunneling_shield/DriverContainer.java | 79 -- ihl/tunneling_shield/DriverEntity.java | 69 - ihl/tunneling_shield/DriverGui.java | 102 -- ihl/tunneling_shield/DriverModel.java | 161 --- ihl/tunneling_shield/DriverRender.java | 50 - ihl/tunneling_shield/DriverRenderEntity.java | 147 -- ihl/tunneling_shield/DriverTileEntity.java | 1136 --------------- ihl/tunneling_shield/HorizontalMiningPipe.java | 276 ---- .../HydrotransportPulpRegeneratorContainer.java | 100 -- .../HydrotransportPulpRegeneratorGui.java | 59 - .../HydrotransportPulpRegeneratorTileEntity.java | 273 ---- ihl/tunneling_shield/IMultiBlock.java | 7 - ihl/tunneling_shield/MultiBlockSpacerBlock.java | 223 --- ihl/utils/BlockItemRender.java | 206 +++ ihl/utils/GuiMultiTextureButton.java | 44 + ihl/utils/IHLUtils.java | 1459 ++++++++------------ ihl/utils/IHLXMLParser.java | 92 -- ihl/utils/PlayerWakeUpEventHandler.java | 17 - ihl/worldgen/ores/IHLFluid.java | 3 +- 105 files changed, 2434 insertions(+), 14699 deletions(-) delete mode 100644 ihl/collector/ChargerEjectorBlock.java delete mode 100644 ihl/collector/ChargerEjectorContainer.java delete mode 100644 ihl/collector/ChargerEjectorGui.java delete mode 100644 ihl/collector/ChargerEjectorModel.java delete mode 100644 ihl/collector/ChargerEjectorRender.java delete mode 100644 ihl/collector/ChargerEjectorTileEntity.java delete mode 100644 ihl/collector/CollectorEntity.java delete mode 100644 ihl/collector/CollectorHeavyEntity.java delete mode 100644 ihl/collector/CollectorHeavyItem.java delete mode 100644 ihl/collector/CollectorItem.java delete mode 100644 ihl/collector/CollectorItemRender.java delete mode 100644 ihl/collector/CollectorModel.java delete mode 100644 ihl/collector/CollectorRender.java delete mode 100644 ihl/collector/GlassBoxContainer.java delete mode 100644 ihl/collector/GlassBoxGui.java delete mode 100644 ihl/collector/GlassBoxRender.java delete mode 100644 ihl/collector/GlassBoxTileEntity.java delete mode 100644 ihl/collector/GuiMultiTextureButton.java delete mode 100644 ihl/collector/InvSlotMultiCharge.java delete mode 100644 ihl/crop_harvestors/BlowerBlock.java delete mode 100644 ihl/crop_harvestors/BlowerContainer.java delete mode 100644 ihl/crop_harvestors/BlowerGui.java delete mode 100644 ihl/crop_harvestors/BlowerTileEntity.java delete mode 100644 ihl/datanet/Contact.java delete mode 100644 ihl/datanet/DataCableItem.java delete mode 100644 ihl/datanet/DataGrid.java delete mode 100644 ihl/datanet/DataNet.java delete mode 100644 ihl/datanet/GuiInvisibleButton.java delete mode 100644 ihl/datanet/RedstoneSignalConverterContainer.java delete mode 100644 ihl/datanet/RedstoneSignalConverterGui.java delete mode 100644 ihl/datanet/RedstoneSignalConverterTileEntity.java delete mode 100644 ihl/guidebook/IHLGuidebookContainer.java delete mode 100644 ihl/guidebook/IHLGuidebookGui.java delete mode 100644 ihl/guidebook/IHLGuidebookInventory.java delete mode 100644 ihl/guidebook/IHLGuidebookItem.java delete mode 100644 ihl/guidebook/IHLGuidebookSlot.java create mode 100644 ihl/handpump/XYZ.java delete mode 100644 ihl/i_hate_liquids/BlockDynamicLiquidPlus.java delete mode 100644 ihl/i_hate_liquids/IHLBucketHandler.java delete mode 100644 ihl/i_hate_liquids/IHLEventHandler.java delete mode 100644 ihl/i_hate_liquids/InvisibleMagicanEntity.java delete mode 100644 ihl/i_hate_liquids/XYZ.java delete mode 100644 ihl/interfaces/IDataCableHolder.java delete mode 100644 ihl/interfaces/IDataNode.java create mode 100644 ihl/items_blocks/IHLBucketHandler.java delete mode 100644 ihl/model/RenderGameOverlayEventHandler.java delete mode 100644 ihl/model/SwitchBoxBlockRender.java delete mode 100644 ihl/processing/invslots/InvSlotSignalProcessor.java delete mode 100644 ihl/processing/metallurgy/PassiveBlock.java delete mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java delete mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java delete mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java delete mode 100644 ihl/tunneling_shield/BlockItemRender.java delete mode 100644 ihl/tunneling_shield/DriverBlock.java delete mode 100644 ihl/tunneling_shield/DriverContainer.java delete mode 100644 ihl/tunneling_shield/DriverEntity.java delete mode 100644 ihl/tunneling_shield/DriverGui.java delete mode 100644 ihl/tunneling_shield/DriverModel.java delete mode 100644 ihl/tunneling_shield/DriverRender.java delete mode 100644 ihl/tunneling_shield/DriverRenderEntity.java delete mode 100644 ihl/tunneling_shield/DriverTileEntity.java delete mode 100644 ihl/tunneling_shield/HorizontalMiningPipe.java delete mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorContainer.java delete mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java delete mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java delete mode 100644 ihl/tunneling_shield/IMultiBlock.java delete mode 100644 ihl/tunneling_shield/MultiBlockSpacerBlock.java create mode 100644 ihl/utils/BlockItemRender.java create mode 100644 ihl/utils/GuiMultiTextureButton.java delete mode 100644 ihl/utils/IHLXMLParser.java delete mode 100644 ihl/utils/PlayerWakeUpEventHandler.java (limited to 'ihl') diff --git a/ihl/ClientProxy.java b/ihl/ClientProxy.java index 1a55e27..6b0dac0 100644 --- a/ihl/ClientProxy.java +++ b/ihl/ClientProxy.java @@ -8,21 +8,11 @@ import java.util.Map; import javax.xml.parsers.ParserConfigurationException; -import ihl.collector.ChargerEjectorModel; -import ihl.collector.ChargerEjectorRender; -import ihl.collector.ChargerEjectorTileEntity; -import ihl.collector.CollectorEntity; -import ihl.collector.CollectorHeavyEntity; -import ihl.collector.CollectorItemRender; -import ihl.collector.CollectorRender; -import ihl.collector.GlassBoxRender; -import ihl.collector.GlassBoxTileEntity; import ihl.crop_harvestors.BlobEntityFX; import ihl.crop_harvestors.BlobEntityFX.FluidType; import ihl.crop_harvestors.BlobRenderFX; import ihl.crop_harvestors.SackRender; import ihl.crop_harvestors.SackTileEntity; -import ihl.datanet.DataCableItem; import ihl.enviroment.LightBulbModel; import ihl.enviroment.LightBulbRender; import ihl.enviroment.LightBulbTileEntity; @@ -104,12 +94,7 @@ import ihl.servitor.FlameRenderFX; import ihl.servitor.LostHeadEntity; import ihl.servitor.LostHeadRender; import ihl.servitor.SkullItemRender; -import ihl.tunneling_shield.BlockItemRender; -import ihl.tunneling_shield.DriverEntity; -import ihl.tunneling_shield.DriverModel; -import ihl.tunneling_shield.DriverRender; -import ihl.tunneling_shield.DriverRenderEntity; -import ihl.tunneling_shield.DriverTileEntity; +import ihl.utils.BlockItemRender; import ihl.utils.IHLRenderUtils; import ihl.utils.IHLUtils; import ihl.worldgen.ores.IHLFluid; @@ -125,7 +110,6 @@ import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; @@ -164,25 +148,16 @@ public class ClientProxy extends ServerProxy { this.renderUtils=new IHLRenderUtils(); MinecraftForge.EVENT_BUS.register(this.renderUtils); - registerBlockHandler(new ImpregnatingMachineBlockRender(), MachineType.BronzeTub, MachineType.GlassBox); + registerBlockHandler(new ImpregnatingMachineBlockRender(), MachineType.BronzeTub); registerBlockHandler(new RefluxCondenserBlockRender(), MachineType.RefluxCondenser); - registerBlockHandler(new SwitchBoxBlockRender(), MachineType.RedstoneSignalConverter); registerBlockHandler(new RectifierTransformerUnitBlockRender(), MachineType.RectifierTransformerUnit); registerBlockHandler(new IronWorkbenchBlockRender(), MachineType.IronWorkbench); PileBlockRender pileBlockRender = new PileBlockRender(); RenderingRegistry.registerBlockHandler(pileBlockRender); ClientRegistry.bindTileEntitySpecialRenderer(PileTileEntity.class, pileBlockRender.pileTileEntityRender); - RenderingRegistry.registerEntityRenderingHandler(CollectorEntity.class, new CollectorRender(false)); - MinecraftForgeClient.registerItemRenderer(IHLMod.collectorItem, new CollectorItemRender(false)); - RenderingRegistry.registerEntityRenderingHandler(CollectorHeavyEntity.class, new CollectorRender(true)); - MinecraftForgeClient.registerItemRenderer(IHLMod.collectorHeavyItem, new CollectorItemRender(true)); - RenderingRegistry.registerEntityRenderingHandler(DriverEntity.class, new DriverRenderEntity()); RenderingRegistry.registerEntityRenderingHandler(IHLEntityFallingPile.class, new IHLEntityFallingPileRender()); - ClientRegistry.bindTileEntitySpecialRenderer(ChargerEjectorTileEntity.class, new ChargerEjectorRender()); - ClientRegistry.bindTileEntitySpecialRenderer(DriverTileEntity.class, new DriverRender()); ClientRegistry.bindTileEntitySpecialRenderer(SackTileEntity.class, new SackRender()); - ClientRegistry.bindTileEntitySpecialRenderer(GlassBoxTileEntity.class, new GlassBoxRender()); ClientRegistry.bindTileEntitySpecialRenderer(LathePart1TileEntity.class, new UniversalTileRender(new LathePart1Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"))); ClientRegistry.bindTileEntitySpecialRenderer(LathePart2TileEntity.class, new UniversalTileRender(new LathePart2Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"))); ClientRegistry.bindTileEntitySpecialRenderer(LoomTileEntity.class, new UniversalTileRender(new LoomModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/detonationSprayingMachine.png"))); @@ -214,8 +189,6 @@ public class ClientProxy extends ServerProxy { ClientRegistry.bindTileEntitySpecialRenderer(SpotlightTileEntity.class, new SpotlightRender()); selectionBoxSpecialRendererRegistry.put(AnchorTileEntity.class, new CableHolderSelectionBoxSpecialRenderer()); selectionBoxSpecialRendererRegistry.put(RectifierTransformerUnitTileEntity.class, new RectifierTransformerUnitSelectionBoxSpecialRenderer()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(IHLMod.driverBlock), new BlockItemRender(new DriverModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/shield.png"), 5, 2, 0F, 0.0F)); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(IHLMod.chargerEjectorBlock), new BlockItemRender(new ChargerEjectorModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/chargerEjector.png"), 0, 6, 0.5F, 0.0F)); MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("goldPrecipitatorCondenser"), new BlockItemRender(new PrecipitatorCondenserModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/porcelainBox.png"), 0, 0, 0.0F, 0.0F)); MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("goldChimneyKnee"), new BlockItemRender(new GoldChimneyKneeModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/porcelainBox.png"), 0, 0, 0.0F, 0.0F)); MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("cannonBronze"), new BlockItemRender(new DetonationSprayingMachineModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/detonationSprayingMachine.png"), 0, 0, 0.0F, 0.0F)); @@ -242,15 +215,12 @@ public class ClientProxy extends ServerProxy { MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("spotlight"), new BlockItemRender(new SpotlightModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/spotlight.png"), 0, 1, 0.0F, 0.0F)); MinecraftForgeClient.registerItemRenderer(IHLTool.instance, new IHLToolRenderer()); MinecraftForgeClient.registerItemRenderer(FlexibleCableItem.instance, new FlexibleCableItemRender()); - MinecraftForgeClient.registerItemRenderer(DataCableItem.dataCableInstance, new FlexibleCableItemRender()); RenderingRegistry.registerEntityRenderingHandler(LostHeadEntity.class, new LostHeadRender()); RenderingRegistry.registerEntityRenderingHandler(FlameEntityFX.class, new FlameRenderFX(IHLModInfo.MODID+":textures/particles/flameTongue.png")); RenderingRegistry.registerEntityRenderingHandler(BlastEntityFX.class, new FlameRenderFX(IHLModInfo.MODID+":textures/particles/blast.png")); RenderingRegistry.registerEntityRenderingHandler(BlobEntityFX.class, new BlobRenderFX()); RenderingRegistry.registerEntityRenderingHandler(ExplosionEntityFX.class, new ExplosionRenderFX(IHLModInfo.MODID+":textures/particles/explosion.png")); RenderingRegistry.registerEntityRenderingHandler(NodeEntity.class, new NodeRender()); - MinecraftForge.EVENT_BUS.register(new RenderGameOverlayEventHandler()); - } @Override diff --git a/ihl/IHLMod.java b/ihl/IHLMod.java index 9635d41..c9470b5 100644 --- a/ihl/IHLMod.java +++ b/ihl/IHLMod.java @@ -12,7 +12,6 @@ import javax.xml.parsers.ParserConfigurationException; import org.apache.logging.log4j.Logger; -import codechicken.lib.config.ConfigTag; import codechicken.nei.NEIModContainer; import gregapi.data.IL; import gregapi.data.MT; @@ -33,8 +32,6 @@ import ic2.api.recipe.RecipeInputOreDict; import ic2.api.recipe.Recipes; import ic2.core.Ic2Items; import ic2.core.util.StackUtil; -import ihl.datanet.DataCableItem; -import ihl.datanet.DataNet; import ihl.enviroment.LaserHitMirrorEventHandler; import ihl.enviroment.LightBulbBlock; import ihl.enviroment.MirrorBlock; @@ -50,16 +47,12 @@ import ihl.flexible_cable.IHLENet; import ihl.flexible_cable.IronWorkbenchTileEntity; import ihl.flexible_cable.NodeEntity; import ihl.flexible_cable.PowerCableNodeEntity; -import ihl.guidebook.IHLGuidebookItem; import ihl.handpump.AdvancedHandPump; import ihl.handpump.IHLHandPump; -import ihl.i_hate_liquids.BlockDynamicLiquidPlus; -import ihl.i_hate_liquids.IHLBucketHandler; -import ihl.i_hate_liquids.IHLEventHandler; import ihl.items_blocks.FiberItem; import ihl.items_blocks.FlexibleCableItem; import ihl.items_blocks.FlexiblePipeItem; -import ihl.items_blocks.IHLItemBlock; +import ihl.items_blocks.IHLBucketHandler; import ihl.items_blocks.IHLTool; import ihl.items_blocks.ItemSubstance; import ihl.items_blocks.MachineBaseBlock; @@ -91,25 +84,17 @@ import ihl.processing.metallurgy.GasWeldingStationTileEntity; import ihl.processing.metallurgy.ImpregnatingMachineTileEntity; import ihl.processing.metallurgy.InjectionMoldBlock; import ihl.processing.metallurgy.MuffleFurnanceTileEntity; -import ihl.processing.metallurgy.PassiveBlock; import ihl.processing.metallurgy.RollingMachinePart1TileEntity; import ihl.processing.metallurgy.VulcanizationExtrudingMoldTileEntity; import ihl.processing.metallurgy.WireMillTileEntity; import ihl.processing.metallurgy.WoodenRollingMachinePart1TileEntity; -import ihl.collector.ChargerEjectorBlock; -import ihl.collector.ChargerEjectorTileEntity; -import ihl.collector.CollectorHeavyEntity; -import ihl.collector.CollectorHeavyItem; -import ihl.collector.CollectorItem; -import ihl.collector.CollectorEntity; -import ihl.crop_harvestors.BlowerBlock; -import ihl.crop_harvestors.BlowerTileEntity; import ihl.crop_harvestors.RubberTreeBlock; import ihl.crop_harvestors.SackBlock; import ihl.crop_harvestors.SackTileEntity; import ihl.recipes.IronWorkbenchRecipe; import ihl.recipes.RecipeInputDetonator; import ihl.recipes.RecipeInputDie; +import ihl.recipes.RecipeInputOreDictionaryList; import ihl.recipes.RecipeInputWire; import ihl.recipes.RecipeOutputItemStack; import ihl.recipes.UniversalRecipeInput; @@ -119,14 +104,9 @@ import ihl.servitor.LostHeadEntity; import ihl.trans_dimensional_item_teleporter.TDITBlock; import ihl.trans_dimensional_item_teleporter.TDITFrequencyTransmitter; import ihl.trans_dimensional_item_teleporter.TDITTileEntity; -import ihl.tunneling_shield.DriverBlock; -import ihl.tunneling_shield.DriverTileEntity; -import ihl.tunneling_shield.HorizontalMiningPipe; -import ihl.tunneling_shield.MultiBlockSpacerBlock; import ihl.utils.EntityDropEventHandler; import ihl.utils.FluidDictionary; import ihl.utils.IHLUtils; -import ihl.utils.IHLXMLParser; import ihl.worldgen.IHLWorldGenerator; import ihl.worldgen.ores.BlockOre; import ihl.worldgen.ores.DebugScannerBlock; @@ -171,36 +151,16 @@ public class IHLMod implements IFuelHandler { // GregTech recipes. public static boolean isGregTechModLoaded = false; public static boolean isGT_API_Version_5 = false; - // This used to determine if CCC presented on server and do not use - // alternative water blocks if true. - public static boolean cccFiniteWater = false; - public static Block driverBlock; - public static Block blowerBlock; public static Block cableAnchorBlock; public static Block sackBlock; public static Block rubberTreeBlock; public static Block spruceTreeBlock; public static Block evaporatorBlock; public static Block electricEvaporatorBlock; - public static Block multiBlockSpacerBlock = (new MultiBlockSpacerBlock()).setBlockName("IHLMultiBlockSpacerBlock") - .setBlockTextureName(IHLModInfo.MODID + ":shieldAU").setHardness(5.0F).setResistance(5.0F); public static Block boneBlock = (new BoneBlock(Material.coral)).setBlockName("boneBlock").setHardness(2.0F) .setResistance(2.0F); public static Item ic2_handpump; public static Item ic2_advanced_handpump; - public static Item collectorItem = new CollectorItem().setUnlocalizedName("collector"); - public static Item collectorHeavyItem = new CollectorHeavyItem().setUnlocalizedName("collectorHeavy"); - public static Block horizontalMiningPipeX = (new HorizontalMiningPipe(1)).setBlockName("horizontalMiningPipeX") - .setBlockTextureName("ic2:machine/blockMiningPipe").setHardness(5.0F).setResistance(5.0F); - public static Block horizontalMiningPipeZ = (new HorizontalMiningPipe(0)).setBlockName("horizontalMiningPipeZ") - .setBlockTextureName("ic2:machine/blockMiningPipe").setHardness(5.0F).setResistance(5.0F); - public static Block flowing_water = (new BlockDynamicLiquidPlus(Material.water)).setHardness(100.0F) - .setLightOpacity(3).setBlockName("water").setBlockTextureName(IHLModInfo.MODID + ":metalShards"); - public static Block flowing_lava = (new BlockDynamicLiquidPlus(Material.lava)).setHardness(100.0F) - .setLightLevel(1.0F).setBlockName("lava").setBlockTextureName(IHLModInfo.MODID + ":metalShards"); - public static Block chargerEjectorBlock = (new ChargerEjectorBlock(Material.glass)) - .setBlockName("chargerEjectorBlock").setBlockTextureName(IHLModInfo.MODID + ":ace").setHardness(2.0F) - .setResistance(2.0F); public static Item ihlSkull = (new Item()).setUnlocalizedName("skull").setFull3D() .setCreativeTab(CreativeTabs.tabMisc).setTextureName(IHLModInfo.MODID + ":skull"); public static Block ic2Leaves; @@ -212,10 +172,8 @@ public class IHLMod implements IFuelHandler { .setBlockTextureName(IHLModInfo.MODID + ":tditTop"); public static Item crucible; public static Logger log; - public static DataNet datanet; private ItemStack pfaalimestone; private ItemStack pfaacobblelimestone; - public static IHLXMLParser xmlparser; public static FluidDictionary fluidDictionary; public static Map moltenAmounts = new HashMap(); public static ExplosionVectorBlockV2 explosionHandler; @@ -223,7 +181,6 @@ public class IHLMod implements IFuelHandler { @EventHandler public void preInit(FMLPreInitializationEvent evt) throws IOException, ParserConfigurationException { fluidDictionary = new FluidDictionary(); - xmlparser = new IHLXMLParser(); log = evt.getModLog(); IHLMod.config = new IHLModConfig(evt); rubberTreeBlock = (new RubberTreeBlock(RubberTreeBlock.TreeType.RUBBERTREE)).setBlockName("rubberTreeBlock") @@ -232,7 +189,6 @@ public class IHLMod implements IFuelHandler { .setBlockTextureName(IHLModInfo.MODID + ":blockSpruceFront").setHardness(2.0F).setResistance(5.0F) .setCreativeTab(IHLCreativeTab.tab); GameRegistry.registerFuelHandler(this); - PassiveBlock.init(); FiberItem.init(); FlexiblePipeItem.init(); InjectionMoldBlock.init(); @@ -247,10 +203,6 @@ public class IHLMod implements IFuelHandler { LightBulbBlock.init(); MachineBaseBlock.init();// must be first IHLMod.enet = new IHLENet(); - IHLMod.datanet = new DataNet(); - if (config.enableExtendedLiquidPhysics) { - MinecraftForge.EVENT_BUS.register(new IHLEventHandler()); - } MinecraftForge.EVENT_BUS.register(new EntityDropEventHandler()); MinecraftForge.EVENT_BUS.register(new LaserHitMirrorEventHandler()); MinecraftForge.EVENT_BUS.register(new IHLBucketHandler()); @@ -261,10 +213,8 @@ public class IHLMod implements IFuelHandler { cableAnchorBlock = new AnchorBlock("cableAnchor"); List info1 = new ArrayList(); info1.add("non vulcanized rubber insulated"); - DataCableItem.init(); GroundRemoverItem.init(); FlexibleCableItem.init(); - IHLGuidebookItem.init(); ExplosiveBlock.init(); PileBlock.init(); GameRegistry.registerTileEntity(AnchorTileEntity.class, "anchorTileEntity"); @@ -274,11 +224,6 @@ public class IHLMod implements IFuelHandler { ic2_handpump = new IHLHandPump().setUnlocalizedName("handpump"); ic2_advanced_handpump = new AdvancedHandPump().setUnlocalizedName("advanced_handpump"); tditft = new TDITFrequencyTransmitter().setUnlocalizedName("tditFrequencyTransmitter"); - driverBlock = (new DriverBlock(Material.iron)).setBlockName("IHLDriverBlock") - .setBlockTextureName(IHLModInfo.MODID + ":driver").setHardness(5.0F).setResistance(5.0F); - - blowerBlock = (new BlowerBlock(Material.iron)).setBlockName("blowerBlock") - .setBlockTextureName(IHLModInfo.MODID + ":shieldAU").setHardness(5.0F).setResistance(5.0F); evaporatorBlock = (new EvaporatorBlock(Material.iron)).setBlockName("evaporatorBlock") .setBlockTextureName(IHLModInfo.MODID + ":solidFuelEvaporatorFrontActive").setHardness(5.0F) @@ -289,35 +234,12 @@ public class IHLMod implements IFuelHandler { sackBlock = (new SackBlock(Material.iron)).setBlockName("sackBlock") .setBlockTextureName(IHLModInfo.MODID + ":sackItem").setHardness(0.5F).setResistance(0.5F); - GameRegistry.registerBlock(horizontalMiningPipeX, "horizontalMiningPipeX"); - GameRegistry.registerBlock(horizontalMiningPipeZ, "horizontalMiningPipeZ"); GameRegistry.registerBlock(boneBlock, "boneBlock"); - GameRegistry.registerBlock(blowerBlock, "blowerBlock"); - GameRegistry.registerTileEntity(BlowerTileEntity.class, "blowerTileEntity"); - GameRegistry.registerItem(ic2_handpump, "Handpump"); GameRegistry.registerItem(ic2_advanced_handpump, ic2_advanced_handpump.getUnlocalizedName()); GameRegistry.registerItem(ihlSkull, "skull"); - GameRegistry.registerBlock(driverBlock, IHLItemBlock.class, "IHLDriverBlock"); - GameRegistry.registerTileEntity(DriverTileEntity.class, "IHLDriverTileEntity"); - - GameRegistry.registerBlock(chargerEjectorBlock, IHLItemBlock.class, "chargerEjectorBlock"); - GameRegistry.registerTileEntity(ChargerEjectorTileEntity.class, "ChargerEjectorTileEntity"); - - GameRegistry.registerBlock(multiBlockSpacerBlock, "IHLShieldBlock"); - - GameRegistry.registerBlock(flowing_water, "flowing_water"); - GameRegistry.registerBlock(flowing_lava, "flowing_lava"); - - GameRegistry.registerItem(collectorItem, "collectorItem"); - - GameRegistry.registerItem(collectorHeavyItem, "collectorHeavyItem"); - - // NetworkRegistry.INSTANCE.registerGuiHandler(this, new - // IHLGuiHandler()); - GameRegistry.registerBlock(rubberTreeBlock, "rubberTreeBlock"); GameRegistry.registerBlock(spruceTreeBlock, "spruceTreeBlock"); GameRegistry.registerBlock(sackBlock, "sackBlock"); @@ -334,6 +256,8 @@ public class IHLMod implements IFuelHandler { registerEntities(); OreDictionary.registerOre("ingotBrick", Items.brick); OreDictionary.registerOre("dustGunpowder", Items.gunpowder); + OreDictionary.registerOre("toolLighter", Items.flint_and_steel); + OreDictionary.registerOre("charcoal", new ItemStack(Items.coal,1,1)); OreDictionary.registerOre("blockDirt", new ItemStack(Blocks.dirt, 1, OreDictionary.WILDCARD_VALUE)); OreDictionary.registerOre("blockDirt", new ItemStack(Blocks.grass, 1, OreDictionary.WILDCARD_VALUE)); OreDictionary.registerOre("platePaper", new ItemStack(Items.paper, 1, OreDictionary.WILDCARD_VALUE)); @@ -349,19 +273,6 @@ public class IHLMod implements IFuelHandler { public void postInit(FMLPostInitializationEvent evt) throws IOException { ic2Leaves = StackUtil.getBlock(IC2Items.getItem("rubberLeaves")); ic2Wood = StackUtil.getBlock(IC2Items.getItem("rubberWood")); - boolean isCodeChickenCoreLoaded = true; - try { - Class.forName("codechicken.core.asm.TweakTransformer"); - } catch (ClassNotFoundException e) { - isCodeChickenCoreLoaded = false; - } - if (isCodeChickenCoreLoaded) { - codechicken.core.asm.CodeChickenCoreModContainer.loadConfig(); - ConfigTag tweaks = codechicken.core.asm.CodeChickenCoreModContainer.config.getTag("tweaks"); - cccFiniteWater = tweaks.getTag("finiteWater") - .setComment("If set to true two adjacent water source blocks will not generate a third.") - .getBooleanValue(true); - } if (!IHLMod.config.skipRecipeLoad) { if (IHLMod.config.enableRubberTreeSack) { GameRegistry.addRecipe(new ItemStack(sackBlock, 1), @@ -382,8 +293,6 @@ public class IHLMod implements IFuelHandler { Character.valueOf('C'), IC2Items.getItem("copperCableItem"), Character.valueOf('A'), IC2Items.getItem("advancedCircuit") }); } - GameRegistry.addRecipe(IHLUtils.getThisModItemStack("glassBoxBlock"), - new Object[] { " ", "G G", "GGG", 'G', new ItemStack(Blocks.glass_pane, 1) }); GameRegistry.addRecipe(new ItemStack(boneBlock, 1), new Object[] { "XXX", "XYX", "XXX", 'X', Items.bone, 'Y', Items.iron_ingot }); GameRegistry.addRecipe(new ItemStack(boneBlock, 1), @@ -562,46 +471,6 @@ public class IHLMod implements IFuelHandler { advBattery.setItemDamage(OreDictionary.WILDCARD_VALUE); chargedReBattery.setItemDamage(OreDictionary.WILDCARD_VALUE); - if (IHLMod.config.enableCollectors) { - Recipes.advRecipes.addRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "ICI", "RER", "IZI", Character.valueOf('I'), IC2Items.getItem("ironCableItem"), - Character.valueOf('C'), IC2Items.getItem("casingiron"), Character.valueOf('R'), - IC2Items.getItem("reBattery"), Character.valueOf('E'), - new ItemStack(Items.ender_pearl, 1), Character.valueOf('Z'), - IC2Items.getItem("advancedCircuit") }); - Recipes.advRecipes.addRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "ICI", "RER", "IZI", Character.valueOf('I'), IC2Items.getItem("ironCableItem"), - Character.valueOf('C'), IC2Items.getItem("casingiron"), Character.valueOf('R'), - chargedReBattery, Character.valueOf('E'), new ItemStack(Items.ender_pearl, 1), - Character.valueOf('Z'), IC2Items.getItem("advancedCircuit") }); - Recipes.advRecipes.addRecipe(((CollectorItem) collectorHeavyItem).getItemStack(0), - new Object[] { "ICI", "RER", "IZI", Character.valueOf('I'), IC2Items.getItem("ironCableItem"), - Character.valueOf('C'), IC2Items.getItem("casingbronze"), Character.valueOf('R'), - advBattery, Character.valueOf('E'), new ItemStack(Items.ender_pearl, 1), - Character.valueOf('Z'), IC2Items.getItem("advancedCircuit") }); - - Recipes.advRecipes.addRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "ICI", "RER", "IZI", Character.valueOf('I'), IC2Items.getItem("ironCableItem"), - Character.valueOf('C'), IC2Items.getItem("casingiron"), Character.valueOf('R'), - IC2Items.getItem("reBattery"), Character.valueOf('E'), - IC2Items.getItem("advancedMachine"), Character.valueOf('Z'), - IC2Items.getItem("advancedCircuit") }); - Recipes.advRecipes.addRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "ICI", "RER", "IZI", Character.valueOf('I'), IC2Items.getItem("ironCableItem"), - Character.valueOf('C'), IC2Items.getItem("casingiron"), Character.valueOf('R'), - chargedReBattery, Character.valueOf('E'), IC2Items.getItem("advancedMachine"), - Character.valueOf('Z'), IC2Items.getItem("advancedCircuit") }); - Recipes.advRecipes.addRecipe(((CollectorItem) collectorHeavyItem).getItemStack(0), - new Object[] { "ICI", "RER", "IZI", Character.valueOf('I'), IC2Items.getItem("ironCableItem"), - Character.valueOf('C'), IC2Items.getItem("casingbronze"), Character.valueOf('R'), - advBattery, Character.valueOf('E'), IC2Items.getItem("advancedMachine"), - Character.valueOf('Z'), IC2Items.getItem("advancedCircuit") }); - - Recipes.advRecipes.addRecipe(new ItemStack(IHLMod.chargerEjectorBlock, 1), - new Object[] { "PGP", "GCG", "GLG", Character.valueOf('P'), IC2Items.getItem("platelapi"), - Character.valueOf('G'), new ItemStack(Blocks.glass, 1), Character.valueOf('C'), - IC2Items.getItem("glassFiberCableItem"), Character.valueOf('L'), crystal }); - } if (IHLMod.config.enableHandpump) { Recipes.advRecipes.addRecipe(((IHLHandPump) ic2_handpump).getItemStack(0), new Object[] { "T ", " C ", " P", Character.valueOf('T'), IC2Items.getItem("treetap"), @@ -856,13 +725,13 @@ public class IHLMod implements IFuelHandler { IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hackSawSteel"), IHLUtils.getThisModItemStack("setOfFilesSteel") }), - Arrays.asList(new IRecipeInput[] { new RecipeInputItemStack(IHLUtils.getThisModItemStack("setOfPartsForLVElemotorSteel")), - new RecipeInputFluidContainer(FluidRegistry.getFluid("spruceresin"),1), - new RecipeInputWire("Copper", 4, 15), - new RecipeInputItemStack(new ItemStack(Items.paper)), - new RecipeInputItemStack(new ItemStack(Blocks.planks,1,OreDictionary.WILDCARD_VALUE)), + Arrays.asList(new IRecipeInput[] { + new RecipeInputItemStack(IHLUtils.getThisModItemStack("setOfPartsForLVElemotorSteel")), + new RecipeInputFluidContainer(FluidRegistry.getFluid("spruceresin"), 1), + new RecipeInputWire("Copper", 4, 15), new RecipeInputItemStack(new ItemStack(Items.paper)), + new RecipeInputItemStack(new ItemStack(Blocks.planks, 1, OreDictionary.WILDCARD_VALUE)), new RecipeInputItemStack(IHLUtils.getThisModItemStack("linerIronGraphiteGreased"), 2) }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("electricMotorLVLEDC")}))); + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("electricMotorLVLEDC") }))); IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteHot"), IHLUtils.getThisModItemStack("muttonLard") }), @@ -1186,20 +1055,22 @@ public class IHLMod implements IFuelHandler { new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"), 1) }), Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump") }), Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); - IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), - Arrays.asList(new IRecipeInput[] { - new RecipeInputFluidContainer(FluidRegistry.getFluid("mineraloil"), 1), - new RecipeInputOreDict("foilMica"), new RecipeInputOreDict("foilCopper"), - new RecipeInputOreDict("foilSteel") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("highVoltageCapacitor") }))); - IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), - Arrays.asList(new IRecipeInput[] { - new RecipeInputFluidContainer(FluidRegistry.getFluid("mineraloil"), 1), - new RecipeInputOreDict("foilMica"), new RecipeInputOreDict("foilGold"), - new RecipeInputOreDict("foilSteel") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("highVoltageCapacitor") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputFluidContainer(FluidRegistry.getFluid("mineraloil"), 1), + new RecipeInputOreDict("foilMica"), new RecipeInputOreDict("foilCopper"), + new RecipeInputOreDict("foilSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("highVoltageCapacitor") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputFluidContainer(FluidRegistry.getFluid("mineraloil"), 1), + new RecipeInputOreDict("foilMica"), new RecipeInputOreDict("foilGold"), + new RecipeInputOreDict("foilSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("highVoltageCapacitor") }))); IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), IHLUtils.getThisModItemStack("handDrillBronze"), @@ -1339,7 +1210,7 @@ public class IHLMod implements IFuelHandler { IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("dustTin"), new RecipeInputItemStack(new ItemStack(Blocks.glass_pane), 16), - new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"),1), + new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"), 1), new RecipeInputFluidContainer(FluidRegistry.getFluid("turpentine"), 1), new RecipeInputItemStack(IHLUtils.getThisModItemStack("fabric")) }), Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("mirror", 16) }))); @@ -1389,36 +1260,6 @@ public class IHLMod implements IFuelHandler { IHLUtils.getInsulatedWire("Copper", 1, 15, "Rubber", 100), IHLUtils.getOreDictItemStack("plateSteel"), new ItemStack(Blocks.glass_pane) }), Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("spotlight") }))); - IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { - IHLUtils.getThisModItemStack("hammer"), IHLUtils.getThisModItemStack("tinSnipsSteel"), - IHLUtils.getThisModItemStack("drillSteelHardened"), IHLUtils.getThisModItemStack("handDrillBronze"), - IHLUtils.getThisModItemStack("tapM10x1SteelHardened"), - IHLUtils.getThisModItemStack("hackSawSteel") }), - Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("plateSteel", 8), - IHLUtils.getThisModItemStackWithSize("incisorSteelDiamondCoated", 8), - IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 16), - IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 8), - IHLUtils.getThisModItemStackWithSize("barD10Steel", 4), - IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"), - IHLUtils.getThisModItemStack("foilRubber") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("advancedShieldAssemblyUnitBlock") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); - IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), - IHLUtils.getThisModItemStack("hackSawSteel"), IHLUtils.getThisModItemStack("viseSteel"), - IHLUtils.getThisModItemStack("setOfFilesSteel") }), - Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("plateSteel", 2), - IHLUtils.getOreDictItemStack("foilSteel"), - IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 8), - IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 8), - IHLUtils.getThisModItemStackWithSize("barD10Steel", 16), - IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"), - IHLUtils.getThisModItemStack("extruderSetOfMoldedPartsSteel"), - IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 4), - IHLUtils.getThisModItemStack("turboCompressorSetOfMoldedPartsBronze"), - IHLUtils.getThisModItemStack("foilRubber") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hydrotransportPulpRegenerator") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList( new IRecipeInput[] { RecipeInputs.cutter, RecipeInputs.saw, RecipeInputs.vise, RecipeInputs.file }), Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("plateSteel", 2), @@ -1430,29 +1271,6 @@ public class IHLMod implements IFuelHandler { RecipeInputs.get("foilRubber") }), Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("paperMachine") }), Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); - IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( - Arrays.asList(new IRecipeInput[] { RecipeInputs.cutter, RecipeInputs.saw, RecipeInputs.hammer, - RecipeInputs.file }), - Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("plateSteel", 2), - new RecipeInputOreDict("foilSteel"), new RecipeInputItemStack(Ic2Items.elemotor), - RecipeInputs.get("boltM10x1Steel", 8), RecipeInputs.get("nutM10x1Steel", 8), - RecipeInputs.get("linerIronGraphiteGreased", 4), - RecipeInputs.get("turboCompressorSetOfMoldedPartsBronze", 2) }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("blowerBlock") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); - IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, - Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("dyeRed"), - new RecipeInputWire("Copper", 128, 15, "Rubber", 100, 10000) }), - Arrays.asList( - new ItemStack[] { IHLUtils.getThisModWireItemStackWithLength("EightPinDataCable", 16) }))); - IronWorkbenchTileEntity - .addRecipe(new IronWorkbenchRecipe(Arrays.asList(new IRecipeInput[] { RecipeInputs.cutter }), - Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("plateSteel", 2), - new RecipeInputOreDict("foilSteel"), new RecipeInputOreDict("foilMica"), - new RecipeInputOreDict("foilCopper"), - new RecipeInputWire("Copper", 8, 15, "Rubber", 100, 10000) }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("redstoneSignalConverter") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("dustIronOxide", 8), new RecipeInputOreDict("dustBauxite"), new RecipeInputOreDict("dustPotassiumOxide"), }), @@ -1567,35 +1385,33 @@ public class IHLMod implements IFuelHandler { Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 240, "Rubber", 100) }), Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 240) }))); - IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), - Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("plateGraphite", 2), - new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("highVoltageCapacitor", 3),3), - new RecipeInputFluidContainer(IHLFluid.IHLFluidType.MineralOil.fluid, 1), - new RecipeInputOreDict("dustSolderingAlloy"), new RecipeInputOreDict("foilMica"), - new RecipeInputWire(IHLUtils.getUninsulatedWire("Copper", 5, 15)), - new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("gu-81m", 4)), - new RecipeInputOreDict("foilCopper"), - new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("valveTube1C21P", 6)) }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("vacuumInductionMeltingFurnace") }), - Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); ItemStack detonator = IHLUtils.getItemStackWithTag("detonator", "detonator_delay", 5); detonator.stackSize = 16; IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("platePaper", 2), new RecipeInputItemStack(new ItemStack(Items.string)), new RecipeInputOreDict("dustGunpowder", 1), - new RecipeInputOreDict("dustPentaerythritolTetranitrate", 1), + new RecipeInputOreDictionaryList(new String[] {"dustPentaerythritolTetranitrate", "dustMercuryFulminate"}, 1), new RecipeInputOreDict("ingotTarPitch", 1) }), Arrays.asList(new ItemStack[] { detonator }), null)); IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, Arrays.asList( new IRecipeInput[] { new RecipeInputOreDict("platePaper", 2), - new RecipeInputOreDict("dustPentaerythritolTetranitrate", 8), + new RecipeInputOreDict("dustPentaerythritolTetranitrate", 4), + new RecipeInputOreDict("ingotTarPitch", 1), new RecipeInputDetonator(detonator) }), + Arrays.asList( + new ItemStack[] { IHLUtils.getItemStackWithTag("ihlExplosive", "explosionPower", 1500) }), + null)); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList( + new IRecipeInput[] { new RecipeInputOreDict("platePaper", 2), + new RecipeInputOreDict("dustWood", 4), + new RecipeInputFluidContainer(FluidRegistry.getFluid("nitroglycerin"), 1), new RecipeInputOreDict("ingotTarPitch", 1), new RecipeInputDetonator(detonator) }), Arrays.asList( new ItemStack[] { IHLUtils.getItemStackWithTag("ihlExplosive", "explosionPower", 1000) }), null)); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustSiliconDioxide", 2), new RecipeInputOreDict("dustCoal", 4), "dustCarborundum"); AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustQuicklime"), @@ -2090,6 +1906,28 @@ public class IHLMod implements IFuelHandler { new RecipeOutputItemStack[] { new RecipeOutputItemStack( IHLUtils.getOreDictItemStack("dustPentaerythritolTetranitrate"), 1f) }, 200, false)); + if(FluidRegistry.isFluidRegistered("bioethanol")){ + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("bioethanol", 450), + IHLUtils.getFluidStackWithSize("mercury", 144), + IHLUtils.getFluidStackWithSize("nitricacid", 300)}, + null), + new UniversalRecipeOutput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("acetaldehyde", 300) }, + new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustMercuryFulminate"),1f) }, + 200)); + } + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("glyceryl", 100), + IHLUtils.getFluidStackWithSize("nitricacid", 300)}, + null), + new UniversalRecipeOutput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("nitroglycerin", 400) }, + null, + 200)); Crucible.addRecipe("ingotSteel", IHLUtils.getFluidStackWithSize("molten.steel", 144)); Crucible.addRecipe("ingotBronze", IHLUtils.getFluidStackWithSize("molten.bronze", 144)); @@ -2178,14 +2016,11 @@ public class IHLMod implements IFuelHandler { if (Loader.isModLoaded("NotEnoughItems")) { NEIModContainer.plugins.add(new NEIIHLConfig()); } - IHLMod.config.checkLists(); IHLMod.proxy.initBlockRenderer(); IHLMod.log.info("IHL loaded."); } private void registerEntities() { - EntityRegistry.registerModEntity(CollectorEntity.class, "CollectorEntity", 0, this, 80, 3, true); - EntityRegistry.registerModEntity(CollectorHeavyEntity.class, "CollectorHeavyEntity", 1, this, 80, 3, true); EntityRegistry.registerModEntity(PowerCableNodeEntity.class, "PowerCableNodeEntity", 2, this, 80, 3, true); EntityRegistry.registerModEntity(NodeEntity.class, "NodeEntity", 3, this, 80, 3, true); EntityRegistry.registerModEntity(IHLEntityFallingPile.class, "IHLEntityFallingPile", 4, this, 80, 3, true); @@ -2218,21 +2053,6 @@ public class IHLMod implements IFuelHandler { @SuppressWarnings("deprecation") private void loadGT5Recipes() { - ItemStack advBattery = ItemList.Hull_MV.get(1L, new Object[] { null }); - ItemStack oreListIterator = GT_OreDictUnificator.get(OrePrefixes.cableGt08, Materials.Gold, 1L); - ItemStack sc = GT_OreDictUnificator.get(OrePrefixes.cableGt08, Materials.Silver, 1L); - ItemStack ec = GT_OreDictUnificator.get(OrePrefixes.cableGt08, Materials.Electrum, 1L); - ItemStack lp = GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Lazurite, 1L); - ItemStack sp = GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Steel, 1L); - ItemStack rotor_lv = ItemList.Rotor_LV.get(1L, new Object[] { null }); - ItemStack rotor_mv = ItemList.Rotor_MV.get(1L, new Object[] { null }); - ItemStack motor_lv = ItemList.Electric_Motor_LV.get(1L, new Object[] { null }); - ItemStack motor_mv = ItemList.Electric_Motor_MV.get(1L, new Object[] { null }); - ItemStack sensor_lv = ItemList.Sensor_LV.get(1L, new Object[] { null }); - ItemStack sensor_mv = ItemList.Sensor_MV.get(1L, new Object[] { null }); - ItemStack battery_lv_c = ItemList.Battery_RE_LV_Cadmium.get(1L, new Object[] { null }); - ItemStack battery_lv_l = ItemList.Battery_RE_LV_Lithium.get(1L, new Object[] { null }); - ItemStack battery_lv_s = ItemList.Battery_RE_LV_Sodium.get(1L, new Object[] { null }); ItemStack battery_mv_c = ItemList.Battery_RE_MV_Cadmium.get(1L, new Object[] { null }); ItemStack battery_mv_l = ItemList.Battery_RE_MV_Lithium.get(1L, new Object[] { null }); ItemStack battery_mv_s = ItemList.Battery_RE_MV_Sodium.get(1L, new Object[] { null }); @@ -2274,51 +2094,6 @@ public class IHLMod implements IFuelHandler { OrePrefixes.pipeSmall.get(Materials.TungstenSteel), 'P', pump_hv, 'B', energy_crystal }); } - if (config.enableTunnelingShield) { - gregtech.api.util.GT_ModHandler - .addCraftingRecipe(IHLUtils.getThisModItemStack("IHLShieldAssemblyUnitBlock"), - gregtech.api.util.GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { "RfR", "BwB", "PPP", 'R', OrePrefixes.stick.get(Materials.Steel), 'B', - OrePrefixes.bolt.get(Materials.Steel), 'P', - OrePrefixes.plate.get(Materials.Steel) }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(new ItemStack(driverBlock, 1), - new Object[] { " ", " H ", " M ", 'H', advBattery, 'M', motor_mv }); - } - - if (config.enableCollectors) { - gregtech.api.util.GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorHeavyItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", 'P', rotor_mv, 'S', sensor_mv, 'R', - OrePrefixes.stick.get(Materials.Aluminium), 'M', motor_mv, 'B', battery_mv_c }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorHeavyItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", 'P', rotor_mv, 'S', sensor_mv, 'R', - OrePrefixes.stick.get(Materials.Aluminium), 'M', motor_mv, 'B', battery_mv_l }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorHeavyItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", 'P', rotor_mv, 'S', sensor_mv, 'R', - OrePrefixes.stick.get(Materials.Aluminium), 'M', motor_mv, 'B', battery_mv_s }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", 'P', rotor_lv, 'S', sensor_lv, 'R', - OrePrefixes.stick.get(Materials.Steel), 'M', motor_lv, 'B', battery_lv_c }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", 'P', rotor_lv, 'S', sensor_lv, 'R', - OrePrefixes.stick.get(Materials.Steel), 'M', motor_lv, 'B', battery_lv_l }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", 'P', rotor_lv, 'S', sensor_lv, 'R', - OrePrefixes.stick.get(Materials.Steel), 'M', motor_lv, 'B', battery_lv_s }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(new ItemStack(chargerEjectorBlock, 1), - new Object[] { "PGP", "GCG", "GLG", 'P', lp, 'G', new ItemStack(Blocks.glass, 1), 'C', - oreListIterator, 'L', advBattery }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(new ItemStack(chargerEjectorBlock, 1), new Object[] { - "PGP", "GCG", "GLG", 'P', lp, 'G', new ItemStack(Blocks.glass, 1), 'C', sc, 'L', advBattery }); - gregtech.api.util.GT_ModHandler.addCraftingRecipe(new ItemStack(chargerEjectorBlock, 1), new Object[] { - "PGP", "GCG", "GLG", 'P', lp, 'G', new ItemStack(Blocks.glass, 1), 'C', ec, 'L', advBattery }); - } - - if (config.enableFan) { - gregtech.api.util.GT_ModHandler.addCraftingRecipe(new ItemStack(blowerBlock, 1), - new Object[] { "PIP", "RHR", "IMI", 'P', sp, 'I', new ItemStack(Blocks.iron_bars, 1), 'R', rotor_mv, - 'H', advBattery, 'M', motor_mv }); - } - if (config.enableFlexibleCablesCrafting) { gregtech.api.util.GT_ModHandler.addCraftingRecipe(IHLUtils.getThisModItemStack("ironWorkbench"), new Object[] { "PPS", "RRh", "RRd", 'P', OrePrefixes.plate.get(Materials.Iron), 'S', @@ -2411,29 +2186,46 @@ public class IHLMod implements IFuelHandler { IHLUtils.getThisModWireItemStackWithLength("pipeRubberWithSulfur", 16)); } + @SuppressWarnings("deprecation") private void loadGT6Recipes() { - ItemStack hull_mv = Ic2Items.advancedMachine; - ItemStack gc = OreDictManager.INSTANCE.getStack(OP.cableGt08, MT.Gold, 1); - ItemStack sc = OreDictManager.INSTANCE.getStack(OP.cableGt08, MT.Silver, 1); - ItemStack ec = OreDictManager.INSTANCE.getStack(OP.cableGt08, MT.Electrum, 1); - ItemStack lp = OreDictManager.INSTANCE.getStack(OP.plate, MT.Lazurite, 1); - ItemStack sp = OreDictManager.INSTANCE.getStack(OP.plate, MT.Steel, 1); - ItemStack rotor_lv = OreDictManager.INSTANCE.getStack(OP.rotor, MT.Iron, 1); - ItemStack rotor_mv = OreDictManager.INSTANCE.getStack(OP.rotor, MT.Aluminium, 1); - ItemStack motor_lv = IL.Electric_Motor_LV.get(1, (Object) null); - ItemStack motor_mv = IL.Electric_Motor_MV.get(1, (Object) null); - ItemStack sensor_lv = IL.Sensor_LV.get(1, (Object) null); - ItemStack sensor_mv = IL.Sensor_MV.get(1, (Object) null); - ItemStack battery_lv_c = IL.Battery_RE_LV_Cadmium.get(1, (Object) null); - ItemStack battery_lv_l = IL.Battery_RE_LV_Lithium.get(1, (Object) null); - ItemStack battery_lv_s = IL.Battery_RE_LV_Sodium.get(1, (Object) null); - ItemStack battery_mv_c = IL.Battery_RE_MV_Cadmium.get(1, (Object) null); - ItemStack battery_mv_l = IL.Battery_RE_MV_Lithium.get(1, (Object) null); - ItemStack battery_mv_s = IL.Battery_RE_MV_Sodium.get(1, (Object) null); + ItemStack battery_mv_c = IL.Battery_RE_MV_Cadmium.get(1); + ItemStack battery_mv_l = IL.Battery_RE_MV_Lithium.get(1); + ItemStack battery_mv_s = IL.Battery_RE_MV_Sodium.get(1); ItemStack energy_crystal = IC2Items.getItem("energyCrystal"); ItemStack pump = IL.Electric_Pump_MV.get(1, (Object) null); ItemStack pump_hv = IL.Electric_Pump_HV.get(1, (Object) null); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Invar_Full.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Invar_Used.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Plastic_Full.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Plastic_Used.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Platinum_Full.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Platinum_Used.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_MatchBox_Full.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_MatchBox_Used.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Matches.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Fire_Starter.get(1)); + + gregapi.util.UT.Crafting.shaped(IHLUtils.getThisModItemStack(MachineBaseBlock.MachineType.ChemicalReactor.unlocalizedName), + new Object[] { " R ", "PVP", " Mw", + Character.valueOf('R'), gregapi.data.OP.stick.dat(gregapi.data.MT.StainlessSteel), + Character.valueOf('V'), gregapi.data.OP.rotor.dat(gregapi.data.MT.StainlessSteel), + Character.valueOf('P'), gregapi.data.OP.plateCurved.dat(gregapi.data.MT.StainlessSteel), + Character.valueOf('M'), gregapi.data.OP.casingMachine.dat(gregapi.data.MT.Steel)}); + + gregapi.util.UT.Crafting.shaped(IHLUtils.getThisModItemStack(MachineBaseBlock.MachineType.CryogenicDistiller.unlocalizedName), + new Object[] { " R ", "P P", " Mw", + Character.valueOf('R'), gregapi.data.OP.pipeTiny.dat(gregapi.data.MT.Copper), + Character.valueOf('P'), gregapi.data.OP.plateCurved.dat(gregapi.data.MT.Copper), + Character.valueOf('M'), gregapi.data.OP.casingMachine.dat(gregapi.data.MT.Steel)}); + + gregapi.util.UT.Crafting.shaped(IHLUtils.getThisModItemStack(MachineBaseBlock.MachineType.FluidizedBedReactor.unlocalizedName), + new Object[] { " ", "RPR", "VMw", + Character.valueOf('R'), gregapi.data.OP.pipeTiny.dat(gregapi.data.MT.Titanium), + Character.valueOf('P'), gregapi.data.OP.pipeHuge.dat(gregapi.data.MT.Titanium), + Character.valueOf('V'), gregapi.data.OP.rotor.dat(gregapi.data.MT.Titanium), + Character.valueOf('M'), gregapi.data.OP.casingMachine.dat(gregapi.data.MT.Steel)}); + IRecipeInput[] dsmInputs1 = new IRecipeInput[3]; ItemStack gregtechfile = IHLUtils.getOtherModItemStackWithDamage("gregtech", "gt.metatool.01", 18, 1); dsmInputs1[0] = new RecipeInputItemStack(gregtechfile); @@ -2451,83 +2243,27 @@ public class IHLMod implements IFuelHandler { } if (IHLMod.config.enableHandpump) { - GT_ModHandler.addCraftingRecipe(((IHLHandPump) ic2_handpump).getItemStack(0), + gregapi.util.UT.Crafting.shaped(((IHLHandPump) ic2_handpump).getItemStack(0), new Object[] { "T ", " P ", " B", Character.valueOf('T'), OP.pipeSmall.get(MT.Steel), Character.valueOf('P'), pump, Character.valueOf('B'), battery_mv_c }); - GT_ModHandler.addCraftingRecipe(((IHLHandPump) ic2_handpump).getItemStack(0), + gregapi.util.UT.Crafting.shaped(((IHLHandPump) ic2_handpump).getItemStack(0), new Object[] { "T ", " P ", " B", Character.valueOf('T'), OP.pipeSmall.get(MT.Steel), Character.valueOf('P'), pump, Character.valueOf('B'), battery_mv_l }); - GT_ModHandler.addCraftingRecipe(((IHLHandPump) ic2_handpump).getItemStack(0), + gregapi.util.UT.Crafting.shaped(((IHLHandPump) ic2_handpump).getItemStack(0), new Object[] { "T ", " P ", " B", Character.valueOf('T'), OP.pipeSmall.get(MT.Steel), Character.valueOf('P'), pump, Character.valueOf('B'), battery_mv_s }); - GT_ModHandler.addCraftingRecipe(((AdvancedHandPump) ic2_advanced_handpump).getItemStack(0), + gregapi.util.UT.Crafting.shaped(((AdvancedHandPump) ic2_advanced_handpump).getItemStack(0), new Object[] { "T ", " P ", " B", Character.valueOf('T'), OP.pipeSmall.get(MT.TungstenSteel), Character.valueOf('P'), pump_hv, Character.valueOf('B'), energy_crystal }); } - if (IHLMod.config.enableTunnelingShield) { - GT_ModHandler.addCraftingRecipe(IHLUtils.getThisModItemStack("IHLShieldAssemblyUnitBlock"), - GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { "RfR", "BwB", "PPP", Character.valueOf('R'), OP.stick.get(MT.Steel), - Character.valueOf('B'), OP.bolt.get(MT.Steel), Character.valueOf('P'), - OP.plate.get(MT.Steel) }); - GT_ModHandler.addCraftingRecipe(new ItemStack(driverBlock, 1), - new Object[] { " ", " H ", " M ", Character.valueOf('H'), IC2Items.getItem("machine"), - Character.valueOf('M'), IC2Items.getItem("elemotor") }); - } - if (IHLMod.config.enableCollectors) { - GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorHeavyItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", Character.valueOf('P'), rotor_mv, Character.valueOf('S'), - sensor_mv, Character.valueOf('R'), OP.stick.get(MT.Aluminium), Character.valueOf('M'), - motor_mv, Character.valueOf('B'), battery_mv_c }); - GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorHeavyItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", Character.valueOf('P'), rotor_mv, Character.valueOf('S'), - sensor_mv, Character.valueOf('R'), OP.stick.get(MT.Aluminium), Character.valueOf('M'), - motor_mv, Character.valueOf('B'), battery_mv_l }); - GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorHeavyItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", Character.valueOf('P'), rotor_mv, Character.valueOf('S'), - sensor_mv, Character.valueOf('R'), OP.stick.get(MT.Aluminium), Character.valueOf('M'), - motor_mv, Character.valueOf('B'), battery_mv_s }); - - GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", Character.valueOf('P'), rotor_lv, Character.valueOf('S'), - sensor_lv, Character.valueOf('R'), OP.stick.get(MT.Steel), Character.valueOf('M'), motor_lv, - Character.valueOf('B'), battery_lv_c }); - GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", Character.valueOf('P'), rotor_lv, Character.valueOf('S'), - sensor_lv, Character.valueOf('R'), OP.stick.get(MT.Steel), Character.valueOf('M'), motor_lv, - Character.valueOf('B'), battery_lv_l }); - GT_ModHandler.addCraftingRecipe(((CollectorItem) collectorItem).getItemStack(0), - new Object[] { "PSP", "RMR", "PBP", Character.valueOf('P'), rotor_lv, Character.valueOf('S'), - sensor_lv, Character.valueOf('R'), OP.stick.get(MT.Steel), Character.valueOf('M'), motor_lv, - Character.valueOf('B'), battery_lv_s }); - - GT_ModHandler.addCraftingRecipe(new ItemStack(IHLMod.chargerEjectorBlock, 1), - new Object[] { "PGP", "GCG", "GLG", Character.valueOf('P'), lp, Character.valueOf('G'), - new ItemStack(Blocks.glass, 1), Character.valueOf('C'), gc, Character.valueOf('L'), - hull_mv }); - GT_ModHandler.addCraftingRecipe(new ItemStack(IHLMod.chargerEjectorBlock, 1), - new Object[] { "PGP", "GCG", "GLG", Character.valueOf('P'), lp, Character.valueOf('G'), - new ItemStack(Blocks.glass, 1), Character.valueOf('C'), sc, Character.valueOf('L'), - hull_mv }); - GT_ModHandler.addCraftingRecipe(new ItemStack(IHLMod.chargerEjectorBlock, 1), - new Object[] { "PGP", "GCG", "GLG", Character.valueOf('P'), lp, Character.valueOf('G'), - new ItemStack(Blocks.glass, 1), Character.valueOf('C'), ec, Character.valueOf('L'), - hull_mv }); - } - if (IHLMod.config.enableFan) { - GT_ModHandler.addCraftingRecipe(new ItemStack(blowerBlock, 1), - new Object[] { "PIP", "RHR", "IMI", Character.valueOf('P'), sp, Character.valueOf('I'), - new ItemStack(Blocks.iron_bars, 1), Character.valueOf('R'), rotor_mv, - Character.valueOf('H'), hull_mv, Character.valueOf('M'), motor_mv }); - } if (IHLMod.config.enableFlexibleCablesCrafting) { - GT_ModHandler.addCraftingRecipe(IHLUtils.getThisModItemStack("ironWorkbench"), + gregapi.util.UT.Crafting.shaped(IHLUtils.getThisModItemStack("ironWorkbench"), new Object[] { "PPS", "RRh", "RRd", Character.valueOf('P'), OP.plate.get(MT.Iron), Character.valueOf('S'), OP.screw.get(MT.Iron), Character.valueOf('R'), OP.stick.get(MT.Iron) }); - GT_ModHandler.addCraftingRecipe(IHLUtils.getThisModItemStack("setOfDies1_5sqmm"), + gregapi.util.UT.Crafting.shaped(IHLUtils.getThisModItemStack("setOfDies1_5sqmm"), new Object[] { " ", "fPs", " ", Character.valueOf('P'), OP.plate.get(MT.Steel) }); - GT_ModHandler.addCraftingRecipe(IHLUtils.getItemStackWithTag("setOfDies1_5sqmm", "transverseSection", 240), + gregapi.util.UT.Crafting.shaped(IHLUtils.getItemStackWithTag("setOfDies1_5sqmm", "transverseSection", 240), new Object[] { " f ", " P ", " s ", Character.valueOf('P'), OP.plate.get(MT.Steel) }); } if (pfaalimestone != null) { @@ -2614,6 +2350,7 @@ public class IHLMod implements IFuelHandler { new FluidStack(FluidRegistry.getFluid("glue"), 240), new FluidStack(FluidRegistry.getFluid("water"), 100) }, 64, 32, 0); + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("dustRubber", 5), IHLUtils.getOreDictItemStackWithSize("dustTinySulfur", 1), IHLUtils.getFluidStackWithSize("molten.rubber", 144 * 5)); @@ -2640,21 +2377,6 @@ public class IHLMod implements IFuelHandler { crystal.setItemDamage(OreDictionary.WILDCARD_VALUE); advBattery.setItemDamage(OreDictionary.WILDCARD_VALUE); chargedReBattery.setItemDamage(OreDictionary.WILDCARD_VALUE); - if (IHLMod.config.enableTunnelingShield) { - Recipes.advRecipes.addRecipe(new ItemStack(driverBlock, 1), - new Object[] { " ", " E ", " M ", Character.valueOf('E'), IC2Items.getItem("elemotor"), - Character.valueOf('M'), IC2Items.getItem("machine") }); - Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("IHLShieldAssemblyUnitBlock"), - new Object[] { "OOO", "PPP", " ", Character.valueOf('O'), IC2Items.getItem("obsidianDust"), - Character.valueOf('P'), IC2Items.getItem("plateiron") }); - } - if (IHLMod.config.enableFan) { - Recipes.advRecipes.addRecipe(new ItemStack(blowerBlock, 1), - new Object[] { "PBP", "IEI", "PMP", Character.valueOf('P'), IC2Items.getItem("plateiron"), - Character.valueOf('B'), new ItemStack(Blocks.iron_bars, 1), Character.valueOf('I'), - new ItemStack(Items.iron_ingot, 1), Character.valueOf('E'), IC2Items.getItem("elemotor"), - Character.valueOf('M'), IC2Items.getItem("machine") }); - } if (IHLMod.config.enableRubberTreeSack) { Recipes.advRecipes.addRecipe(new ItemStack(electricEvaporatorBlock, 1), new Object[] { "CCC", "CCC", " F ", Character.valueOf('C'), IC2Items.getItem("platecopper"), diff --git a/ihl/IHLModConfig.java b/ihl/IHLModConfig.java index f62ca7d..99739c9 100644 --- a/ihl/IHLModConfig.java +++ b/ihl/IHLModConfig.java @@ -1,11 +1,9 @@ package ihl; -import ic2.api.item.IC2Items; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputFluidContainer; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeInputOreDict; -import ic2.core.util.StackUtil; import ihl.flexible_cable.IronWorkbenchTileEntity; import ihl.recipes.IronWorkbenchRecipe; import ihl.recipes.RecipeInputDie; @@ -30,10 +28,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map.Entry; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @@ -41,7 +37,7 @@ import net.minecraft.nbt.NBTTagCompound; public class IHLModConfig { - public int explosionVectorSizeBits=8; + public int explosionVectorSizeBits=7; public int handpumpTier=1; public int handpumpMaxCharge=30000; @@ -51,33 +47,12 @@ public class IHLModConfig public int advancedHandpumpMaxCharge=1000000; public int advancedHandpumpOperationEUCost=10000; - public int harvesterTier=1; - public int harvesterMaxEnergyStorage=110; - public int harvesterIdleEUCost=1; - public int harvesterOperationEUCost=100; - - public int blowerTier=1; - public int blowerMaxEnergyStorage=100; - public int blowerEnergyConsumePerTick=5; - public int tditTier=4; public int tditMaxEnergyStorage=12000; public int tditEnergyConsumePerStack=12000; - public int ts02DefaultTier=1; - public int ts02DefaultMaxEnergyStorage=1000; - public int ts02DefaultSpeed=400; - public int ts02DefaultOperationEUCost=5; - public String[] ts02BlockBlackListString; - public String[] ts02BlockWhiteListString; - - public boolean enableExtendedLiquidPhysics=true; public boolean enableHandpump=true; - public boolean enableFan=true; - public boolean enableTunnelingShield=true; - public boolean enableHarvester=true; public boolean enableRubberTreeSack=true; - public boolean enableCollectors=true; public boolean enableWailers=true; public boolean enableTDIT=true; @@ -104,7 +79,6 @@ public class IHLModConfig public int mirrorReflectionUpdateSpeed=128; public String preventMachineBlockRegistrationName="null"; public boolean skipRecipeLoad=false; - public boolean giveIHLManualOnPlayerWakeUpEvent=true; public IHLModConfig(FMLPreInitializationEvent evt) throws IOException { @@ -112,17 +86,10 @@ public class IHLModConfig config.load(); skipRecipeLoad = config.get(Configuration.CATEGORY_GENERAL, "skipRecipeLoad", skipRecipeLoad).getBoolean(skipRecipeLoad); preventMachineBlockRegistrationName = config.get(Configuration.CATEGORY_GENERAL, "preventMachineBlockRegistrationName", preventMachineBlockRegistrationName).getString(); - String[] bl = {"bedrock", "reinforcedStone", "reinforcedGlass", "reinforcedDoorBlock" , "personalSafe", "end_portal_frame"}; - String[] wl = {"brown_mushroom_block", "cake", "fire", "lava", "water", "flowing_lava", "flowing_water", "redstone_torch", "redstone_wire", "web", "torch"}; - enableExtendedLiquidPhysics = config.get(Configuration.CATEGORY_GENERAL, "enableExtendedLiquidPhysics", enableExtendedLiquidPhysics).getBoolean(enableExtendedLiquidPhysics); enableHandpump = config.get(Configuration.CATEGORY_GENERAL, "enableHandpump", enableHandpump).getBoolean(enableHandpump); - enableFan = config.get(Configuration.CATEGORY_GENERAL, "enableFan", enableFan).getBoolean(enableFan); - enableTunnelingShield = config.get(Configuration.CATEGORY_GENERAL, "enableTunnelingShield", enableTunnelingShield).getBoolean(enableTunnelingShield); enableRubberTreeSack = config.get(Configuration.CATEGORY_GENERAL, "enableRubberTreeSack", enableRubberTreeSack).getBoolean(enableRubberTreeSack); - enableCollectors = config.get(Configuration.CATEGORY_GENERAL, "enableCollectors", enableCollectors).getBoolean(enableCollectors); enableWailers = config.get(Configuration.CATEGORY_GENERAL, "enableWailers", enableWailers).getBoolean(enableWailers); enableTDIT = config.get(Configuration.CATEGORY_GENERAL, "enableTDIT", enableTDIT).getBoolean(enableTDIT); - giveIHLManualOnPlayerWakeUpEvent = config.get(Configuration.CATEGORY_GENERAL, "giveIHLManualOnPlayerWakeUpEvent", giveIHLManualOnPlayerWakeUpEvent).getBoolean(giveIHLManualOnPlayerWakeUpEvent); generateApatiteOre = config.get(Configuration.CATEGORY_GENERAL, "generateApatiteOre", generateApatiteOre).getBoolean(generateApatiteOre); generateSaltpeterOre = config.get(Configuration.CATEGORY_GENERAL, "generateSaltpeterOre", generateSaltpeterOre).getBoolean(generateSaltpeterOre); @@ -147,23 +114,10 @@ public class IHLModConfig advancedHandpumpTier = config.get(Configuration.CATEGORY_GENERAL, "advancedHandpumpTier", advancedHandpumpTier).getInt(); advancedHandpumpMaxCharge = config.get(Configuration.CATEGORY_GENERAL, "advancedHandpumpMaxCharge", advancedHandpumpMaxCharge).getInt(); advancedHandpumpOperationEUCost = config.get(Configuration.CATEGORY_GENERAL, "advancedHandpumpOperationEUCost", advancedHandpumpOperationEUCost).getInt(); - blowerTier = config.get(Configuration.CATEGORY_GENERAL, "blowerTier", blowerTier).getInt(); - blowerMaxEnergyStorage = config.get(Configuration.CATEGORY_GENERAL, "blowerMaxEnergyStorage", blowerMaxEnergyStorage).getInt(); - blowerEnergyConsumePerTick = config.get(Configuration.CATEGORY_GENERAL, "blowerEnergyConsumePerTick", blowerEnergyConsumePerTick).getInt(); tditTier = config.get(Configuration.CATEGORY_GENERAL, "tditTier", tditTier).getInt(); tditMaxEnergyStorage = config.get(Configuration.CATEGORY_GENERAL, "tditMaxEnergyStorage", tditMaxEnergyStorage).getInt(); tditEnergyConsumePerStack = config.get(Configuration.CATEGORY_GENERAL, "tditEnergyConsumePerStack", tditEnergyConsumePerStack).getInt(); - - ts02DefaultTier = config.get(Configuration.CATEGORY_GENERAL, "ts02DefaultTier", ts02DefaultTier).getInt(); - ts02DefaultMaxEnergyStorage = config.get(Configuration.CATEGORY_GENERAL, "ts02DefaultMaxEnergyStorage", ts02DefaultMaxEnergyStorage).getInt(); - ts02DefaultSpeed = config.get(Configuration.CATEGORY_GENERAL, "ts02DefaultSpeed", ts02DefaultSpeed).getInt(); - ts02DefaultOperationEUCost = config.get(Configuration.CATEGORY_GENERAL, "ts02DefaultOperationEUCost", ts02DefaultOperationEUCost).getInt(); - - harvesterTier = config.get(Configuration.CATEGORY_GENERAL, "harvesterTier", harvesterTier).getInt(); - harvesterMaxEnergyStorage = config.get(Configuration.CATEGORY_GENERAL, "harvesterMaxEnergyStorage", harvesterMaxEnergyStorage).getInt(); - harvesterIdleEUCost = config.get(Configuration.CATEGORY_GENERAL, "harvesterIdleEUCost", harvesterIdleEUCost).getInt(); - harvesterOperationEUCost = config.get(Configuration.CATEGORY_GENERAL, "harvesterOperationEUCost", harvesterOperationEUCost).getInt(); enableFlexibleCablesGridPowerLossCalculations = config.get(Configuration.CATEGORY_GENERAL, "enableFlexibleCablesGridPowerLossCalculations", enableFlexibleCablesGridPowerLossCalculations).getBoolean(enableFlexibleCablesGridPowerLossCalculations); additionalPowerLossesAtFrequencyGenerator = config.get(Configuration.CATEGORY_GENERAL, "additionalPowerLossesAtFrequencyGenerator", additionalPowerLossesAtFrequencyGenerator).getDouble(additionalPowerLossesAtFrequencyGenerator); @@ -173,26 +127,6 @@ public class IHLModConfig explosionVectorSizeBits = config.get(Configuration.CATEGORY_GENERAL, "explosionVectorSizeBits", explosionVectorSizeBits).getInt(); - Property blp = config.get(Configuration.CATEGORY_GENERAL, "ts02BlockBlackList", bl); - Property wlp = config.get(Configuration.CATEGORY_GENERAL, "ts02BlockWhiteList", wl); - if(blp.isList()) - { - ts02BlockBlackListString = config.get(Configuration.CATEGORY_GENERAL, "ts02BlockBlackList", bl).getStringList(); - } - else - { - blp.set(bl); - ts02BlockBlackListString=bl; - } - if(wlp.isList()) - { - ts02BlockWhiteListString = config.get(Configuration.CATEGORY_GENERAL, "ts02BlockWhiteList", wl).getStringList(); - } - else - { - wlp.set(wl); - ts02BlockWhiteListString=wl; - } config.save(); } @@ -599,37 +533,6 @@ public class IHLModConfig loadRecipeConfig(is, false); } - public void checkLists() - { - for(int i6=0;i6 { - - protected ChargerEjectorTileEntity tileEntity; - public int lastStorage = -1; - private final static int height=166; - - public ChargerEjectorContainer(EntityPlayer entityPlayer, ChargerEjectorTileEntity tileEntity1){ - super(tileEntity1); - this.tileEntity = tileEntity1; - int col; - - for (col = 0; col < 3; ++col) - { - for (int col1 = 0; col1 < 9; ++col1) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); - } - } - - for (col = 0; col < 9; ++col) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); - } - - this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 26, 35)); - - for(col=0;col<=2;col++) - { - for(int row=0;row<=2;row++) - { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.chargeSlot, col+row*3, 66+26*col, 11+24*row)); - } - } - } - - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)this.crafters.get(i); - - if (this.tileEntity.getStored() != this.lastStorage) - { - icrafting.sendProgressBarUpdate(this, 0, (this.tileEntity.getStored()>>15) & Short.MAX_VALUE); - icrafting.sendProgressBarUpdate(this, 1, (short)(this.tileEntity.getStored() & Short.MAX_VALUE)); - } - } - - this.lastStorage = this.tileEntity.getStored(); - } - - @Override - public void updateProgressBar(int index, int value) - { - super.updateProgressBar(index, value); - - switch (index) - { - case 0: - this.tileEntity.setStored((value<<15)); - break; - case 1: - this.tileEntity.setStored(this.tileEntity.getStored()+value); - break; - } - } - - @Override - public boolean canInteractWith(EntityPlayer var1) { - return tileEntity.isUseableByPlayer(var1); - } - - @Override - public void putStackInSlot(int par1, ItemStack par2ItemStack) - { - if(par1<44) - { - this.getSlot(par1).putStack(par2ItemStack); - } - } -} diff --git a/ihl/collector/ChargerEjectorGui.java b/ihl/collector/ChargerEjectorGui.java deleted file mode 100644 index 1836dc9..0000000 --- a/ihl/collector/ChargerEjectorGui.java +++ /dev/null @@ -1,128 +0,0 @@ -package ihl.collector; - -import cpw.mods.fml.relauncher.Side; - -import cpw.mods.fml.relauncher.SideOnly; -import ic2.core.IC2; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; -import ic2.core.util.GuiTooltipHelper; - -@SideOnly(Side.CLIENT) -public class ChargerEjectorGui extends GuiContainer { - private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIChargerEjector.png"); - private ChargerEjectorContainer container; - private String title = StatCollector.translateToLocal("ihl.gui.charger_ejector"); - private GuiMultiTextureButton button1; - private GuiMultiTextureButton button2; - private GuiMultiTextureButton button3; - private GuiMultiTextureButton button4; - private int timer=10; - - public ChargerEjectorGui (ChargerEjectorContainer container1) { - //the container is instanciated and passed to the superclass for handling - super(container1); - this.container=container1; - } - - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - button1=new GuiMultiTextureButton(0, x+138, y+8, 16, 20, background,183,0,216,0); - button1.isActive=this.container.tileEntity.autoEject; - button2=new GuiMultiTextureButton(1, x+155, y+8, 16, 20, background,200,0,233,0); - button2.isActive=!this.container.tileEntity.autoEject; - button3=new GuiMultiTextureButton(2, x+138, y+29, 16, 20, background,183,21,216,21); - button4=new GuiMultiTextureButton(3, x+155, y+29, 16, 20, background,200,21,233,21); - this.buttonList.add(button1); - this.buttonList.add(button2); - this.buttonList.add(button3); - this.buttonList.add(button4); - } - - @Override - public void actionPerformed(GuiButton button) - { - super.actionPerformed(button); - IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, button.id); - if (button.id == 2) - { - button3.isActive=true; - timer=10; - } - if (button.id == 3) - { - button4.isActive=true; - timer=10; - } - - } - - @Override - protected void drawGuiContainerForegroundLayer(int param1, int param2) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - fontRendererObj.drawString(title, 8, 8, 6171880); - int e = Math.min(this.container.tileEntity.getStored(), this.container.tileEntity.maxStorage)/1000; - String eStr = String.valueOf(e); - int w = this.fontRendererObj.getStringWidth(eStr); - this.fontRendererObj.drawString(eStr + "kEU", 40-w, 62, 4210752); - this.fontRendererObj.drawString("/" + this.container.tileEntity.maxStorage/1000 + "kEU", 12, 72, 4210752); - String tooltip1 = StatCollector.translateToLocal("ihl.gui.charger_ejector_auto_eject"); - String tooltip2 = StatCollector.translateToLocal("ihl.gui.charger_ejector_do_not_auto_eject"); - String tooltip3 = StatCollector.translateToLocal("ihl.gui.charger_ejector_call_collectors"); - String tooltip4 = StatCollector.translateToLocal("ihl.gui.charger_ejector_erase_memory"); - GuiTooltipHelper.drawAreaTooltip(param1-90, param2-32, tooltip1, x+46, y-24, x+62, y-4); - GuiTooltipHelper.drawAreaTooltip(param1-90, param2-32, tooltip2, x+63, y-24, x+79, y-4); - GuiTooltipHelper.drawAreaTooltip(param1-90, param2-32, tooltip3, x+46, y-2, x+62, y+18); - GuiTooltipHelper.drawAreaTooltip(param1-90, param2-32, tooltip4, x+63, y-2, x+79, y+18); - //GuiTooltiphelper.drawAreaTooltip(param1-90, param2-32, tooltip1, x+120, 16, 132, 34); - //GuiTooltiphelper.drawAreaTooltip(param1-90, param2-32, tooltip2, x+137, 16, 149, 34); - //GuiTooltiphelper.drawAreaTooltip(param1-90, param2-32, tooltip3, x+120, 37, 132, 55); - //GuiTooltiphelper.drawAreaTooltip(param1-90, param2-32, tooltip4, 137, 37, 149, 55); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, - int par3) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - button1.isActive=this.container.tileEntity.autoEject; - button2.isActive=!this.container.tileEntity.autoEject; - if(timer>0) - { - timer--; - } - if(timer==1) - { - button3.isActive=false; - button4.isActive=false; - } - //charge - if (this.container.tileEntity.getStored() > 0) - { - int chargeLevel=Math.min(Math.round(this.container.tileEntity.getStored()*23.0F/this.container.tileEntity.maxStorage),23); - this.drawTexturedModalRect(x+12, y+32+23-chargeLevel, xSize, 23-chargeLevel, 7, chargeLevel); - } - - } - - @Override - public void onGuiClosed() - { - super.onGuiClosed(); - this.container.tileEntity.isGuiScreenOpened=false; - } -} \ No newline at end of file diff --git a/ihl/collector/ChargerEjectorModel.java b/ihl/collector/ChargerEjectorModel.java deleted file mode 100644 index 5177fee..0000000 --- a/ihl/collector/ChargerEjectorModel.java +++ /dev/null @@ -1,150 +0,0 @@ -package ihl.collector; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; - -public class ChargerEjectorModel extends ModelBase { - //fields - ModelRenderer Base; - ModelRenderer ItemPieces; - ModelRenderer LightOnA; - ModelRenderer LightOnB; - ModelRenderer LightOnC; - ModelRenderer LightOffA; - ModelRenderer LightOffB; - ModelRenderer LightOffC; - - public ChargerEjectorModel() - { - textureWidth = 64; - textureHeight = 64; - setTextureOffset("Base.Shape1", 0, 0); - setTextureOffset("Base.Shape2", 0, 0); - setTextureOffset("Base.Shape3", 44, 17); - setTextureOffset("Base.Shape4", 28, 17); - setTextureOffset("Base.Shape6", 0, 0); - setTextureOffset("Base.Shape15", 0, 0); - setTextureOffset("Base.Shape16", 0, 0); - setTextureOffset("Base.Shape17", 0, 0); - setTextureOffset("Base.Shape18", 0, 0); - setTextureOffset("Base.Shape19", 0, 0); - setTextureOffset("Base.Shape20", 0, 0); - setTextureOffset("Base.Shape21", 0, 0); - setTextureOffset("Base.Shape22", 0, 0); - setTextureOffset("Base.Shape23", 0, 0); - setTextureOffset("Base.Shape24", 0, 0); - setTextureOffset("Base.Shape25", 0, 0); - setTextureOffset("Base.Shape26", 0, 0); - setTextureOffset("Base.Shape27", 0, 0); - setTextureOffset("Base.Shape28", 0, 0); - setTextureOffset("Base.Shape29", 0, 0); - setTextureOffset("Base.Shape30", 0, 0); - setTextureOffset("Base.Shape31", 0, 0); - setTextureOffset("Base.Shape32", 0, 0); - setTextureOffset("Base.Shape33", 0, 0); - setTextureOffset("Base.Shape34", 0, 0); - setTextureOffset("Base.Shape35", 0, 0); - setTextureOffset("Base.Shape36", 0, 0); - - setTextureOffset("ItemPieces.Shape37", 0, 32); - setTextureOffset("ItemPieces.Shape38", 0, 32); - setTextureOffset("ItemPieces.Shape39", 0, 32); - - setTextureOffset("LightOnA.Shape7", 0, 17); - setTextureOffset("LightOnA.Shape5", 0, 24); - setTextureOffset("LightOnA.Shape8", 14, 19); - setTextureOffset("LightOnA.Shape9", 14, 17); - setTextureOffset("LightOnB.Shape10", 14, 21); - setTextureOffset("LightOnB.Shape11", 14, 23); - setTextureOffset("LightOnB.Shape12", 14, 25); - setTextureOffset("LightOnB.Shape13", 14, 28); - setTextureOffset("LightOnC.Shape14", 20, 25); - - setTextureOffset("LightOffA.ShapeA7", 0, 17+14); - setTextureOffset("LightOffA.ShapeA5", 0, 24+14); - setTextureOffset("LightOffA.ShapeA8", 14, 19+14); - setTextureOffset("LightOffA.ShapeA9", 14, 17+14); - setTextureOffset("LightOffB.ShapeA10", 14, 21+14); - setTextureOffset("LightOffB.ShapeA11", 14, 23+14); - setTextureOffset("LightOffB.ShapeA12", 14, 25+14); - setTextureOffset("LightOffB.ShapeA13", 14, 28+14); - setTextureOffset("LightOffC.ShapeA14", 20, 25+14); - - Base = new ModelRenderer(this, "Base"); - Base.setRotationPoint(0F, 0F, 0F); - Base.mirror = true; - Base.addBox("Shape1", -8F, 23F, -8F, 16, 1, 16); - Base.addBox("Shape2", -8F, 11F, -8F, 16, 1, 16); - Base.addBox("Shape3", -1F, 0F, -1F, 2, 10, 2); - Base.addBox("Shape4", -2F, 12F, -2F, 4, 10, 4); - Base.addBox("Shape6", -4F, -1F, -4F, 8, 1, 8); - Base.addBox("Shape15", -1F, 22F, -8F, 2, 1, 16); - Base.addBox("Shape16", 7F, 22F, -8F, 1, 1, 16); - Base.addBox("Shape17", -8F, 22F, -8F, 1, 1, 16); - Base.addBox("Shape18", 2F, 22F, -1F, 5, 1, 2); - Base.addBox("Shape19", -7F, 22F, -1F, 5, 1, 2); - Base.addBox("Shape20", 1F, 22F, 7F, 6, 1, 1); - Base.addBox("Shape21", -7F, 22F, 7F, 6, 1, 1); - Base.addBox("Shape22", 1F, 22F, -8F, 6, 1, 1); - Base.addBox("Shape23", -7F, 22F, -8F, 6, 1, 1); - Base.addBox("Shape24", -8F, 10F, -1F, 16, 1, 2); - Base.addBox("Shape25", -8F, 10F, -8F, 16, 1, 1); - Base.addBox("Shape26", -8F, 10F, 7F, 16, 1, 1); - Base.addBox("Shape27", -1F, 10F, 1F, 2, 1, 6); - Base.addBox("Shape28", -1F, 10F, -7F, 2, 1, 6); - Base.addBox("Shape29", -8F, 10F, -7F, 1, 1, 6); - Base.addBox("Shape30", -8F, 10F, 1F, 1, 1, 6); - Base.addBox("Shape31", 7F, 10F, 1F, 1, 1, 6); - Base.addBox("Shape32", 7F, 10F, -7F, 1, 1, 6); - Base.addBox("Shape33", 3F, -2F, -4F, 1, 1, 8); - Base.addBox("Shape34", -4F, -2F, -4F, 1, 1, 8); - Base.addBox("Shape35", -3F, -2F, -4F, 6, 1, 1); - Base.addBox("Shape36", -3F, -2F, 3F, 6, 1, 1); - - ItemPieces = new ModelRenderer(this, "ItemPieces"); - ItemPieces.setRotationPoint(0F, 0F, 0F); - ItemPieces.mirror = true; - ItemPieces.addBox("Shape37", -3F, -2F, -3F, 6, 1, 6); - ItemPieces.addBox("Shape38", -7F, 10.1F, -7F, 14, 1, 14); - ItemPieces.addBox("Shape39", -7F, 22.1F, -7F, 14, 1, 14); - - LightOnA = new ModelRenderer(this, "LightOnA"); - LightOnA.setRotationPoint(0F, 0F, 0F); - LightOnA.mirror = true; - LightOnA.addBox("Shape7", 6F, 22F, 1F, 1, 1, 6); - LightOnA.addBox("Shape5", 1F, 22F, 1F, 1, 1, 6); - LightOnA.addBox("Shape8", 2F, 22F, 1F, 4, 1, 1); - LightOnA.addBox("Shape9", 2F, 22F, 6F, 4, 1, 1); - LightOnB = new ModelRenderer(this, "LightOnB"); - LightOnB.setRotationPoint(0F, 0F, 0F); - LightOnB.mirror = true; - LightOnB.addBox("Shape10", 2F, 22F, 2F, 4, 1, 1); - LightOnB.addBox("Shape11", 2F, 22F, 5F, 4, 1, 1); - LightOnB.addBox("Shape12", 2F, 22F, 3F, 1, 1, 2); - LightOnB.addBox("Shape13", 5F, 22F, 3F, 1, 1, 2); - LightOnC = new ModelRenderer(this, "LightOnC"); - LightOnC.setRotationPoint(0F, 0F, 0F); - LightOnC.mirror = true; - LightOnC.addBox("Shape14", 3F, 22F, 3F, 2, 1, 2); - - LightOffA = new ModelRenderer(this, "LightOffA"); - LightOffA.setRotationPoint(0F, 0F, 0F); - LightOffA.mirror = true; - LightOffA.addBox("ShapeA7", 6F, 22F, 1F, 1, 1, 6); - LightOffA.addBox("ShapeA5", 1F, 22F, 1F, 1, 1, 6); - LightOffA.addBox("ShapeA8", 2F, 22F, 1F, 4, 1, 1); - LightOffA.addBox("ShapeA9", 2F, 22F, 6F, 4, 1, 1); - LightOffB = new ModelRenderer(this, "LightOffB"); - LightOffB.setRotationPoint(0F, 0F, 0F); - LightOffB.mirror = true; - LightOffB.addBox("ShapeA10", 2F, 22F, 2F, 4, 1, 1); - LightOffB.addBox("ShapeA11", 2F, 22F, 5F, 4, 1, 1); - LightOffB.addBox("ShapeA12", 2F, 22F, 3F, 1, 1, 2); - LightOffB.addBox("ShapeA13", 5F, 22F, 3F, 1, 1, 2); - LightOffC = new ModelRenderer(this, "LightOffC"); - LightOffC.setRotationPoint(0F, 0F, 0F); - LightOffC.mirror = true; - LightOffC.addBox("ShapeA14", 3F, 22F, 3F, 2, 1, 2); - } - -} diff --git a/ihl/collector/ChargerEjectorRender.java b/ihl/collector/ChargerEjectorRender.java deleted file mode 100644 index 07ed0af..0000000 --- a/ihl/collector/ChargerEjectorRender.java +++ /dev/null @@ -1,92 +0,0 @@ -package ihl.collector; - -import org.lwjgl.opengl.GL11; - -import ihl.IHLModInfo; -import ihl.utils.IHLItemRenderer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; - -public class ChargerEjectorRender extends TileEntitySpecialRenderer { - private ChargerEjectorModel model = new ChargerEjectorModel(); - private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/chargerEjector.png"); - private int blink=0; - private IHLItemRenderer itemRenderer=new IHLItemRenderer(); - - @Override - public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) - { - this.renderAModelAt((ChargerEjectorTileEntity)par1TileEntity, par2, par4, par6, par8); - } - - private void renderAModelAt(ChargerEjectorTileEntity te, - double x, double y, double z, float par8) { - if(blink<60) - { - blink++; - } - else - { - blink=0; - } - int[] x0={0,-8,0,8,0,-8,0,8,-4}; - int[] z0={0,0,-8,0,0,0,8,0,-4}; - int[] y0={0,0,0,0,-12,0,0,0,-12}; - int[] x1={0,-8,-8,0,0,-8,-8, 0,-4}; - int[] z1={0, 0, 8,8,8, 8, 0, 0, 4}; - int[] y1={0, 0, 0,0,6, 6, 6, 6,12}; - for(int i=0;i<9;i++) - { - this.itemRenderer.doRender(RenderManager.instance, te.chargeSlot.get(i), x+x1[i]/16F+0.75D, y+y1[i]/16F+0.25D, z+z1[i]/16F+0.25D); - } - bindTexture(tex); //texture - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 12F/16F, (float)z + 0.5F); - GL11.glScalef(1.0F, -0.5F, -1F); - model.Base.render(1.0F/16.0F); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xf0, 0xf0); - for(int i=0;i<9;i++) - { - - GL11.glTranslatef(x0[i]/16F, y0[i]/16F, z0[i]/16F); - if(te.chargeSlotStatus[i]<=0) - { - model.LightOffA.render(1F/16F); - model.LightOffB.render(1F/16F); - model.LightOffC.render(1F/16F); - } - else if(te.chargeSlotStatus[i]==2) - { - model.LightOnA.render(1F/16F); - model.LightOnB.render(1F/16F); - model.LightOnC.render(1F/16F); - } - else - { - if(blink<20) - { - model.LightOnA.render(1F/16F); - model.LightOffB.render(1F/16F); - model.LightOffC.render(1F/16F); - } - else if(blink>=20 && blink<40) - { - model.LightOffA.render(1F/16F); - model.LightOnB.render(1F/16F); - model.LightOffC.render(1F/16F); - } - else - { - model.LightOffA.render(1F/16F); - model.LightOffB.render(1F/16F); - model.LightOnC.render(1F/16F); - } - } - } - GL11.glPopMatrix(); //end - } - -} diff --git a/ihl/collector/ChargerEjectorTileEntity.java b/ihl/collector/ChargerEjectorTileEntity.java deleted file mode 100644 index cda75f4..0000000 --- a/ihl/collector/ChargerEjectorTileEntity.java +++ /dev/null @@ -1,522 +0,0 @@ -package ihl.collector; - -import java.util.Iterator; -import java.util.List; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergySink; -import ic2.api.item.ElectricItem; -import ic2.api.network.INetworkClientTileEntityEventListener; -import ic2.core.ContainerBase; -import ic2.core.IC2; -import ic2.core.IHasGui; -import ic2.core.block.TileEntityInventory; -import ic2.core.block.invslot.InvSlot; -import ic2.core.block.invslot.InvSlot.Access; -import ihl.IHLMod; -import ihl.utils.IHLInvSlotDischarge; - -public class ChargerEjectorTileEntity extends TileEntityInventory implements IEnergySink, IHasGui, INetworkClientTileEntityEventListener { - - private int tier; - public int maxStorage=10000000; - private double energy=0D; - public final IHLInvSlotDischarge dischargeSlot; - public final InvSlotMultiCharge chargeSlot; - public boolean addedToEnergyNet = false; - public int[] chargeSlotStatus = new int[9]; - public int[] prevChargeSlotStatus = new int[9]; - public ItemStack chargeItemStack0; - public ItemStack chargeItemStack1; - public ItemStack chargeItemStack2; - public ItemStack chargeItemStack3; - public ItemStack chargeItemStack4; - public ItemStack chargeItemStack5; - public ItemStack chargeItemStack6; - public ItemStack chargeItemStack7; - public ItemStack chargeItemStack8; - private int slotNumNet=0; - public boolean isGuiScreenOpened=false; - public boolean autoEject=true; - public boolean firstTickUpdate=true; - - public ChargerEjectorTileEntity() - { - super(); - this.tier=4; - this.dischargeSlot = new IHLInvSlotDischarge(this, 0, Access.IO, this.tier, InvSlot.InvSide.BOTTOM); - this.chargeSlot = new InvSlotMultiCharge(this, 1, this.tier,9); - } - - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) - { - if(this.dischargeSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.dischargeSlot.get())); - for(int i=0;i getNetworkedFields() - { - List fields = super.getNetworkedFields(); - for(int i=0;i0) - { - this.chargeSlotStatus[i]=1; - } - else - { - this.chargeSlotStatus[i]=2; - } - } - } - - } - - @Override - public void updateEntityServer() - { - if(this.firstTickUpdate && this.isGuiScreenOpened) - { - IC2.network.get().updateTileEntityField(this, "autoEject"); - this.firstTickUpdate=false; - } - if(this.energy < 1.0D && this.getActive()) - { - this.setActive(false); - } - else if(this.energy >= 1.0D && !this.getActive()) - { - this.setActive(true); - } - updateChargerSlotStatus(); - { - List eItemsList = this.getEItemsList(); - if(eItemsList!=null && eItemsList.size()>0) - { - Iterator ei = eItemsList.iterator(); - while(ei.hasNext()) - { - EntityItem entity=(EntityItem) ei.next(); - if(!entity.isDead && entity.getEntityItem()!=null && entity.getEntityItem().stackSize>0) - { - if(this.chargeSlot.addItemStackToFirstEmptyStack(entity.getEntityItem())) - { - entity.setDead(); - } - } - else - { - entity.setDead(); - } - } - } - EntityPlayer player = this.worldObj.getClosestPlayer(this.xCoord+0.5D, this.yCoord+0.5D, this.zCoord+0.5D, 1.1D); - if(player!=null && player instanceof EntityPlayerMP) - { - for(int i=0;i=0 && player.inventory.addItemStackToInventory(this.chargeSlot.get(i))) - { - this.chargeSlot.put(i, null); - } - } - } - } - - if(this.slotNumNet= 1.0D) - { - for(int i=0;i 1.0D) - { - amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false); - this.energy += amount; - } - } - - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - try - { - this.energy = nbttagcompound.getDouble("energy"); - } - catch (Exception var3) - { - this.energy = nbttagcompound.getInteger("energy"); - - if (this.maxStorage > Integer.MAX_VALUE) - { - this.energy *= 10.0D; - } - } - this.autoEject=nbttagcompound.getBoolean("autoeject"); - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - nbttagcompound.setDouble("energy", this.energy); - nbttagcompound.setBoolean("autoeject", this.autoEject); - } - - @Override - public boolean acceptsEnergyFrom(TileEntity emitter, - ForgeDirection direction) { - return direction==ForgeDirection.DOWN; - } - - @Override - @SideOnly(Side.CLIENT) - public GuiScreen getGui(EntityPlayer arg0, boolean arg1) - { - return new ChargerEjectorGui(new ChargerEjectorContainer(arg0, this)); - } - - @Override - public ContainerBase getGuiContainer(EntityPlayer arg0) { - return new ChargerEjectorContainer(arg0, this); - } - - @Override - public void onGuiClosed(EntityPlayer arg0) - { - this.isGuiScreenOpened=false; - } - - @Override - public String getInventoryName() { - return "charger_ejector"; - } - - public int getStored() { - return Math.round((float)this.energy); - } - - public void setStored(double value) { - this.energy=value; - } - - public boolean getGui(EntityPlayer player) - { - this.isGuiScreenOpened = this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; - return this.isGuiScreenOpened; - } - - private ItemStack getChargeISByNum(int num) - { - switch(num) - { - case 0: - return this.chargeItemStack0; - case 1: - return this.chargeItemStack1; - case 2: - return this.chargeItemStack2; - case 3: - return this.chargeItemStack3; - case 4: - return this.chargeItemStack4; - case 5: - return this.chargeItemStack5; - case 6: - return this.chargeItemStack6; - case 7: - return this.chargeItemStack7; - case 8: - return this.chargeItemStack8; - default: - return this.chargeItemStack0; - } - } - - private void setChargeISByNum(int num, ItemStack stack) - { - switch(num) - { - case 0: - this.chargeItemStack0=stack; - break; - case 1: - this.chargeItemStack1=stack; - break; - case 2: - this.chargeItemStack2=stack; - break; - case 3: - this.chargeItemStack3=stack; - break; - case 4: - this.chargeItemStack4=stack; - break; - case 5: - this.chargeItemStack5=stack; - break; - case 6: - this.chargeItemStack6=stack; - break; - case 7: - this.chargeItemStack7=stack; - break; - case 8: - this.chargeItemStack8=stack; - break; - default: - this.chargeItemStack0=stack; - } - } - - @SuppressWarnings("unchecked") - protected List getEItemsList() - { - double range = 0.2D; - AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.xCoord-range,this.yCoord,this.zCoord-range,this.xCoord+1.0D+range,this.yCoord+1.0D+range,this.zCoord+1.0D+range); - List eItemsList = this.worldObj.getEntitiesWithinAABB(EntityItem.class, searchArea); - return eItemsList; - } - //1.7.10 API - @Override - public double getDemandedEnergy() - { - return this.maxStorage - this.energy; - } - - @Override - public int getSinkTier() - { - return this.tier; - } - - @Override - public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) - { - if (this.energy >= this.maxStorage) - { - return amount; - } - else - { - this.energy += amount; - return 0.0D; - } - } - - @Override - public void onNetworkEvent(EntityPlayer player, int event) - { - switch(event) - { - case 0: - if(!this.autoEject) - { - this.autoEject=true; - IC2.network.get().updateTileEntityField(this, "autoEject"); - } - break; - case 1: - if(this.autoEject) - { - this.autoEject=false; - IC2.network.get().updateTileEntityField(this, "autoEject"); - } - break; - case 2: - callCollectors(); - break; - case 3: - eraseMemory(); - break; - default: - break; - } - } - - @SuppressWarnings("unchecked") - private void callCollectors() - { - double range = 64D; - AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.xCoord-range,this.yCoord,this.zCoord-range,this.xCoord+1.0D+range,this.yCoord+1.0D+range,this.zCoord+1.0D+range); - List eList = this.worldObj.getEntitiesWithinAABB(CollectorEntity.class, searchArea); - if(!eList.isEmpty()) - { - Iterator eListIterator=eList.iterator(); - while(eListIterator.hasNext()) - { - CollectorEntity fbbe = eListIterator.next(); - fbbe.currentTask=CollectorEntity.Tasks.RECHARGE; - fbbe.charger=this; - } - } - } - - private void eraseMemory() - { - for(int i=0;i eItemIgnoreList = new ArrayList(); - public Tasks currentTask=Tasks.IDLE; - private int teUpdateTimer = 0; - private double[] last5TickPosX = new double[5]; - private double[] last5TickPosY = new double[5]; - private double[] last5TickPosZ = new double[5]; - - public CollectorEntity(World par1World) - { - super(par1World); - //this.preventEntitySpawning = true; - this.setSize(0.9F, 0.25F); - this.pathFinder3D=new IHL3dPathFinder(this); - this.isImmuneToFire=true; - this.waypointX=this.posX; - this.waypointY=this.posY; - this.waypointZ=this.posZ; - this.lastItemX=this.posX; - this.lastItemY=this.posY; - this.lastItemZ=this.posZ; - } - - @Override - protected void applyEntityAttributes() - { - super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); - } - - @Override - protected void entityInit() - { - super.entityInit(); - this.dataWatcher.addObject(16, Integer.valueOf(this.maxEnergy)); - this.dataWatcher.addObject(17, Integer.valueOf(this.energy)); - this.dataWatcher.addObjectByDataType(18, 5); - } - - /** - * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be - * pushable on contact, like boats or minecarts. - */ - @Override - public AxisAlignedBB getCollisionBox(Entity par1Entity) - { - return par1Entity.boundingBox; - } - - /** - * returns the bounding box for this entity - */ - @Override - public AxisAlignedBB getBoundingBox() - { - return this.boundingBox; - } - - /** - * Returns true if this entity should push and be pushed by other entities when colliding. - */ - @Override - public boolean canBePushed() - { - return true; - } - - public CollectorEntity(World par1World, double par2, double par4, double par6) - { - this(par1World); - this.setPosition(par2, par4, par6); - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.prevPosX = par2; - this.prevPosY = par4; - this.prevPosZ = par6; - this.lastItemX=this.posX; - this.lastItemY=this.posY; - this.lastItemZ=this.posZ; - this.waypointX=this.posX; - this.waypointY=this.posY; - this.waypointZ=this.posZ; - } - - - /** - * Returns true if other Entities should be prevented from moving through this Entity. - */ - @Override - public boolean canBeCollidedWith() - { - return !this.isDead; - } - - @SuppressWarnings("unchecked") - @Override - public void onUpdate() - { - super.onUpdate(); - if(teUpdateTimer<120) - { - teUpdateTimer++; - } - else - { - teUpdateTimer=0; - } - if(teUpdateTimer % 5 ==0) - { - this.last5TickPosX[0]=this.posX; - this.last5TickPosY[0]=this.posY; - this.last5TickPosZ[0]=this.posZ; - } - else - { - this.last5TickPosX[teUpdateTimer % 5]=this.last5TickPosX[teUpdateTimer % 5-1]; - this.last5TickPosY[teUpdateTimer % 5]=this.last5TickPosY[teUpdateTimer % 5-1]; - this.last5TickPosZ[teUpdateTimer % 5]=this.last5TickPosZ[teUpdateTimer % 5-1]; - } - if(this.worldObj.isRemote && this.clientSideNeedEnergyUpdate) - { - this.energy=this.dataWatcher.getWatchableObjectInt(17); - this.maxEnergy=this.dataWatcher.getWatchableObjectInt(16); - this.clientSideNeedEnergyUpdate=false; - } - if(this.energy>=1) - { - this.energy-=this.energyConsume; - } - else if(!this.worldObj.isRemote) - { - this.dropAsItem(); - } - if(this.charger==null && teUpdateTimer==20) - { - List teList = this.worldObj.loadedTileEntityList; - Iterator teIterator=teList.iterator(); - while(teIterator.hasNext()) - { - TileEntity te = (TileEntity) teIterator.next(); - if(!te.isInvalid() && this.charger==null && (te instanceof ChargerEjectorTileEntity || te instanceof TileEntityElectricBlock || te instanceof TileEntityBaseGenerator)) - { - double dist1 =this.getDistanceSq(te.xCoord,te.yCoord,te.zCoord); - if(dist1<4096D) - { - if(te instanceof TileEntityElectricBlock) - { - TileEntityElectricBlock charger1 = (TileEntityElectricBlock) te; - if(charger1.chargeSlot.isEmpty()) - { - this.charger=charger1; - } - } - else if(te instanceof TileEntityBaseGenerator) - { - TileEntityBaseGenerator charger1 = (TileEntityBaseGenerator) te; - if(charger1.chargeSlot.isEmpty()) - { - this.charger=charger1; - } - } - else if(te instanceof ChargerEjectorTileEntity) - { - ChargerEjectorTileEntity charger1 = (ChargerEjectorTileEntity) te; - if(charger1.chargeSlot.getFirstEmptyStack()>=0) - { - this.charger=charger1; - } - } - } - } - else if(!te.isInvalid() && this.charger!=null && (te instanceof ChargerEjectorTileEntity || te instanceof TileEntityElectricBlock || te instanceof TileEntityBaseGenerator)) - { - double dist1 =this.getDistanceSq(this.charger.xCoord,this.charger.yCoord,this.charger.zCoord); - double dist2 =this.getDistanceSq(te.xCoord,te.yCoord,te.zCoord); - if(this.charger instanceof ChargerEjectorTileEntity) - { - if(te instanceof ChargerEjectorTileEntity) - { - ChargerEjectorTileEntity charger1 = (ChargerEjectorTileEntity) te; - if(dist2=0) - { - this.charger=charger1; - } - } - } - else - { - if(te instanceof TileEntityElectricBlock) - { - TileEntityElectricBlock charger1 = (TileEntityElectricBlock) te; - if(dist2=0) - { - this.charger=charger1; - } - } - - } - } - } - - } - - if(!this.worldObj.isRemote && hopperx!=0 || hoppery!=0 || hopperz!=0) - { - TileEntity te = this.worldObj.getTileEntity(hopperx, hoppery, hopperz); - if(te!=null && te instanceof IInventory) - { - this.hopper=te; - } - hopperx=0; - hoppery=0; - hopperz=0; - } - if(this.hopper==null && teUpdateTimer==10) - { - List teList = this.worldObj.loadedTileEntityList; - Iterator teIterator=teList.iterator(); - while(teIterator.hasNext()) - { - TileEntity te = (TileEntity) teIterator.next(); - if(this.hopper==null && te instanceof IInventory) - { - this.hopper=te; - } - else if(te instanceof IInventory) - { - double dist1 =this.getDistanceSq(this.hopper.xCoord,this.hopper.yCoord,this.hopper.zCoord); - double dist2 =this.getDistanceSq(te.xCoord,te.yCoord,te.zCoord); - if(dist2=12) - { - if(this.randomWaypoints()) - { - currentTask=Tasks.SEARCH_ITEM; - var7 = 0.5D; - } - } - return; - } - - if(var7 < 1.0D || var7 > 3600.0D) - { - if(var7 < 1.0D) - { - if(this.energy<1000*this.energyConsume) - { - currentTask=Tasks.RECHARGE; - } - switch(currentTask) - { - case RECHARGE: - this.rechargeMe(); - if(this.charger!=null) - { - if(this.pathFinder3D.findPath(this.charger.xCoord+0.5D,this.charger.yCoord+1.5D, this.charger.zCoord+0.5D)) - { - this.waypointX=this.pathFinder3D.waypointX; - this.waypointY=this.pathFinder3D.waypointY; - this.waypointZ=this.pathFinder3D.waypointZ; - } - else - { - this.charger=null; - this.randomWaypoints(); - } - } - break; - case SEARCH_ITEM: - this.harvest(); - List eItemsList=this.getEItemsList(); - if(this.target==null) - { - if(eItemsList.isEmpty()) - { - this.lastItemX=this.posX; - this.lastItemY=this.posY; - this.lastItemZ=this.posZ; - } - else - { - Iterator ei = eItemsList.iterator(); - while(ei.hasNext()) - { - EntityItem newTarget=(EntityItem) ei.next(); - if(!newTarget.isDead && newTarget.getEntityItem()!=null && newTarget.getEntityItem().stackSize>0 && this.canAdd(newTarget.getEntityItem()) && !this.eItemIgnoreList.contains(newTarget)) - { - if(this.pathFinder3D.findPath(newTarget.posX, newTarget.posY+1.0D, newTarget.posZ)) - { - this.target=newTarget; - this.waypointX=this.pathFinder3D.waypointX; - this.waypointY=this.pathFinder3D.waypointY; - this.waypointZ=this.pathFinder3D.waypointZ; - break; - } - else - { - this.eItemIgnoreList.add(newTarget); - } - } - } - } - } - else - { - if(this.target.isDead) - { - this.target=null; - } - else if(this.pathFinder3D.findPath(target.posX, target.posY+1.0D, target.posZ)) - { - this.waypointX=this.pathFinder3D.waypointX; - this.waypointY=this.pathFinder3D.waypointY; - this.waypointZ=this.pathFinder3D.waypointZ; - break; - } - else - { - this.eItemIgnoreList.add(target); - this.target=null; - } - } - if(this.target==null && this.capturedStack!=null) - { - currentTask=Tasks.DROP_ITEM; - this.waypointX=this.posX; - this.waypointY=this.posY; - this.waypointZ=this.posZ; - } - else if(this.target==null) - { - this.randomWaypoints(); - } - break; - case DROP_ITEM: - this.dropItem(); - if(this.hopper!=null && this.capturedStack!=null) - { - this.pathFinder3D.findPath(this.hopper.xCoord,this.hopper.yCoord+2.0D, this.hopper.zCoord); - this.waypointX=this.pathFinder3D.waypointX; - this.waypointY=this.pathFinder3D.waypointY; - this.waypointZ=this.pathFinder3D.waypointZ; - } - else - { - currentTask=Tasks.SEARCH_ITEM; - this.waypointX=this.posX; - this.waypointY=this.posY; - this.waypointZ=this.posZ; - } - break; - default: - break; - } - } - } - if(this.isEntityInsideOpaqueBlock()) - { - this.noClip=true; - int xyz[] = {0,0,1,0,0,-1,0,0}; - Block block; - int x,y,z; - for(int i=0;i<=5;i++) - { - x=MathHelper.floor_double(this.posX)+xyz[i]; - y=MathHelper.floor_double(this.posY)+xyz[i+1]; - z=MathHelper.floor_double(this.posZ)+xyz[i+2]; - block = this.worldObj.getBlock(x,y,z); - if(block.isAir(this.worldObj, x,y,z)) - { - double varx=x+0.5D; - double vary=y+0.5D; - double varz=z+0.5D; - this.setPosition(varx, vary, varz); - this.setHealth(this.getMaxHealth()); - this.noClip=false; - break; - } - } - } - - if(var7>0.01D) - { - var7 = MathHelper.sqrt_double(var7); - this.motionX += var1 / var7 * 0.02D; - this.motionY += var3 / var7 * 0.02D; - this.motionZ += var5 / var7 * 0.02D; - } - if (this.courseChangeCooldown-- <= 0) - { - this.courseChangeCooldown += this.rand.nextInt(5) + 2; - - } - float rYaw=-((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI; - float rYawD=this.rotationYaw-rYaw; - this.renderYawOffset = this.rotationYaw -= rYawD*0.1F; - } - - protected boolean canAdd(ItemStack stack) - { - if(this.capturedStack==null) - { - return true; - } - else - { - if(this.capturedStack.stackSize eItemsList = this.worldObj.getEntitiesWithinAABB(EntityItem.class, searchArea); - if(eItemsList!=null && eItemsList.size()>0) - { - Iterator itemIterator = eItemsList.iterator(); - while(itemIterator.hasNext()) - { - EntityItem eItem = (EntityItem) itemIterator.next(); - if(eItem.getEntityItem()!=null && eItem.getEntityItem().stackSize>0) - { - if(this.canAdd(eItem.getEntityItem())) - { - this.harvest(eItem); - } - } - else if(eItem.getEntityItem().stackSize<=0) - { - if(!this.worldObj.isRemote)eItem.setDead(); - } - else if(eItem.getEntityItem()==null) - { - if(!this.worldObj.isRemote)eItem.setDead(); - } - } - } - } - - protected void dropItem() - { - if(this.hopper!=null && this.capturedStack!=null) - { - double var1 = this.hopper.xCoord - this.posX; - double var3 = this.hopper.yCoord - this.posY + 2D; - double var5 = this.hopper.zCoord - this.posZ; - double var7 = var1 * var1 + var3 * var3 + var5 * var5; - if (var7 < 2.0D) - { - if(this.addItemStackToInventory((IInventory)this.hopper, this.capturedStack)) - { - this.capturedStack=null; - this.dataWatcher.updateObject(18, this.capturedStack); - } - } - } - } - - private void rechargeMe() - { - if(this.charger!=null) - { - double var1 = this.charger.xCoord - this.posX; - double var3 = this.charger.yCoord - this.posY + 2D; - double var5 = this.charger.zCoord - this.posZ; - double var7 = var1 * var1 + var3 * var3 + var5 * var5; - if (var7 < 2.0D) - { - if(this.charger instanceof TileEntityElectricBlock) - { - InvSlotCharge chargeSlot =((TileEntityElectricBlock) this.charger).chargeSlot; - if(chargeSlot.isEmpty()) - { - ItemStack itemStack = this.getItemStack(this.energy); - if(this.hopper!=null) - { - int[] hopperxyz = {this.hopper.xCoord,this.hopper.yCoord,this.hopper.zCoord}; - if(itemStack.stackTagCompound==null) - { - itemStack.stackTagCompound=new NBTTagCompound(); - } - itemStack.stackTagCompound.setIntArray("hopperxyz", hopperxyz); - } - - chargeSlot.put(itemStack); - if(this.capturedStack!=null) - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.capturedStack)); - } - this.setDead(); - } - else - { - this.charger=null; - } - } - else if(this.charger instanceof TileEntityBaseGenerator) - { - InvSlotCharge chargeSlot =((TileEntityBaseGenerator) this.charger).chargeSlot; - if(chargeSlot.isEmpty()) - { - ItemStack itemStack = this.getItemStack(this.energy); - if(this.hopper!=null) - { - int[] hopperxyz = {this.hopper.xCoord,this.hopper.yCoord,this.hopper.zCoord}; - if(itemStack.stackTagCompound==null) - { - itemStack.stackTagCompound=new NBTTagCompound(); - } - itemStack.stackTagCompound.setIntArray("hopperxyz", hopperxyz); - } - - chargeSlot.put(itemStack); - if(this.capturedStack!=null) - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.capturedStack)); - } - this.setDead(); - } - else - { - this.charger=null; - } - } - else if(this.charger instanceof ChargerEjectorTileEntity) - { - InvSlotMultiCharge chargeSlot =((ChargerEjectorTileEntity) this.charger).chargeSlot; - if(chargeSlot.isEmpty()) - { - ItemStack itemStack = this.getItemStack(this.energy); - if(this.hopper!=null) - { - int[] hopperxyz = {this.hopper.xCoord,this.hopper.yCoord,this.hopper.zCoord}; - if(itemStack.stackTagCompound==null) - { - itemStack.stackTagCompound=new NBTTagCompound(); - } - itemStack.stackTagCompound.setIntArray("hopperxyz", hopperxyz); - } - chargeSlot.put(itemStack); - spawnContainedItems(); - this.setDead(); - } - else - { - this.charger=null; - } - } - else - { - this.charger=null; - return; - } - } - } - } - - private boolean randomWaypoints() - { - double wx,wy,wz; - if(this.hopper!=null) - { - double var1 = this.hopper.xCoord - this.posX; - double var3 = this.hopper.yCoord - this.posY + 1.5D; - double var5 = this.hopper.zCoord - this.posZ; - double var7 = var1 * var1 + var3 * var3 + var5 * var5; - if(var7>4096D) - { - wx = (double)this.hopper.xCoord + (double)(this.rand.nextFloat() * 8.0F - 4.0F); - wy = (double)this.hopper.yCoord + (double)(this.rand.nextFloat() * 8.0F - 4.0F); - wz = (double)this.hopper.zCoord + (double)(this.rand.nextFloat() * 8.0F - 4.0F); - } - else if(var3>16D) - { - wx = this.posX + (this.rand.nextFloat() * 8.0F - 4.0F); - wy = (double)this.hopper.yCoord + (double)(this.rand.nextFloat() * 8.0F - 4.0F); - wz = this.posZ + (this.rand.nextFloat() * 8.0F - 4.0F); - } - else - { - wx = this.posX + (this.rand.nextFloat() * 8.0F - 4.0F); - wy = this.posY + (this.rand.nextFloat() * 8.0F - 4.0F); - wz = this.posZ + (this.rand.nextFloat() * 8.0F - 4.0F); - } - } - else - { - wx = this.posX + (this.rand.nextFloat() * 8.0F - 4.0F); - wy = this.posY + (this.rand.nextFloat() * 2.0F - 1.0F); - wz = this.posZ + (this.rand.nextFloat() * 8.0F - 4.0F); - } - if(this.pathFinder3D.findPath(wx, wy, wz)) - { - this.waypointX=this.pathFinder3D.waypointX; - this.waypointY=this.pathFinder3D.waypointY; - this.waypointZ=this.pathFinder3D.waypointZ; - return true; - } - else - { - return false; - } - } - - - protected boolean addItemStackToInventory(IInventory hopper, ItemStack stack) - { - int startFrom=0; - int endWith=hopper.getSizeInventory()-1; - if(IHLMod.isGregTechModLoaded && IHLMod.isGT_API_Version_5 && hopper instanceof gregtech.api.metatileentity.BaseMetaTileEntity) - { - startFrom=endWith=4; - } - for(int i=startFrom;i<=endWith;++i) - { - if(hopper.isItemValidForSlot(i, stack)) - { - ItemStack hopperSlot = hopper.getStackInSlot(i); - if(hopperSlot!=null && hopperSlot.stackSize getEItemsList() - { - double range = 32D; - AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.lastItemX-range,this.lastItemY-range,this.lastItemZ-range,this.lastItemX+range,this.lastItemY+range,this.lastItemZ+range); - List eItemsList = this.worldObj.getEntitiesWithinAABB(EntityItem.class, searchArea); - return eItemsList; - } - - public ItemStack getItemStack(int charge) - { - ItemStack ret = new ItemStack(this.thisItem); - ElectricItem.manager.charge(ret, charge, this.maxEnergy, true, false); - return ret; - } - - public enum Tasks - { - RECHARGE, - SEARCH_ITEM, - DROP_ITEM, - IDLE - } - - protected void spawnContainedItems() - { - if(this.capturedStack!=null) - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.capturedStack)); - } - } - - protected void harvest(EntityItem eItem) - { - if(this.capturedStack==null) - { - this.capturedStack=eItem.getEntityItem(); - if(!this.worldObj.isRemote)eItem.setDead(); - this.target=null; - if(this.capturedStack!=null) - { - this.dataWatcher.updateObject(18, this.capturedStack.copy()); - this.lastItemX=this.posX; - this.lastItemY=this.posY; - this.lastItemZ=this.posZ; - } - } - else if(this.capturedStack.getItem() == eItem.getEntityItem().getItem() && this.capturedStack.getItemDamage() == eItem.getEntityItem().getItemDamage()) - { - this.capturedStack.stackSize+=eItem.getEntityItem().stackSize; - if(!this.worldObj.isRemote)eItem.setDead(); - this.target=null; - this.dataWatcher.updateObject(18, this.capturedStack.copy()); - this.lastItemX=this.posX; - this.lastItemY=this.posY; - this.lastItemZ=this.posZ; - } - } - -} \ No newline at end of file diff --git a/ihl/collector/CollectorHeavyEntity.java b/ihl/collector/CollectorHeavyEntity.java deleted file mode 100644 index 510e28b..0000000 --- a/ihl/collector/CollectorHeavyEntity.java +++ /dev/null @@ -1,305 +0,0 @@ -package ihl.collector; - -import ihl.IHLMod; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.world.World; - -public class CollectorHeavyEntity extends CollectorEntity { - private ItemStack capturedStack2; - private ItemStack capturedStack3; - private ItemStack capturedStack4; - - public CollectorHeavyEntity(World par1World) - { - super(par1World); - this.setSize(0.98F, 0.25F); - this.energyConsume=4; - this.thisItem=IHLMod.collectorHeavyItem; - this.waypointX=this.posX; - this.waypointY=this.posY; - this.waypointZ=this.posZ; - this.lastItemX=this.posX; - this.lastItemY=this.posY; - this.lastItemZ=this.posZ; - } - - public CollectorHeavyEntity(World par1World, double par2, double par4, double par6) - { - this(par1World); - this.setPosition(par2, par4, par6); - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.prevPosX = par2; - this.prevPosY = par4; - this.prevPosZ = par6; - this.lastItemX=this.posX; - this.lastItemY=this.posY; - this.lastItemZ=this.posZ; - this.energyConsume=4; - this.thisItem=IHLMod.collectorHeavyItem; - } - - - @Override - protected void entityInit() - { - super.entityInit(); - this.dataWatcher.addObjectByDataType(19, 5); - this.dataWatcher.addObjectByDataType(20, 5); - this.dataWatcher.addObjectByDataType(21, 5); - } - - @Override - protected void dropItem() - { - if(this.hopper!=null) - { - double var1 = this.hopper.xCoord - this.posX; - double var3 = this.hopper.yCoord - this.posY + 2D; - double var5 = this.hopper.zCoord - this.posZ; - double var7 = var1 * var1 + var3 * var3 + var5 * var5; - - if (var7 < 2.0D) - { - for(int i=0;i<4;i++) - { - if(getItemStackNum(i)!=null && this.addItemStackToInventory((IInventory)this.hopper, getItemStackNum(i))) - { - setItemStackSlotContent(i,null); - } - } - } - } - } - - public ItemStack getVisibleItemStack(int num) - { - return this.dataWatcher.getWatchableObjectItemStack(18+num); - } - - @Override - public void readEntityFromNBT(NBTTagCompound nbt) - { - super.readEntityFromNBT(nbt); - try - { - NBTTagList var2 = nbt.getTagList("Items", 10); - if(var2!=null) - { - for(int i=1;i<4;i++) - { - NBTTagCompound var4 = var2.getCompoundTagAt(i); - if(var4!=null) - { - this.setItemStackSlotContent(i, ItemStack.loadItemStackFromNBT(var4)); - if(this.getItemStackNum(i)!=null) - { - this.dataWatcher.updateObject(18+i, this.getItemStackNum(i).copy()); - } - } - } - } - } - catch(Throwable e) - { - e.printStackTrace(); - } - } - - @Override - public void writeEntityToNBT(NBTTagCompound nbt) - { - super.writeEntityToNBT(nbt); - try - { - NBTTagList var2 = nbt.getTagList("Items", 10); - if(var2!=null) - { - for(int i=1;i<4;i++) - { - if(this.getItemStackNum(i)!=null) - { - NBTTagCompound var4 = new NBTTagCompound(); - var4.setByte("Slot", (byte)i); - this.getItemStackNum(i).writeToNBT(var4); - var2.appendTag(var4); - } - } - } - } - catch(Throwable e) - { - e.printStackTrace(); - } - } - - @Override - protected void spawnContainedItems() - { - if(this.capturedStack!=null) - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.capturedStack)); - } - if(this.capturedStack2!=null) - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.capturedStack2)); - } - if(this.capturedStack3!=null) - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.capturedStack3)); - } - if(this.capturedStack4!=null) - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.capturedStack4)); - } - } - - private ItemStack getItemStackNum(int num) - { - switch(num) - { - case 0: - return this.capturedStack; - case 1: - return this.capturedStack2; - case 2: - return this.capturedStack3; - case 3: - return this.capturedStack4; - default: - return this.capturedStack; - } - } - - private void setItemStackSlotContent(int num, ItemStack itemStack) - { - switch(num) - { - case 0: - this.capturedStack=itemStack; - if(this.capturedStack!=null) - { - this.dataWatcher.updateObject(18, this.capturedStack.copy()); - } - else - { - this.dataWatcher.updateObject(18, this.capturedStack); - } - break; - case 1: - this.capturedStack2=itemStack; - if(this.capturedStack2!=null) - { - this.dataWatcher.updateObject(19, this.capturedStack2.copy()); - } - else - { - this.dataWatcher.updateObject(19, this.capturedStack2); - } - break; - case 2: - this.capturedStack3=itemStack; - if(this.capturedStack3!=null) - { - this.dataWatcher.updateObject(20, this.capturedStack3.copy()); - } - else - { - this.dataWatcher.updateObject(20, this.capturedStack3); - } - break; - case 3: - this.capturedStack4=itemStack; - if(this.capturedStack4!=null) - { - this.dataWatcher.updateObject(21, this.capturedStack4.copy()); - } - else - { - this.dataWatcher.updateObject(21, this.capturedStack4); - } - break; - default: - break; - } - } - - private void addItemStackSlotContent(int num, ItemStack itemStack) - { - switch(num) - { - case 0: - this.capturedStack.stackSize+=itemStack.stackSize; - break; - case 1: - this.capturedStack2.stackSize+=itemStack.stackSize; - break; - case 2: - this.capturedStack3.stackSize+=itemStack.stackSize; - break; - case 3: - this.capturedStack4.stackSize+=itemStack.stackSize; - break; - default: - break; - } - } - - @Override - protected boolean canAdd(ItemStack stack) - { - for(int i=0;i<4;i++) - { - if(getItemStackNum(i)==null) - { - return true; - } - else - { - if(getItemStackNum(i).stackSize getHudInfo(ItemStack itemStack) { - LinkedList info = new LinkedList(); - info.add(ElectricItem.manager.getToolTip(itemStack)); - info.add("Power Tier: " + this.tier); - return info; - } - - @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) - { - info.add("PowerTier: " + this.tier); - } - - @Override - @SideOnly(Side.CLIENT) - @SuppressWarnings({ "rawtypes", "unchecked" }) - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - itemList.add(this.getItemStack(this.maxCharge)); - itemList.add(this.getItemStack(0)); - } - - public ItemStack getItemStack(int charge) - { - ItemStack ret = new ItemStack(this); - ElectricItem.manager.charge(ret, charge, this.maxCharge, true, false); - return ret; - } - - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return (this.maxCharge-ElectricItem.manager.getCharge(stack))/this.maxCharge; - } - - -} diff --git a/ihl/collector/CollectorItemRender.java b/ihl/collector/CollectorItemRender.java deleted file mode 100644 index 39040bb..0000000 --- a/ihl/collector/CollectorItemRender.java +++ /dev/null @@ -1,112 +0,0 @@ -package ihl.collector; - -import ihl.IHLModInfo; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.client.model.ModelBox; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.IItemRenderer; -import org.lwjgl.opengl.GL11; - -public class CollectorItemRender implements IItemRenderer{ - private CollectorModel model = new CollectorModel(); - private ResourceLocation tex; - private float scale; - -public CollectorItemRender(boolean heavy) -{ - super(); - if(heavy) - { - scale = 1F/80F; - tex = new ResourceLocation(IHLModInfo.MODID+":textures/entities/collectorHeavy.png"); - } - else - { - scale = 1F/100F; - tex = new ResourceLocation(IHLModInfo.MODID+":textures/entities/collector.png"); - } -} - -@Override -public void renderItem(ItemRenderType type, ItemStack item, Object... data) -{ - int levelBar = Math.max(0,model.Indicator.cubeList.size()-2-Math.round((float)(27-item.getItemDamageForDisplay())*(float)model.Indicator.cubeList.size()/27F)); - RenderPlayer var25; - EntityClientPlayerMP var3 = Minecraft.getMinecraft().thePlayer; - GL11.glPushMatrix(); - switch(type) - { - case EQUIPPED_FIRST_PERSON: - GL11.glTranslatef(0F, 0.5F, 0.5F); - GL11.glScalef(1.0F, -1F, -1F); - Minecraft.getMinecraft().getTextureManager().bindTexture(var3.getLocationSkin()); - var25 = (RenderPlayer)RenderManager.instance.getEntityRenderObject(Minecraft.getMinecraft().thePlayer); - GL11.glRotatef(135F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(35F, 0.0F, 1.0F, 0.0F); - var25.renderFirstPersonArm(Minecraft.getMinecraft().thePlayer); - GL11.glRotatef(-35F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-135F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(-0.5F, -1.0F, 0.5F); - break; - case ENTITY: - GL11.glTranslatef(0F, 1.0F, 0F); - GL11.glScalef(1.0F, -1F, -1F); - break; - case INVENTORY: - GL11.glScalef(1.0F, -1F, -1F); - break; - case EQUIPPED: - GL11.glTranslatef(0.5F,0.5F,0.25F); - GL11.glScalef(1.0F, -1F, -1F); - break; - default: - break; - } - Minecraft.getMinecraft().renderEngine.bindTexture(tex); - model.Base.render(scale); - for(int i=0;i<4;i++) - { - model.Eleron.rotateAngleY=i*(float)Math.PI/2; - model.Eleron.render(scale); - } - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xf0, 0xf0); - for(int i=0;i<4;i++) - { - GL11.glRotatef(i* 90F, 0.0F, 1.0F, 0.0F); - model.Flares.render(scale); - ModelBox box = (ModelBox) model.Indicator.cubeList.get(levelBar); - box.render(Tessellator.instance,scale); - } - GL11.glPopMatrix(); -} - -/** - * IItemRenderer implementation * - */ -@Override -public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } -} - -@Override -public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return true; -} -} \ No newline at end of file diff --git a/ihl/collector/CollectorModel.java b/ihl/collector/CollectorModel.java deleted file mode 100644 index a1bada9..0000000 --- a/ihl/collector/CollectorModel.java +++ /dev/null @@ -1,110 +0,0 @@ -package ihl.collector; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; - -public class CollectorModel extends ModelBase { - //fields - ModelRenderer Base; - ModelRenderer Eleron; - ModelRenderer Indicator; - ModelRenderer Flares; - - public CollectorModel() - { - textureWidth = 256; - textureHeight = 128; - int barSize=31; - setTextureOffset("Base.Shape1", 34, 10); - setTextureOffset("Base.Shape6", 74, 41); - setTextureOffset("Base.Shape8", 22, 6); - setTextureOffset("Base.Shape27", 0, 0); - setTextureOffset("Base.Shape9", 13, 3); - setTextureOffset("Eleron.Shape4", 0, 6); - setTextureOffset("Eleron.Shape2", 0, 7); - setTextureOffset("Eleron.Shape3", 0, 0); - setTextureOffset("Eleron.Shape5", 0, 0); - setTextureOffset("Eleron.Shape7", 74, 0); - setTextureOffset("Eleron.Shape14", 56, 0); - setTextureOffset("Eleron.Shape11", 48, 0); - setTextureOffset("Eleron.Shape10", 52, 0); - setTextureOffset("Eleron.Shape12", 50, 0); - setTextureOffset("Eleron.Shape13", 54, 0); - setTextureOffset("Eleron.Shape15", 58, 0); - setTextureOffset("Eleron.Shape18", 0, 0); - setTextureOffset("Eleron.Shape16", 0, 3); - setTextureOffset("Eleron.Shape17", 0, 4); - for(int i=0;i 15) - { - ModelBox box = (ModelBox) model.Indicator.cubeList.get(levelBar); - box.render(Tessellator.instance,scale); - } - else if(blink < 15) - { - ModelBox box = (ModelBox) model.Indicator.cubeList.get(model.Indicator.cubeList.size()-1); - box.render(Tessellator.instance,scale); - } - } - GL11.glPopMatrix(); //end - - } - - @Override - protected ResourceLocation getEntityTexture(Entity arg0) { - return this.tex; - } - -} \ No newline at end of file diff --git a/ihl/collector/GlassBoxContainer.java b/ihl/collector/GlassBoxContainer.java deleted file mode 100644 index 8f6e52a..0000000 --- a/ihl/collector/GlassBoxContainer.java +++ /dev/null @@ -1,45 +0,0 @@ -package ihl.collector; - -import ic2.core.ContainerBase; -import ic2.core.slot.SlotInvSlot; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Slot; - -public class GlassBoxContainer extends ContainerBase { - - protected GlassBoxTileEntity tileEntity; - public int lastStorage = -1; - private final static int height=166; - - public GlassBoxContainer(EntityPlayer entityPlayer, GlassBoxTileEntity tileEntity1){ - super(tileEntity1); - this.tileEntity = tileEntity1; - int col; - - for (col = 0; col < 3; ++col) - { - for (int col1 = 0; col1 < 9; ++col1) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); - } - } - - for (col = 0; col < 9; ++col) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); - } - - for(col=0;col<=3;col++) - { - for(int row=0;row<=3;row++) - { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.invSlot, col+row*4, 55+17*col, 7+17*row)); - } - } - } - - @Override - public boolean canInteractWith(EntityPlayer var1) { - return tileEntity.isUseableByPlayer(var1); - } -} diff --git a/ihl/collector/GlassBoxGui.java b/ihl/collector/GlassBoxGui.java deleted file mode 100644 index 2210d06..0000000 --- a/ihl/collector/GlassBoxGui.java +++ /dev/null @@ -1,44 +0,0 @@ -package ihl.collector; - -import cpw.mods.fml.relauncher.Side; - -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class GlassBoxGui extends GuiContainer { - private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIGlassBox.png"); - private GlassBoxContainer container; - - public GlassBoxGui (GlassBoxContainer container1) { - //the container is instanciated and passed to the superclass for handling - super(container1); - this.container=container1; - } - - @Override - protected void drawGuiContainerForegroundLayer(int param1, int param2) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, - int par3) { - //draw your Gui here, only thing you need to change is the path - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } - - @Override - public void onGuiClosed() - { - super.onGuiClosed(); - this.container.tileEntity.isGuiScreenOpened=false; - } -} \ No newline at end of file diff --git a/ihl/collector/GlassBoxRender.java b/ihl/collector/GlassBoxRender.java deleted file mode 100644 index 305c6bd..0000000 --- a/ihl/collector/GlassBoxRender.java +++ /dev/null @@ -1,47 +0,0 @@ -package ihl.collector; - -import java.util.Random; - -import org.lwjgl.opengl.GL11; - -import ihl.utils.IHLItemRenderer; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; - -public class GlassBoxRender extends TileEntitySpecialRenderer { - private IHLItemRenderer itemRenderer=new IHLItemRenderer(); - private Random rand = new Random(); - private float[] randomPosMatrix={rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat(),rand.nextFloat()}; - - @Override - public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) - { - this.renderAModelAt((GlassBoxTileEntity)par1TileEntity, par2, par4, par6, par8); - } - - private void renderAModelAt(GlassBoxTileEntity te, - double x, double y, double z, float par8) { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y+0.5F, (float)z + 0.5F); - for(int i=0;i getNetworkedFields() - { - List fields = super.getNetworkedFields(); - fields.add("invSlot"); - return fields; - } - - public boolean enableUpdateEntity() - { - return IC2.platform.isSimulating(); - } - - @Override - public void updateEntityServer() - { - boolean needInvUpdate=false; - List eItemList = new ArrayList(); - for(int i=0;i=0 && player.inventory.addItemStackToInventory(this.invSlot.get(i))) - { - this.invSlot.put(i, null); - needInvUpdate=true; - } - } - } - } - if(needInvUpdate) - { - IC2.network.get().updateTileEntityField(this, "invSlot"); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - } - - @Override - @SideOnly(Side.CLIENT) - public GuiScreen getGui(EntityPlayer arg0, boolean arg1) - { - return new GlassBoxGui(new GlassBoxContainer(arg0, this)); - } - - @Override - public ContainerBase getGuiContainer(EntityPlayer arg0) { - return new GlassBoxContainer(arg0, this); - } - - @Override - public void onGuiClosed(EntityPlayer arg0) - { - this.isGuiScreenOpened=false; - } - - @Override - public String getInventoryName() { - return "glass_box"; - } - - public boolean getGui(EntityPlayer player) - { - this.isGuiScreenOpened = this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; - return this.isGuiScreenOpened; - } - - @SuppressWarnings("unchecked") - protected List getEItemsList() - { - double range = 0.2D; - AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.xCoord,this.yCoord,this.zCoord,this.xCoord+1.0D,this.yCoord+1.0D+range,this.zCoord+1.0D); - List eItemsList = this.worldObj.getEntitiesWithinAABB(EntityItem.class, searchArea); - return eItemsList; - } - - @Override - public void setInventorySlotContents(int var1, ItemStack var2) - { - super.setInventorySlotContents(var1, var2); - IC2.network.get().updateTileEntityField(this, "invSlot"); - } - - public void dropContents() - { - for(int i=0;i=this.size()) - { - return false; - } - else - { - if(this.accepts(stack)) - { - this.put(slotNum, stack); - return true; - } - else - { - return false; - } - } - } - - @Override - public void put(ItemStack stack) - { - this.addItemStackToFirstEmptyStack(stack); - } - - public int getFirstEmptyStack() - { - for(int i=0;i=0; - } -} diff --git a/ihl/crop_harvestors/BlowerBlock.java b/ihl/crop_harvestors/BlowerBlock.java deleted file mode 100644 index 3ec49b7..0000000 --- a/ihl/crop_harvestors/BlowerBlock.java +++ /dev/null @@ -1,169 +0,0 @@ -package ihl.crop_harvestors; - -import java.util.Random; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ic2.api.item.IC2Items; -import ihl.IHLCreativeTab; -import ihl.IHLModInfo; -import ihl.utils.IHLUtils; -import net.minecraft.block.Block; -import net.minecraft.block.ITileEntityProvider; -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.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlowerBlock extends Block implements ITileEntityProvider{ - - IIcon textureLeft, textureRight, textureBack; - - public BlowerBlock(Material material) - { - super(material); - this.setCreativeTab(IHLCreativeTab.tab); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) - { - return IC2Items.getItem("machine").getItem(); - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - TileEntity te = world.getTileEntity(x,y,z); - if(te instanceof BlowerTileEntity) - { - BlowerTileEntity bte = (BlowerTileEntity)te; - bte.updateChecksum=-1; - } - } - - @Override - public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) - { - } - - @Override - public TileEntity createNewTileEntity(World world, int var2) { - return new BlowerTileEntity(); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) - { - this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blowerFront"); - this.textureBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blowerBack"); - this.textureLeft = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blowerLeft"); - this.textureRight = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blowerRight"); - } - - @Override - public boolean hasTileEntity(int metadata) - { - return true; - } - - @Override - public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){ - TileEntity te = world.getTileEntity(x,y,z); - if(te instanceof BlowerTileEntity) - { - BlowerTileEntity bte = (BlowerTileEntity)te; - if (bte == null || entityPlayer.isSneaking()) { - return false; - } - else - { - return bte.getGui(entityPlayer); - } - } - return false; - } - - /** - * Called when the block is placed in the world. - */ - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) - { - TileEntity t = world.getTileEntity(x, y, z); - if(t!=null && t instanceof BlowerTileEntity) - { - ((BlowerTileEntity)t).setFacing(IHLUtils.getFacingFromPlayerView(player, false)); - } - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - int facing=3; - int mask[] = { - 0,1,2,3,4,5, - 1,0,3,2,4,5, - 3,2,0,1,4,5, - 2,3,1,0,4,5, - 2,3,5,4,0,1, - 2,3,4,5,1,0 - }; - TileEntity te = world.getTileEntity(x, y, z); - if(te!=null) - { - BlowerTileEntity tebh = (BlowerTileEntity) te; - facing=tebh.getFacing(); - } - - switch (mask[facing*6+side]) - { - case 0: - return this.blockIcon; - case 1: - return this.textureBack; - case 2: - return this.textureBack; - case 3: - return this.textureBack; - case 4: - return this.textureLeft; - case 5: - return this.textureRight; - default: - return this.textureLeft; - } - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - switch (side) - { - case 0: - return this.blockIcon; - case 1: - return this.textureBack; - case 2: - return this.textureLeft; - case 3: - return this.textureRight; - case 4: - return this.textureBack; - case 5: - return this.textureBack; - default: - return this.textureLeft; - } - } - -} diff --git a/ihl/crop_harvestors/BlowerContainer.java b/ihl/crop_harvestors/BlowerContainer.java deleted file mode 100644 index 2a64488..0000000 --- a/ihl/crop_harvestors/BlowerContainer.java +++ /dev/null @@ -1,89 +0,0 @@ -package ihl.crop_harvestors; - -import ic2.core.ContainerBase; -import ic2.core.slot.SlotInvSlot; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - -public class BlowerContainer extends ContainerBase { - - protected BlowerTileEntity tileEntity; - public int lastStorage = -1; - public int lastAirSpeed = -1; - private final static int height=166; - - public BlowerContainer(EntityPlayer entityPlayer, BlowerTileEntity tileEntity1){ - super(tileEntity1); - this.tileEntity = tileEntity1; - int col; - - for (col = 0; col < 3; ++col) - { - for (int col1 = 0; col1 < 9; ++col1) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); - } - } - - for (col = 0; col < 9; ++col) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); - } - - this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 26, 26)); - for(int row=0;row<=3;row++) - { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, row, 152, 8+row*18)); - } - } - - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)this.crafters.get(i); - - if (this.tileEntity.getStored() != this.lastStorage) - { - icrafting.sendProgressBarUpdate(this, 0, (this.tileEntity.getStored()>>15) & Short.MAX_VALUE); - icrafting.sendProgressBarUpdate(this, 1, (short)(this.tileEntity.getStored() & Short.MAX_VALUE)); - - } - - if (this.tileEntity.airSpeedBase != this.lastAirSpeed) - { - icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.airSpeedBase); - } - } - - this.lastStorage = this.tileEntity.getStored(); - this.lastAirSpeed = this.tileEntity.airSpeedBase; - } - - @Override - public void updateProgressBar(int index, int value) - { - super.updateProgressBar(index, value); - - switch (index) - { - case 0: - this.tileEntity.setStored(value<<15); - break; - case 1: - this.tileEntity.setStored(this.tileEntity.getStored()+value); - break; - case 2: - this.tileEntity.airSpeedBase=value; - break; - } - } - - @Override - public boolean canInteractWith(EntityPlayer var1) { - return tileEntity.isUseableByPlayer(var1); - } -} diff --git a/ihl/crop_harvestors/BlowerGui.java b/ihl/crop_harvestors/BlowerGui.java deleted file mode 100644 index bedee1f..0000000 --- a/ihl/crop_harvestors/BlowerGui.java +++ /dev/null @@ -1,58 +0,0 @@ -package ihl.crop_harvestors; - -import cpw.mods.fml.relauncher.Side; - -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class BlowerGui extends GuiContainer { - private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIBlower.png"); - private BlowerContainer container; - - public BlowerGui (BlowerContainer container1) { - //the container is instanciated and passed to the superclass for handling - super(container1); - this.container=container1; - } - - @Override - protected void drawGuiContainerForegroundLayer(int param1, int param2) { - //the parameters for drawString are: string, x, y, color - String title = StatCollector.translateToLocal("tile.blowerBlock.name"); - fontRendererObj.drawStringWithShadow(title, 8, 8, 16767839); - String airspeed = StatCollector.translateToLocal("ihl.gui.blower"); - String units = StatCollector.translateToLocal("ihl.gui.blowerUnits"); - fontRendererObj.drawString(airspeed, 8, 60, 852037); - float e = container.tileEntity.getActive()?container.tileEntity.airSpeedBase/10F:0F; - String eStr = String.valueOf(e); - int w = this.fontRendererObj.getStringWidth(eStr); - fontRendererObj.drawString(eStr, 60-w, 71, 16767839); - fontRendererObj.drawString(units, 62, 71, 852037); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - //charge - if (this.container.tileEntity.getStored() > 0) - { - int chargeLevel=Math.min(Math.round(this.container.tileEntity.getStored()*13.0F/this.container.tileEntity.maxStorage),13); - this.drawTexturedModalRect(11, 28+13-chargeLevel, xSize, 13-chargeLevel, 7, chargeLevel); - } - - - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, - int par3) { - //draw your Gui here, only thing you need to change is the path - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } -} \ No newline at end of file diff --git a/ihl/crop_harvestors/BlowerTileEntity.java b/ihl/crop_harvestors/BlowerTileEntity.java deleted file mode 100644 index e26632b..0000000 --- a/ihl/crop_harvestors/BlowerTileEntity.java +++ /dev/null @@ -1,1065 +0,0 @@ -package ihl.crop_harvestors; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.block.Block; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergySink; -import ic2.api.item.IC2Items; -import ic2.core.ContainerBase; -import ic2.core.IC2; -import ic2.core.IHasGui; -import ic2.core.audio.AudioSource; -import ic2.core.audio.PositionSpec; -import ic2.core.block.TileEntityInventory; -import ic2.core.block.invslot.InvSlot; -import ic2.core.block.invslot.InvSlotUpgrade; -import ic2.core.block.invslot.InvSlot.Access; -import ic2.core.upgrade.IUpgradableBlock; -import ic2.core.upgrade.UpgradableProperty; -import ihl.IHLMod; -import ihl.utils.IHLInvSlotDischarge; - -public class BlowerTileEntity extends TileEntityInventory implements IEnergySink, IHasGui, IUpgradableBlock -{ - private int startUpCounter=0; - private int tier=1; - private int defaultTier=1; - public int maxStorage=100; - private int defaultMaxStorage=100; - private double energy=0D; - private double defaultEnergyConsume=5D; - private double energyConsume=5D; - private int defaultAirSpeedBase=100; - public int airSpeedBase=100; - private int sCAFCount=0; - public boolean addedToEnergyNet = false; - private ArrayList aszlist = new ArrayList(); - public final InvSlotUpgrade upgradeSlot; - public final IHLInvSlotDischarge dischargeSlot; - public int updateChecksum=-1; - private final float lambda=0.00001F; - public int operationRange=-1; - public int lastOperationRange=0; - - private AudioSource startAS; - private AudioSource loopAS; - private AudioSource stopAS; - - public BlowerTileEntity() - { - this.defaultTier=IHLMod.config.blowerTier; - this.defaultMaxStorage=IHLMod.config.blowerMaxEnergyStorage; - this.defaultEnergyConsume=IHLMod.config.blowerEnergyConsumePerTick; - this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 2, 4); - this.dischargeSlot = new IHLInvSlotDischarge(this, 1, Access.IO, this.tier, InvSlot.InvSide.BOTTOM); - } - - @Override - public List getNetworkedFields() - { - List fields = super.getNetworkedFields(); - fields.add("tier"); - fields.add("airSpeedBase"); - fields.add("maxStorage"); - return fields; - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - try - { - this.energy = nbttagcompound.getDouble("energy"); - } - catch (Exception var3) - { - this.energy = nbttagcompound.getInteger("energy"); - - if (this.maxStorage > Integer.MAX_VALUE) - { - this.energy *= 10.0D; - } - } - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - nbttagcompound.setDouble("energy", this.energy); - } - - @Override - public void onLoaded() - { - super.onLoaded(); - if (IC2.platform.isSimulating()) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - this.addedToEnergyNet = true; - } - if (IC2.platform.isRendering() && (this.startAS==null||this.loopAS==null||this.stopAS==null)) - { - this.startAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(),false,false, 1F); - this.loopAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getLoopSoundFile(),true,false, 1F); - this.stopAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStopSoundFile(),false,false, 1F); - } - } - - @Override - public void onUnloaded() - { - if (IC2.platform.isRendering() && this.loopAS != null) - { - this.startAS.stop(); - this.loopAS.stop(); - this.stopAS.stop(); - this.startAS = null; - this.loopAS = null; - this.stopAS = null; - IC2.audioManager.removeSources(this); - } - - if (IC2.platform.isSimulating() && this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - this.addedToEnergyNet = false; - } - super.onUnloaded(); - } - - @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { - return this.getFacing()!=(short)side; - } - - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { - if(this.dischargeSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.dischargeSlot.get())); - if(this.upgradeSlot.get(0)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(0))); - if(this.upgradeSlot.get(1)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(1))); - if(this.upgradeSlot.get(2)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(2))); - if(this.upgradeSlot.get(3)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(3))); - return new ItemStack(IHLMod.blowerBlock,1); - } - - @Override - public void setFacing(short facing1) - { - super.setFacing(facing1); - this.updateChecksum=-1; - } - - public boolean enableUpdateEntity() - { - return true; - } - - public String getStartSoundFile() - { - return "Machines/IHL Industrial Fan/start.ogg"; - } - - public String getLoopSoundFile() - { - return "Machines/IHL Industrial Fan/loop.ogg"; - } - - public String getStopSoundFile() - { - return "Machines/IHL Industrial Fan/stop.ogg"; - } - - @Override - public void updateEntityClient() - { - this.updateBoth(); - if(IC2.platform.isRendering() && this.loopAS!=null) - { - if(this.getActive()) - { - if(this.startUpCounter>12) - { - this.startUpCounter=0; - } - if(this.startUpCounter==0) - { - this.stopAS.stop(); - this.startAS.play(); - } - if(this.startUpCounter<10) - { - this.startUpCounter++; - } - else if(this.startUpCounter==10) - { - this.startAS.stop(); - this.loopAS.play(); - this.startUpCounter++; - } - } - else if(this.startUpCounter>0) - { - this.startAS.stop(); - this.loopAS.stop(); - this.stopAS.play(); - if(this.startUpCounter<170) - { - this.startUpCounter++; - } - else - { - this.startUpCounter=0; - this.stopAS.stop(); - } - } - } - else if(IC2.platform.isRendering() && !this.getActive() && this.loopAS!=null) - { - this.loopAS.stop(); - } - } - - public void updateBoth() - { - if(this.dischargeSlot.tier!=this.tier) - { - this.dischargeSlot.tier=this.tier; - } - } - - - @SuppressWarnings("unchecked") - @Override - public void updateEntityServer() - { - - if (IC2.platform.isSimulating()) - { - this.setOverclockRates(); - } - this.updateBoth(); - if(this.getDemandedEnergy() > 1.0D) - { - double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false); - this.energy += amount; - } - if(this.energy>this.maxStorage) - { - this.energy=this.maxStorage; - } - if(IC2.platform.isSimulating()&&!this.getActive()&&this.energy>=this.energyConsume*2D) - { - this.setActive(true); - } - else if(IC2.platform.isSimulating()&&this.getActive()&&this.energy=this.energyConsume)this.energy-=this.energyConsume; - Iterator it = this.aszlist.iterator(); - a:while(it.hasNext()) - { - AirSpeedZone asz = it.next(); - List entityList = worldObj.getEntitiesWithinAABB(Entity.class, asz.getAABB()); - if(!entityList.isEmpty()) - { - if(this.sCAFCount<=0) - { - this.aszlist.clear(); - this.calculateAirSpeed(); - this.sCAFCount=40; - break a; - } - Iterator ei = entityList.iterator(); - while(ei.hasNext()) - { - Entity ent = ei.next(); - if(asz.isEntityMoveable(ent)) - { - if(ent instanceof EntityPlayer) - { - if(worldObj.isRemote) - { - ent.addVelocity(mX()*0.1D, mY()*0.05D, mZ()*0.1D); - } - } - else - { - ent.addVelocity(mX()*0.1D, mY()*0.05D, mZ()*0.1D); - } - } - } - } - } - - } - if(this.sCAFCount>0) - { - this.sCAFCount--; - } - else - { - this.calculateAirSpeed(); - if(this.operationRange==this.lastOperationRange) - { - this.sCAFCount=600; - } - else - { - this.sCAFCount=20; - this.lastOperationRange=this.operationRange; - } - } - - - } - - private void calculateAirSpeed() - { - int x=xCoord; - int y=yCoord; - int z=zCoord; - int airSpeed=airSpeedBase; - int x0,y0,z0; - x0=x; - y0=y; - z0=z; - int flowExtL=0; - int flowExtR=0; - int flowExtT=0; - int flowExtB=0; - int flowCanBeExtL=0; - int flowCanBeExtR=0; - int flowCanBeExtT=0; - int flowCanBeExtB=0; - - int checkFlowL=0; - int checkFlowR=0; - int checkFlowT=0; - int checkFlowB=0; - - checkFlowL = Math.max( - this.neighborBlowerOperationRange(this.xCoord+mXL()+mX(), this.yCoord+mYL()+mY(),this.zCoord+mZL()+mZ()), - this.neighborBlowerOperationRange(this.xCoord+mXL()-mX(), this.yCoord+mYL()-mY(), this.zCoord+mZL()-mZ()) - ); - checkFlowR = Math.max( - this.neighborBlowerOperationRange(this.xCoord-mXL()+mX(), this.yCoord-mYL()+mY(),this.zCoord-mZL()+mZ()), - this.neighborBlowerOperationRange(this.xCoord-mXL()-mX(), this.yCoord-mYL()-mY(), this.zCoord-mZL()-mZ()) - ); - checkFlowT = Math.max(Math.max( - this.neighborBlowerOperationRange(this.xCoord+mXT()+mX(), this.yCoord+mYT()+mY(),this.zCoord+mZT()+mZ()), - this.neighborBlowerOperationRange(this.xCoord+mXT()-mX(), this.yCoord+mYT()-mY(), this.zCoord+mZT()-mZ()) - ), - this.neighborBlowerOperationRange(this.xCoord+mXT(), this.yCoord+mYT(),this.zCoord+mZT())); - checkFlowB = Math.max(Math.max( - this.neighborBlowerOperationRange(this.xCoord-mXT()+mX(), this.yCoord-mYT()+mY(),this.zCoord-mZT()+mZ()), - this.neighborBlowerOperationRange(this.xCoord-mXT()-mX(), this.yCoord-mYT()-mY(), this.zCoord-mZT()-mZ()) - ), - this.neighborBlowerOperationRange(this.xCoord-mXT(), this.yCoord-mYT(),this.zCoord-mZT())); - int asg = this.getAirSpeedGrade(airSpeed); - a:for(int step=0;step<256;step++) - { - x+=mX(); - y+=mY(); - z+=mZ(); - airSpeed-=Math.round(lambda*(airSpeed*airSpeed))+1; - asg = this.getAirSpeedGrade(airSpeed); - if(asg==0) - { - break; - } - int i1,i2,il,ir,it,ib; - i1=0;i2=0;il=0;ir=0;it=0;ib=0; - for(int tb=-flowExtB;tb<=flowExtT;tb++) - { - i1++; - if(this.isAirPassable(x+mXL()*(flowExtL+1)+mXT()*tb,y+mYL()*(flowExtL+1)+mYT()*tb,z+mZL()*(flowExtL+1)+mZT()*tb)) - { - il++; - } - if(this.isAirPassable(x-mXL()*(flowExtR+1)+mXT()*tb,y-mYL()*(flowExtR+1)+mYT()*tb,z-mZL()*(flowExtR+1)+mZT()*tb)) - { - ir++; - } - } - if(i1==il && step>=checkFlowL) - { - flowCanBeExtL++; - } - if(i1==ir && step>=checkFlowR) - { - flowCanBeExtR++; - } - for(int lr=-flowExtL;lr<=flowExtR;lr++) - { - i2++; - if(this.isAirPassable(x+mXT()*(flowExtT+1)+mXL()*lr,y+mYT()*(flowExtT+1)+mYL()*lr,z+mZT()*(flowExtT+1)+mZL()*lr)) - { - it++; - } - if(this.isAirPassable(x-mXT()*(flowExtB+1)+mXL()*lr,y-mYT()*(flowExtB+1)+mYL()*lr,z-mZT()*(flowExtB+1)+mZL()*lr)) - { - ib++; - } - } - if(i2==it && step>=checkFlowT) - { - flowCanBeExtT++; - } - if(i2==ib && step>=checkFlowB) - { - flowCanBeExtB++; - } - airSpeed-=Math.round(lambda*(airSpeed*airSpeed)*(il+ir+it+ib))+il+ir+it+ib; - asg = this.getAirSpeedGrade(airSpeed); - if(asg==0) - { - this.operationRange=step; - break; - } - if(flowCanBeExtB>=4) - { - flowCanBeExtB=0; - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x-mX()+mXL()*flowExtL+mXT()*flowExtT, - y-mY()+mYL()*flowExtL+mYT()*flowExtT, - z-mZ()+mZL()*flowExtL+mZT()*flowExtT)); - x0=x; - y0=y; - z0=z; - int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - flowExtB++; - int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - airSpeed=airSpeed*s0/s1; - } - else if(flowCanBeExtT>=4) - { - flowCanBeExtT=0; - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x-mX()+mXL()*flowExtL+mXT()*flowExtT, - y-mY()+mYL()*flowExtL+mYT()*flowExtT, - z-mZ()+mZL()*flowExtL+mZT()*flowExtT)); - x0=x; - y0=y; - z0=z; - int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - flowExtT++; - int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - airSpeed=airSpeed*s0/s1; - } - else if(flowCanBeExtR>=4) - { - flowCanBeExtR=0; - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x-mX()+mXL()*flowExtL+mXT()*flowExtT, - y-mY()+mYL()*flowExtL+mYT()*flowExtT, - z-mZ()+mZL()*flowExtL+mZT()*flowExtT)); - x0=x; - y0=y; - z0=z; - int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - flowExtR++; - int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - airSpeed=airSpeed*s0/s1; - } - else if(flowCanBeExtL>=3) - { - flowCanBeExtL=0; - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x-mX()+mXL()*flowExtL+mXT()*flowExtT, - y-mY()+mYL()*flowExtL+mYT()*flowExtT, - z-mZ()+mZL()*flowExtL+mZT()*flowExtT)); - x0=x; - y0=y; - z0=z; - int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - flowExtL++; - int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - airSpeed=airSpeed*s0/s1; - } - else if(flowCanBeExtR>=3) - { - flowCanBeExtR=0; - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x-mX()+mXL()*flowExtL+mXT()*flowExtT, - y-mY()+mYL()*flowExtL+mYT()*flowExtT, - z-mZ()+mZL()*flowExtL+mZT()*flowExtT)); - x0=x; - y0=y; - z0=z; - int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - flowExtR++; - int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - airSpeed=airSpeed*s0/s1; - } - else if(flowCanBeExtT>=3) - { - flowCanBeExtT=0; - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x-mX()+mXL()*flowExtL+mXT()*flowExtT, - y-mY()+mYL()*flowExtL+mYT()*flowExtT, - z-mZ()+mZL()*flowExtL+mZT()*flowExtT)); - x0=x; - y0=y; - z0=z; - int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - flowExtT++; - int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - airSpeed=airSpeed*s0/s1; - } - else if(flowCanBeExtB>=3) - { - flowCanBeExtB=0; - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x-mX()+mXL()*flowExtL+mXT()*flowExtT, - y-mY()+mYL()*flowExtL+mYT()*flowExtT, - z-mZ()+mZL()*flowExtL+mZT()*flowExtT)); - x0=x; - y0=y; - z0=z; - int s0=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - flowExtB++; - int s1=(flowExtR+flowExtL+1)*(flowExtT+flowExtB+1); - airSpeed=airSpeed*s0/s1; - } - for(int tb=-flowExtB;tb<=flowExtT;tb++) - { - for(int lr=-flowExtR;lr<=flowExtL;lr++) - { - if(!this.isAirPassable(x+mXL()*lr+mXT()*tb+mX(),y+mYL()*lr+mYT()*tb+mY(),z+mZL()*lr+mZT()*tb+mZ())) - { - if(lr==0 && tb==0) - { - //System.out.println("Flow breakened by wall check at step="+step); - this.operationRange=step; - break a; - } - else - { - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x-mX()+mXL()*flowExtL+mXT()*flowExtT, - y-mY()+mYL()*flowExtL+mYT()*flowExtT, - z-mZ()+mZL()*flowExtL+mZT()*flowExtT)); - x0=x; - y0=y; - z0=z; - if(lr>0) - { - flowExtL=lr-1; - } - else if(lr<0) - { - flowExtR=-1-lr; - } - if(tb>0) - { - flowExtT=tb-1; - } - else if(tb<0) - { - flowExtB=-1-tb; - } - } - } - } - } - //System.out.println("Airspeed at step="+step+"equals="+airSpeed); - } - if(asg>0) - { - this.aszlist.add(new AirSpeedZone(asg, - x0-mXL()*flowExtR-mXT()*flowExtB, - y0-mYL()*flowExtR-mYT()*flowExtB, - z0-mZL()*flowExtR-mZT()*flowExtB, - x+mXL()*flowExtL+mXT()*flowExtT, - y+mYL()*flowExtL+mYT()*flowExtT, - z+mZL()*flowExtL+mZT()*flowExtT)); - } - } - - - @Override - public boolean acceptsEnergyFrom(TileEntity emitter, - ForgeDirection direction) { - switch(direction) - { - case UP: - return mY()!=1; - case DOWN: - return mY()!=-1; - case NORTH: - return mZ()!=-1 && mZL()==0; - case EAST: - return mX()!=1 && mXL()==0; - case SOUTH: - return mZ()!=1 && mZL()==0; - case WEST: - return mX()!=-1 && mXL()==0; - default: - return false; - } - } - - private boolean isAirPassable(int x,int y,int z) - { - Block block = worldObj.getBlock(x,y,z); - if(block!=null && !block.isNormalCube(worldObj,x,y,z)) - { - if( - !block.isCollidable() || - block.isAir(worldObj,x, y, z) || - block.getBlockBoundsMinX()>0.15D || - block.getBlockBoundsMaxX()<0.85D || - block.getBlockBoundsMinY()>0.15D || - block.getBlockBoundsMaxY()<0.85D || - block.getBlockBoundsMinZ()>0.15D || - block.getBlockBoundsMaxZ()<0.85D - ) - { - return true; - } - else - { - AxisAlignedBB cb = block.getCollisionBoundingBoxFromPool(worldObj, x, y, z); - if(cb!=null) - { - if( - cb.maxX<=1D && - cb.maxX>=0D && - cb.minX<=1D && - cb.minX>=0D && - cb.maxY<=1D && - cb.maxY>=0D && - cb.minY<=1D && - cb.minY>=0D && - cb.maxZ<=1D && - cb.maxZ>=0D && - cb.minZ<=1D && - cb.minZ>=0D - ) - { - if( - cb.maxX<0.85D|| - cb.minX>0.15D|| - cb.maxY<0.85D|| - cb.minY>0.15D|| - cb.maxZ<0.85D|| - cb.minZ>0.15D - ) - { - return true; - } - } - } - } - } - return false; - } - - private int getAirSpeedGrade(int airSpeed) - { - if(airSpeed<30) - { - return 0; - } - else if(airSpeed<100) - { - return 1; - } - else if(airSpeed<200) - { - return 2; - } - else if(airSpeed<300) - { - return 3; - } - else if(airSpeed<400) - { - return 4; - } - else if(airSpeed<500) - { - return 5; - } - else if(airSpeed<600) - { - return 6; - } - else - { - return 7; - } - } - - private class AirSpeedZone - { - private int airSpeedGrade, x0, y0, z0, x1, y1, z1; - public AirSpeedZone(int airSpeedGrade1, int vx0, int vy0, int vz0, int vx1,int vy1,int vz1) - { - this.airSpeedGrade=airSpeedGrade1; - this.x0=vx0; - this.y0=vy0; - this.z0=vz0; - this.x1=vx1; - this.y1=vy1; - this.z1=vz1; - } - - public AxisAlignedBB getAABB() - { - return AxisAlignedBB.getBoundingBox(Math.min(x0,x1), Math.min(y0,y1), Math.min(z0,z1), Math.max(x0,x1)+1D, Math.max(y0,y1)+1D, Math.max(z0,z1)+1D); - } - - @Override - public boolean equals(Object obj) - { - if(obj instanceof AirSpeedZone) - { - AirSpeedZone asz = (AirSpeedZone)obj; - return ( - this.x0==asz.x0 && - this.y0==asz.y0 && - this.z0==asz.z0 && - this.x1==asz.x1 && - this.y1==asz.y1 && - this.z1==asz.z1); - } - return false; - } - - public boolean isEntityMoveable(Entity entity) - { - if(this.airSpeedGrade>=7) - { - return true; - } - else - { - return (entity.width+1F)*(entity.height+1F)<=this.airSpeedGrade*2; - } - } - } - - private int mX() - { - switch(this.getFacing()) - { - case 4: - return -1; - case 5: - return 1; - default: - return 0; - } - } - - private int mY() - { - switch(this.getFacing()) - { - case 0: - return -1; - case 1: - return 1; - default: - return 0; - } - } - - private int mZ() - { - switch(this.getFacing()) - { - case 2: - return -1; - case 3: - return 1; - default: - return 0; - } - } - - private int mXL() - { - switch(this.getFacing()) - { - case 0: - return -1; - case 1: - return 1; - case 2: - return -1; - case 3: - return 1; - default: - return 0; - } - } - - private int mYL() - { - return 0; - } - - private int mZL() - { - switch(this.getFacing()) - { - case 4: - return 1; - case 5: - return -1; - default: - return 0; - } - } - - private int mXT() - { - return 0; - } - - private int mYT() - { - switch(this.getFacing()) - { - case 2: - return 1; - case 3: - return 1; - case 4: - return 1; - case 5: - return 1; - default: - return 0; - } - } - - private int mZT() - { - switch(this.getFacing()) - { - case 0: - return 1; - case 1: - return -1; - default: - return 0; - } - } - - -@Override - public String getInventoryName() { - return "blower"; - } - - public int getStored() { - return Math.round((float)this.energy); - } - - public void setStored(int value) { - this.energy=value; - } - - @Override - @SideOnly(Side.CLIENT) - public GuiScreen getGui(EntityPlayer arg0, boolean arg1) { - return new BlowerGui(new BlowerContainer(arg0, this)); - } - - public boolean getGui(EntityPlayer player) - { - return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; - } - @Override - public ContainerBase getGuiContainer(EntityPlayer arg0) { - return new BlowerContainer(arg0, this); - } - @Override - public void onGuiClosed(EntityPlayer arg0) {} - - public void setOverclockRates() - { - int speedUp=0; - int tierUp=0; - int capacityUp=0; - int checksum=0; - for(int i=0;i= this.maxStorage) - { - return amount; - } - else - { - this.energy += amount; - return 0.0D; - } - } - - @Override - public double getEnergy() { - return this.energy; - } - - @Override - public boolean useEnergy(double amount) - { - if (this.energy >= amount) - { - this.energy -= amount; - return true; - } - else - { - return false; - } - } - - public int neighborBlowerOperationRange(int x,int y,int z) - { - if(this.worldObj.getTileEntity(x, y, z)!=null && this.worldObj.getTileEntity(x, y, z) instanceof BlowerTileEntity) - { - BlowerTileEntity bte = (BlowerTileEntity) this.worldObj.getTileEntity(x, y, z); - if(bte.getFacing()==this.getFacing()) - { - return bte.operationRange; - } - } - return -1; - } - - public ItemStack getOutput(int arg0) - { - return null; - } - - public int getOutputSize() { - return 0; - } - - public void setOutput(int arg0, ItemStack arg1) { - } - - @Override - public Set getUpgradableProperties() - { - Set properties = new HashSet(); - properties.add(UpgradableProperty.Processing); - properties.add(UpgradableProperty.EnergyStorage); - properties.add(UpgradableProperty.Transformer); - return properties; - } -} \ No newline at end of file diff --git a/ihl/datanet/Contact.java b/ihl/datanet/Contact.java deleted file mode 100644 index 5dce365..0000000 --- a/ihl/datanet/Contact.java +++ /dev/null @@ -1,254 +0,0 @@ -package ihl.datanet; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import ic2.core.Ic2Items; -import ihl.IHLMod; -import ihl.interfaces.IDataCableHolder; -import ihl.interfaces.IDataNode; -import ihl.processing.invslots.InvSlotSignalProcessor; -import ihl.utils.IHLUtils; - -public class Contact implements IDataNode -{ - public final int innerId; - private int dataGridID=-1; - private Set connectedContacts = new HashSet(8); - public final InvSlotSignalProcessor attachedSlot; - public final int attachedSlotNumber; - public final int type; //Free:-1; A1:0; A2:1; C:2; NO:3; NC:4; - private final TileEntity base; - - public Contact(TileEntity base1, int innerId1,InvSlotSignalProcessor attachedSlot1,int attachedSlotNumber1, int type1) - { - type=type1; - base=base1; - innerId=innerId1; - attachedSlot=attachedSlot1; - attachedSlotNumber=attachedSlotNumber1; - } - - public void onLoad() - { - if(dataGridID!=-1) - { - DataGrid grid = IHLMod.datanet.getGrid(dataGridID); - grid.telist.add(this); - } - } - - @Override - public int getDataGridID() { - return dataGridID; - } - - @Override - public void setDataGrid(int newGridID) - { - dataGridID=newGridID; - onLoad(); - } - - @Override - public Set getConnectedDataNodes() { - return this.connectedContacts; - } - - public void removeLinkTo(Contact contact2) - { - this.connectedContacts.remove(contact2); - contact2.getConnectedDataNodes().remove(this); - if(dataGridID!=-1) - { - IHLMod.datanet.splitGrids(dataGridID); - } - if(dataGridID!=-1) - { - for(IDataNode contact3:IHLMod.datanet.getGrid(dataGridID).telist) - { - contact3.checkAttachedSlots(); - } - } - else - { - this.checkAttachedSlots(); - } - if(contact2.getDataGridID()!=-1) - { - for(IDataNode contact3:IHLMod.datanet.getGrid(contact2.getDataGridID()).telist) - { - contact3.checkAttachedSlots(); - } - } - else - { - contact2.checkAttachedSlots(); - } - - } - - public void removeConnections(Contact[] contacts) - { - if(this.dataGridID!=-1) - { - this.connectedContacts.removeAll(Arrays.asList(contacts)); - IHLMod.datanet.splitGrids(dataGridID); - } - } - - public void establishLink(Contact contact) - { - this.connectedContacts.add(contact); - contact.getConnectedDataNodes().add(this); - if(dataGridID!=contact.getDataGridID() || dataGridID==-1 || contact.getDataGridID()==-1) - { - int newDataGridID = IHLMod.datanet.mergeGrids(dataGridID,contact.getDataGridID()); - if(this.dataGridID==-1) - { - this.setDataGrid(newDataGridID); - } - if(contact.getDataGridID()==-1) - { - contact.setDataGrid(newDataGridID); - } - for(IDataNode contact2:IHLMod.datanet.getGrid(newDataGridID).telist) - { - contact2.checkAttachedSlots(); - } - } - } - - public void writeToNBT(NBTTagCompound nbt) - { - nbt.setInteger("dataGridID", dataGridID); - NBTTagList connections = new NBTTagList(); - for(IDataNode contact1:this.connectedContacts) - { - NBTTagCompound contactNBT = new NBTTagCompound(); - contactNBT.setInteger("x", contact1.getXPos()); - contactNBT.setInteger("y", contact1.getYPos()); - contactNBT.setInteger("z", contact1.getZPos()); - contactNBT.setInteger("innerId", contact1.getInnerId()); - connections.appendTag(contactNBT); - } - nbt.setTag("connections"+innerId, connections); - } - - public void readFromNBT(NBTTagCompound nbt) - { - this.setDataGrid(nbt.getInteger("dataGridID")); - NBTTagList connections = nbt.getTagList("connections"+innerId, 10); - for(int i=0;i iconMap = new HashMap(); - private static Map nameMap = new HashMap(); - private static Map descriptionMap = new HashMap(); - public static DataCableItem dataCableInstance; - - public DataCableItem() - { - super(); - this.isDataCable=true; - this.setUnlocalizedName("dataCable"); - dataCableInstance=this; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - Type[] var1 = Type.values(); - for(int i=0;i telist = new HashSet(); - public double energy=0D; - public boolean isGridValid=true; - - public Set getListOfExcludedNodes() - { - Set excludedNodes = new HashSet(); - if(this.telist.isEmpty()) - { - return excludedNodes; - } - excludedNodes.addAll(this.telist); - IDataNode startNode = this.telist.iterator().next(); - this.recursiveGridNodesSearch(excludedNodes, startNode); - this.telist.removeAll(excludedNodes); - return excludedNodes; - } - - public void recursiveGridNodesSearch(Set excludedNodes, IDataNode startNode) - { - Iterator nodei = startNode.getConnectedDataNodes().iterator(); - excludedNodes.remove(startNode); - while(nodei.hasNext()) - { - IDataNode node = nodei.next(); - if(excludedNodes.contains(node)) - { - recursiveGridNodesSearch(excludedNodes, node); - } - } - } - - public boolean isConnectedToContact(Contact emitter, int id) - { - Iterator it1 = this.telist.iterator(); - while(it1.hasNext()) - { - IDataNode ate1 = it1.next(); - if(ate1.getInnerId()==id) - { - return true; - } - else if(emitter!=ate1 && ate1.isIndirectlyConnectedWithContact(id)) - { - return true; - } - } - return false; - } -} diff --git a/ihl/datanet/DataNet.java b/ihl/datanet/DataNet.java deleted file mode 100644 index a241517..0000000 --- a/ihl/datanet/DataNet.java +++ /dev/null @@ -1,127 +0,0 @@ -package ihl.datanet; - -import ihl.IHLMod; -import ihl.flexible_cable.NodeEntity; -import ihl.interfaces.IDataNode; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import net.minecraft.nbt.NBTTagCompound; - -public class DataNet { - - public Map grids = new HashMap(); - private int griduid=0; - - public DataNet() - { - } - - public int getNewUniqueGridID() - { - for(int i=0;i tei = grids.get(gridID2).telist.iterator(); - while(tei.hasNext()) - { - IDataNode te = tei.next(); - te.setDataGrid(gridID); - } - grids.remove(gridID2); - return gridID; - } - return gridID2; - } - - - public DataGrid getGrid(int gridID) - { - if(this.grids.get(gridID)==null) - { - DataGrid cgrid; - cgrid=new DataGrid(); - grids.put(gridID, cgrid); - return cgrid; - } - else - { - return this.grids.get(gridID); - } - } - - public void splitGrids(int gridID) - { - DataGrid grid1 = this.grids.get(gridID); - Set excludedNodes = grid1.getListOfExcludedNodes(); - if(!excludedNodes.isEmpty()) - { - if(grid1.telist.size()==1) - { - IDataNode singleNode = grid1.telist.iterator().next(); - singleNode.setDataGrid(-1); - grid1.telist.remove(singleNode); - } - if(excludedNodes.size()==1) - { - IDataNode singleNode = excludedNodes.iterator().next(); - singleNode.setDataGrid(-1); - } - else //Form a new grid - { - int newGridId = this.getNewUniqueGridID(); - Iterator excludedNodesI = excludedNodes.iterator(); - while(excludedNodesI.hasNext()) - { - excludedNodesI.next().setDataGrid(newGridId); - } - } - } - } - - public void removeCableEntities(NBTTagCompound cable) - { - int uid = cable.getInteger("chainUID"); - Set cs = IHLMod.proxy.nodeEntityRegistry.get(uid); - if(cs!=null) - { - for(NodeEntity ne:cs) - { - if(ne!=null) - { - ne.setDead(); - } - } - } - } -} diff --git a/ihl/datanet/GuiInvisibleButton.java b/ihl/datanet/GuiInvisibleButton.java deleted file mode 100644 index 31e8b3f..0000000 --- a/ihl/datanet/GuiInvisibleButton.java +++ /dev/null @@ -1,22 +0,0 @@ -package ihl.datanet; - -import java.util.List; -import java.util.Map; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; - -public class GuiInvisibleButton extends GuiButton { - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public GuiInvisibleButton(int id1, int x, int y, int w, int h, Map linksCoordinatesMap, List buttonList) - { - super(id1, x, y, w, h, ""); - linksCoordinatesMap.put(id1, new Integer[] {x+w/2,y+h/2}); - buttonList.add(this); - } - - @Override - public void drawButton(Minecraft minecraft, int i, int j){} - -} diff --git a/ihl/datanet/RedstoneSignalConverterContainer.java b/ihl/datanet/RedstoneSignalConverterContainer.java deleted file mode 100644 index 261c9d5..0000000 --- a/ihl/datanet/RedstoneSignalConverterContainer.java +++ /dev/null @@ -1,100 +0,0 @@ -package ihl.datanet; - -import java.util.List; - -import ic2.core.ContainerBase; -import ic2.core.IC2; -import ic2.core.slot.SlotInvSlot; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; - -public class RedstoneSignalConverterContainer extends ContainerBase { - - protected RedstoneSignalConverterTileEntity tileEntity; - private int lastLinksAmount = -1; - private int lastCablesAmount = -1; - private short lastEnergy = -1; - private int prevButtonPressed1 = -1; - public final static int height=224; - public final static int width=198; - public List links; - - public RedstoneSignalConverterContainer(EntityPlayer entityPlayer, RedstoneSignalConverterTileEntity tileEntity1){ - super(tileEntity1); - this.tileEntity = tileEntity1; - links=this.tileEntity.links; - int col; - for (col = 0; col < 3; ++col) - { - for (int col1 = 0; col1 < 9; ++col1) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); - } - } - for (col = 0; col < 9; ++col) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); - } - for (col = 0; col < tileEntity1.sensorEmitterSlots.size(); ++col) - { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.sensorEmitterSlots, col, 8, 8+col*18)); - } - this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 8, 116)); - } - - @Override - public boolean canInteractWith(EntityPlayer var1) { - return tileEntity.isUseableByPlayer(var1); - } - - - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)this.crafters.get(i); - if (this.tileEntity.links.size() != this.lastLinksAmount) - { - IC2.network.get().sendContainerField(this, "links"); - } - if (this.tileEntity.energy != this.lastEnergy) - { - icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.energy); - } - if (this.tileEntity.cableList.size() != this.lastCablesAmount) - { - icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.cableList.size()); - } - if (this.tileEntity.prevButtonPressed != this.prevButtonPressed1) - { - icrafting.sendProgressBarUpdate(this, 3, this.tileEntity.prevButtonPressed); - } - } - this.lastCablesAmount=this.tileEntity.cableList.size(); - this.lastLinksAmount=this.tileEntity.links.size(); - this.lastEnergy=this.tileEntity.energy; - this.prevButtonPressed1 = this.tileEntity.prevButtonPressed; - - } - - @Override - public void updateProgressBar(int index, int value) - { - super.updateProgressBar(index, value); - switch (index) - { - case 1: - this.tileEntity.energy=(short) value; - break; - case 2: - this.tileEntity.cablesAmount=(short) value; - break; - case 3: - this.tileEntity.prevButtonPressed=(short) value; - break; - } - } -} diff --git a/ihl/datanet/RedstoneSignalConverterGui.java b/ihl/datanet/RedstoneSignalConverterGui.java deleted file mode 100644 index ce7e2d4..0000000 --- a/ihl/datanet/RedstoneSignalConverterGui.java +++ /dev/null @@ -1,139 +0,0 @@ -package ihl.datanet; - -import java.util.HashMap; -import java.util.Map; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ic2.core.IC2; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import ihl.collector.GuiMultiTextureButton; - -@SideOnly(Side.CLIENT) -public class RedstoneSignalConverterGui extends GuiContainer { - private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIRedstoneSignalConverter.png"); - private RedstoneSignalConverterContainer container; - private GuiInvisibleButton[] sensorsEmittersPlus = new GuiInvisibleButton[6]; - private GuiInvisibleButton[] sensorsEmittersMinus = new GuiInvisibleButton[6]; - private GuiInvisibleButton[][] cableContacts = new GuiInvisibleButton[4][8]; - public Map linksCoordinatesMap = new HashMap(); - private GuiMultiTextureButton removeLast; - private GuiMultiTextureButton removeAll; - private int timer=10; - - public RedstoneSignalConverterGui (RedstoneSignalConverterContainer container1) - { - super(container1); - this.container=container1; - this.ySize=RedstoneSignalConverterContainer.height; - this.xSize=RedstoneSignalConverterContainer.width; - } - - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - int i,i1; - new GuiInvisibleButton(0, x+24, y+121, 3, 3, linksCoordinatesMap, buttonList); //battery plus - new GuiInvisibleButton(1, x+24, y+124, 3, 3, linksCoordinatesMap, buttonList); //battery minus - for(i=0;i>8) & 255); - Integer[] to = this.linksCoordinatesMap.get(integer & 255); - this.drawLink(from[0], from[1], to[0], to[1], index); - } - - @Override - public void actionPerformed(GuiButton button) - { - super.actionPerformed(button); - IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, button.id); - if (button.id == removeLast.id) - { - //removeLast.isActive=true; - timer=10; - } - if (button.id == removeAll.id) - { - removeAll.isActive=true; - timer=10; - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, - int par3) { - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.mc.renderEngine.bindTexture(background); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - for(int i = 0;i 0) - { - int i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); - this.drawTexturedModalRect(x+184, y+119 + 12 - i1, 202, 12 - i1, 14, i1 + 2); - } - for(int i=0;i0) - { - timer--; - } - if(timer==1) - { - //removeLast.isActive=false; - removeAll.isActive=false; - } - } - - private void drawLink(int fromX, int fromY, int toX, int toY, int index) - { - int verticalLineOffset = 3*index+3; - this.drawTexturedModalRect(Math.min(fromX+verticalLineOffset,toX), toY-1, 0, 253, Math.abs(fromX+verticalLineOffset-toX)+(toX<=fromX+verticalLineOffset?1:0), 3); - this.drawTexturedModalRect(fromX+verticalLineOffset-1, Math.min(fromY, toY), 253, 0, 3, Math.abs(fromY-toY)+(toY cableList; - public final IHLInvSlotDischarge dischargeSlot; - public final List links = new ArrayList();//Short has 16 bits - public int prevButtonPressed=-1; - public short energy=0; - public final static short maxEnergy=Short.MAX_VALUE; - private int tick=0; - public boolean linksOrInventoryChanged=false; - private int inventoryCheckSum=0; - public final Contact[] contacts = new Contact[68]; - private NBTTagCompound nbtread; - public boolean checkcableList=true; - public short cablesAmount=0; - - /*Contacts is: - * 0 - battery slot plus - * 1 - battery slot minus - * 2-7 sensors/emitters plus - * 8-13 sensors/emitters minus - * 14-49 cableList - */ - - public RedstoneSignalConverterTileEntity() - { - sensorEmitterSlots = new InvSlotSignalProcessor(this, "sensorEmitterSlots", 0, Access.IO, 6, 2); - cableList = new ArrayList(); - dischargeSlot = new IHLInvSlotDischarge(this, 2, Access.IO, 4); - contacts[0]=new Contact(this,0,null,-1,0); - contacts[1]=new Contact(this,1,null,-1,1); - for(int i1=2;i1<8;i1++) - { - contacts[i1]=new Contact(this,i1, sensorEmitterSlots,i1-2,0); - } - for(int i1=8;i1<14;i1++) - { - sensorEmitterSlots.setStackSizeLimit(1); - contacts[i1]=new Contact(this,i1, sensorEmitterSlots,i1-8,1); - } - for(int i1=14;i1<50;i1++) - { - contacts[i1]=new Contact(this,i1,null, -1, -1); - } - for(int i1=50;i1<56;i1++) - { - contacts[i1]=new Contact(this,i1, sensorEmitterSlots,i1-50,2); - } - for(int i1=56;i1<62;i1++) - { - contacts[i1]=new Contact(this,i1, sensorEmitterSlots,i1-56,3); - } - for(int i1=62;i1<68;i1++) - { - contacts[i1]=new Contact(this,i1, sensorEmitterSlots,i1-02,4); - } - } - - @Override - public boolean wrenchCanRemove(EntityPlayer var1) - { - return this.cableList.isEmpty(); - } - - @Override - public void setFacing(short facing) - { - this.removeAttachedChains(); - } - - @Override - public void onLoaded() - { - super.onLoaded(); - if (IC2.platform.isSimulating()) - { - IC2.network.get().updateTileEntityField(this, "sensorEmitterSlots"); - if(nbtread!=null) - { - for(Contact contact1:contacts) - { - contact1.readFromNBT(nbtread); - } - } - nbtread=null; - } - } - - @Override - public List getNetworkedFields() - { - List fields = super.getNetworkedFields(); - fields.add("sensorEmitterSlots"); - return fields; - } - - @Override - public void updateEntityClient() - { - int checkSum=0; - for(int i=0;i0) - { - Set checkedGrids = new HashSet(); - Set unCheckedGrids = new HashSet(); - InvSlotSignalProcessor slots = this.sensorEmitterSlots; - for(int i=0;i ugi = unCheckedGrids.iterator(); - while(!unCheckedGrids.isEmpty()) - { - Integer dgid2 = ugi.next(); - ugi.remove(); - { - for(IDataNode contact3:IHLMod.datanet.getGrid(dgid2).telist) - { - contact3.checkAttachedSlots(); - if(contact3.getAttachedSlot()!=null) - { - Contact c4 = contact3.getAttachedSlot().getOppositeContact(contact3); - if(!checkedGrids.contains(c4.getDataGridID())) - { - unCheckedGrids.add(c4.getDataGridID()); - } - } - } - checkedGrids.add(dgid2); - } - } - this.linksOrInventoryChanged=false; - } - if(this.energy < 1) - { - this.energy += (short)(this.dischargeSlot.discharge(getDemandedEnergy(), false)*256D); - } - if(tick++ % 256==0) - { - this.energy--; - } - } - - @Override - public String getInventoryName() - { - return "redstoneSignalConverter"; - } - @Override - public boolean addDataCable(NBTTagCompound cable) - { - if(this.cableList.size()<4) - { - this.cableList.add(cable); - return true; - } - return false; - } - - - @Override - public double[] getPortPos(EntityLivingBase player) - { - ForgeDirection direction = ForgeDirection.getOrientation(IHLUtils.getFacingFromPlayerView(player, true)).getOpposite(); - return new double[] {this.xCoord+0.5d+0.5d*direction.offsetX,this.yCoord+direction.offsetY*1.0d,this.zCoord+0.5d+0.5d*direction.offsetZ}; - } - - @Override - public void onNetworkEvent(EntityPlayer player, int event) - { - if(prevButtonPressed==-1 && event < 255) - { - prevButtonPressed = event; - } - else if(prevButtonPressed!=event && event < 255) - { - int minor = Math.min(prevButtonPressed,event); - int major = Math.max(prevButtonPressed,event); - int link = ((minor<<8) | major); - this.links.add(link); - contacts[prevButtonPressed].establishLink(contacts[event]); - prevButtonPressed=-1; - } - else if(event==256 && !this.links.isEmpty()) - { - int link = this.links.remove(this.links.size()-1); - Contact contact1 = this.contacts[link >> 8]; - Contact contact2 = this.contacts[link & 255]; - contact1.removeLinkTo(contact2); - } - else if(event==257 && !this.links.isEmpty()) - { - this.links.clear(); - for(Contact contact1:contacts) - { - contact1.removeConnections(contacts); - } - } - } - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - for(Contact contact1:contacts) - { - contact1.writeToNBT(nbt); - } - if (!links.isEmpty()) - { - NBTTagList linkList1 = new NBTTagList(); - Iterator fli = links.iterator(); - while(fli.hasNext()) - { - Integer link = fli.next(); - if(link!=null) - { - NBTTagCompound linkNBT1 = new NBTTagCompound(); - linkNBT1.setInteger("link", link); - linkList1.appendTag(linkNBT1); - } - } - nbt.setTag("links", linkList1); - } - else - { - nbt.setString("Empty", ""); - } - NBTTagList cableNBTList = new NBTTagList(); - for(NBTTagCompound cable:this.cableList) - { - cableNBTList.appendTag(cable); - } - nbt.setTag("cableList", cableNBTList); - nbt.setBoolean("checkcableList", this.checkcableList); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - NBTTagList cableNBTList=nbt.getTagList("cableList", 10); - for(int i=0;i getGuiContainer(EntityPlayer player) - { - return new RedstoneSignalConverterContainer(player, this); - } - - public int getGUIEnergy(int i) - { - if(this.energy cli = cableList.iterator(); - while(cli.hasNext()) - { - NBTTagCompound cl=cli.next(); - IHLMod.datanet.removeCableEntities(cl); - ItemStack is = IHLUtils.getThisModItemStack("dataCable"); - is.stackTagCompound=cl; - double[] pps = this.getPortPos(null); - EntityItem eitem = new EntityItem(worldObj, pps[0], pps[1], pps[2], is); - worldObj.spawnEntityInWorld(eitem); - { - int chainUID = cl.getInteger("chainUID"); - int x1 = cl.getInteger("connectorX1"); - int y1 = cl.getInteger("connectorY1"); - int z1 = cl.getInteger("connectorZ1"); - int connectorDimensionId1 = cl.getInteger("connectorDimensionId1"); - int x = cl.getInteger("connectorX"); - int y = cl.getInteger("connectorY"); - int z = cl.getInteger("connectorZ"); - int connectorDimensionId = cl.getInteger("connectorDimensionId"); - if(x1!=xCoord || y1!=yCoord || z1!=zCoord) - { - x=x1; - y=y1; - z=z1; - connectorDimensionId=connectorDimensionId1; - } - TileEntity te = MinecraftServer.getServer().worldServerForDimension(connectorDimensionId).getTileEntity(x, y, z); - if(te instanceof IDataCableHolder) - { - IDataCableHolder dch = ((IDataCableHolder)te); - Contact[] c = this.getContacts(chainUID); - Contact[] c1 = dch.getContacts(chainUID); - for(int i2=0;i2 cli = cableList.iterator(); - while(cli.hasNext()) - { - NBTTagCompound cl=cli.next(); - int chainUID1 = cl.getInteger("chainUID"); - if(chainUID1==chainUID) - { - cli.remove(); - return; - } - } - } - - @Override - public Contact getContact(int innerId1) - { - return this.contacts[innerId1]; - } - - - @Override - public boolean isCableRemoved(int chainUniqueID) { - if(!checkcableList) - { - return false; - } - for(NBTTagCompound cl:cableList) - { - if(cl.getInteger("chainUID")==chainUniqueID) - { - return false; - } - } - return true; - } - - @Override - public void setCableCheck(boolean b) - { - this.checkcableList=b; - } -} diff --git a/ihl/enviroment/SpotlightTileEntity.java b/ihl/enviroment/SpotlightTileEntity.java index b8bebab..ab18ebe 100644 --- a/ihl/enviroment/SpotlightTileEntity.java +++ b/ihl/enviroment/SpotlightTileEntity.java @@ -2,7 +2,7 @@ package ihl.enviroment; import ic2.api.network.INetworkTileEntityEventListener; import ic2.core.IC2; import ihl.IHLModInfo; -import ihl.i_hate_liquids.XYZ; +import ihl.handpump.XYZ; import ihl.utils.IHLUtils; import java.util.HashSet; diff --git a/ihl/explosion/ChunkAndWorldLoadEventHandler.java b/ihl/explosion/ChunkAndWorldLoadEventHandler.java index d52672c..b85e636 100644 --- a/ihl/explosion/ChunkAndWorldLoadEventHandler.java +++ b/ihl/explosion/ChunkAndWorldLoadEventHandler.java @@ -9,64 +9,56 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.Explosion; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -public class ChunkAndWorldLoadEventHandler -{ +public class ChunkAndWorldLoadEventHandler { public static ChunkAndWorldLoadEventHandler instance; - public ChunkAndWorldLoadEventHandler() - { - instance=this; + + public ChunkAndWorldLoadEventHandler() { + instance = this; } - + @SubscribeEvent - public void onChunkLoadEvent(net.minecraftforge.event.world.ChunkEvent.Load event) - { - if(event.getChunk().isChunkLoaded && IHLMod.explosionHandler.blastWaveByDimensionId.containsKey(event.world.provider.dimensionId)) - { - WorldSavedDataBlastWave bwdata = IHLMod.explosionHandler.blastWaveByDimensionId.get(event.world.provider.dimensionId); + public void onChunkLoadEvent(net.minecraftforge.event.world.ChunkEvent.Load event) { + if (event.getChunk().isChunkLoaded + && IHLMod.explosionHandler.blastWaveByDimensionId.containsKey(event.world.provider.dimensionId)) { + WorldSavedDataBlastWave bwdata = IHLMod.explosionHandler.blastWaveByDimensionId + .get(event.world.provider.dimensionId); long cc = ChunkCoordIntPair.chunkXZ2Int(event.getChunk().xPosition, event.getChunk().zPosition); - if(bwdata.data.containsKey(cc)) - { + if (bwdata.data.containsKey(cc)) { Set bwArraySet = bwdata.data.remove(cc); - int[] svset = new int[bwArraySet.size()]; int[] directionMask = new int[3]; - int i=0; Iterator bwArrayI = bwArraySet.iterator(); Integer[] bwArray = null; - while(bwArrayI.hasNext()) - { - bwArray=bwArrayI.next(); - svset[i]=bwArray[0]; - i++; - directionMask[0]=bwArray[5]; - directionMask[1]=bwArray[6]; - directionMask[2]=bwArray[7]; - IHLMod.explosionHandler.setPower(bwArray[0], bwArray[4]); + while (bwArrayI.hasNext()) { + bwArray = bwArrayI.next(); + directionMask[0] = bwArray[5]; + directionMask[1] = bwArray[6]; + directionMask[2] = bwArray[7]; + Explosion explosion = new Explosion(event.world, null, bwArray[1], bwArray[2], bwArray[3], 100f); + IHLMod.explosionHandler.breakBlocksAndGetDescendants(event.world, bwArray[1], bwArray[2], + bwArray[3], explosion, bwArray[0], bwArray[4], directionMask); + } + if (!IHLMod.explosionHandler.isCalculating) { + IHLMod.explosionHandler.sendChunkUpdateToPlayersInExplosionAffectedZone(event.world, bwArray[1], + bwArray[2], bwArray[3]); } -/* IHLMod.log.info("Doing schleduled explosion. Direction: ("+ - directionMask[0]+";"+directionMask[1]+";"+directionMask[2]+") "+ - "svset.length"+svset.length);*/ - IHLMod.explosionHandler.doExplosion(event.world, bwArray[1], bwArray[2], bwArray[3], svset, directionMask, new Explosion(event.world, null, bwArray[1], bwArray[2], bwArray[3], 100f)); - IHLMod.explosionHandler.sendChunkUpdateToPlayersInExplosionAffectedZone(event.world, bwArray[1], bwArray[2], bwArray[3]); } } } @SubscribeEvent - public void onWorldLoadEvent(net.minecraftforge.event.world.WorldEvent.Load event) - { - WorldSavedDataBlastWave blastWave = (WorldSavedDataBlastWave) event.world.mapStorage.loadData(WorldSavedDataBlastWave.class, "blastWave"); - if(blastWave!=null) - { - IHLMod.explosionHandler.blastWaveByDimensionId.put(event.world.provider.dimensionId,blastWave); + public void onWorldLoadEvent(net.minecraftforge.event.world.WorldEvent.Load event) { + WorldSavedDataBlastWave blastWave = (WorldSavedDataBlastWave) event.world.mapStorage + .loadData(WorldSavedDataBlastWave.class, "blastWave"); + if (blastWave != null) { + IHLMod.explosionHandler.blastWaveByDimensionId.put(event.world.provider.dimensionId, blastWave); } } @SubscribeEvent - public void onWorldSaveEvent(net.minecraftforge.event.world.WorldEvent.Save event) - { - if(IHLMod.explosionHandler.blastWaveByDimensionId.containsKey(event.world.provider.dimensionId)) - { - event.world.mapStorage.setData("blastWave",IHLMod.explosionHandler.blastWaveByDimensionId.get(event.world.provider.dimensionId)); + public void onWorldSaveEvent(net.minecraftforge.event.world.WorldEvent.Save event) { + if (IHLMod.explosionHandler.blastWaveByDimensionId.containsKey(event.world.provider.dimensionId)) { + event.world.mapStorage.setData("blastWave", + IHLMod.explosionHandler.blastWaveByDimensionId.get(event.world.provider.dimensionId)); } } } diff --git a/ihl/explosion/DetonatorMiniGUI.java b/ihl/explosion/DetonatorMiniGUI.java index c969983..6a6c421 100644 --- a/ihl/explosion/DetonatorMiniGUI.java +++ b/ihl/explosion/DetonatorMiniGUI.java @@ -12,72 +12,70 @@ import ihl.IHLMod; import ihl.interfaces.ItemMiniGUI; import ihl.utils.IHLUtils; -public class DetonatorMiniGUI extends ItemMiniGUI -{ +public class DetonatorMiniGUI extends ItemMiniGUI { private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIIronWorkbench.png"); private int detonator_delay; private GuiTextField detonatorDelayTextField; private int xPos; private int yPos; - - public DetonatorMiniGUI(GuiContainer gui, Slot slot) - { + + public DetonatorMiniGUI(GuiContainer gui, Slot slot) { super(gui, slot); - detonator_delay=slot.getStack().stackTagCompound.getInteger("detonator_delay"); - xPos = this.slotBase.xDisplayPosition-18; - yPos = this.slotBase.yDisplayPosition+18; - detonatorDelayTextField=new GuiTextField(this.guiBase.mc.fontRenderer, xPos+78, yPos+3, 28, 11); + detonator_delay = slot.getStack().stackTagCompound.getInteger("detonator_delay"); + xPos = this.slotBase.xDisplayPosition - 18; + yPos = this.slotBase.yDisplayPosition + 18; + detonatorDelayTextField = new GuiTextField(this.guiBase.mc.fontRenderer, xPos + TEXT_BOX_POSX, + yPos + TEXT_BOX_POSY, TEXT_BOX_WIDTH, 11); detonatorDelayTextField.setText(Integer.toString(detonator_delay)); detonatorDelayTextField.setFocused(true); } @Override - public void displayGUI() - { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - this.guiBase.mc.renderEngine.bindTexture(background); - this.guiBase.drawTexturedModalRect(xPos, yPos, 0, 202, 126, 25); - int runnerXPos=xPos+5+114*detonator_delay/1350; - this.guiBase.drawTexturedModalRect(runnerXPos, yPos+18, 126, 202, 3, 5); - this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.detonator_delay"), xPos+3, yPos+4, 0xFFCC00); + public void displayGUI() { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.guiBase.mc.renderEngine.bindTexture(background); + this.guiBase.drawTexturedModalRect(xPos, yPos, 0, 202, 126, HEIGHT); + int runnerXPos = xPos + 5 + 114 * detonator_delay / 1350; + this.guiBase.drawTexturedModalRect(runnerXPos, yPos + 34, 126, 202, 3, 5); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.detonator_delay"), + xPos + 3, yPos + 4, 0xFFCC00); this.detonatorDelayTextField.drawTextBox(); - this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("s"), xPos+110, yPos+4, 0xFFCC00); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("s"), xPos + UNITS_LABEL_POSX, yPos + 18, + 0xFFCC00); } @Override - public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) - { - if(mouseX>=xPos+5 && mouseX<=xPos+119 && mouseY>=yPos+17 && mouseY<=yPos+24) - { - this.detonator_delay=Math.max(1, Math.min(1350,(mouseX-xPos-5)*1350/114)); + public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) { + if (mouseX >= xPos + 5 && mouseX <= xPos + 119 && mouseY >= yPos + RUNNER_POSY - 1 && mouseY <= yPos + HEIGHT) { + this.detonator_delay = Math.max(1, Math.min(1350, (mouseX - xPos - 5) * 1350 / 114)); this.detonatorDelayTextField.setText(Integer.toString(detonator_delay)); } - if(mouseX>=xPos+78 && mouseX<=xPos+78+28 && mouseY>=yPos+3 && mouseY<=yPos+3+11) - { + if (mouseX >= xPos + TEXT_BOX_POSX && mouseX <= xPos + TEXT_BOX_POSX + TEXT_BOX_WIDTH && mouseY >= yPos + 3 + && mouseY <= yPos + 3 + 11) { this.detonatorDelayTextField.setFocused(true); } - return mouseX>=xPos && mouseX<=xPos+202 && mouseY>=yPos && mouseY<=yPos+25; + return mouseX >= xPos && mouseX <= xPos + 202 && mouseY >= yPos && mouseY <= yPos + HEIGHT; } - + @Override - public boolean handleKeyTyped(char characterTyped, int keyIndex) - { - this.detonatorDelayTextField.textboxKeyTyped(characterTyped, keyIndex); - if(keyIndex==KeyEvent.VK_ACCEPT || keyIndex==KeyEvent.VK_ENTER || keyIndex==28 || keyIndex==156)//28 - enter;156 - numpad enter - { - this.detonator_delay=Math.max(1, Math.min(1350,(int)(IHLUtils.parseIntSafe(this.detonatorDelayTextField.getText(),this.detonator_delay)))); + public boolean handleKeyTyped(char characterTyped, int keyIndex) { + this.detonatorDelayTextField.textboxKeyTyped(characterTyped, keyIndex); + // 28 - enter; 156 - numpad enter + if (keyIndex == KeyEvent.VK_ACCEPT || keyIndex == KeyEvent.VK_ENTER || keyIndex == 28 || keyIndex == 156) { + this.detonator_delay = Math.max(1, Math.min(1350, + (int) (IHLUtils.parseIntSafe(this.detonatorDelayTextField.getText(), this.detonator_delay)))); this.detonatorDelayTextField.setText(Integer.toString(detonator_delay)); this.detonatorDelayTextField.setFocused(false); return true; - } + } return false; - } + } @Override - public void onGUIClosed() - { - IHLMod.proxy.sendItemStackNBTTagFromClientToServerPlayer(this.guiBase.mc.thePlayer, this.slotBase.slotNumber, "detonator_delay", this.detonator_delay); + public void onGUIClosed() { + IHLMod.proxy.sendItemStackNBTTagFromClientToServerPlayer(this.guiBase.mc.thePlayer, this.slotBase.slotNumber, + "detonator_delay", this.detonator_delay); } } diff --git a/ihl/explosion/ExplosionEntityFX.java b/ihl/explosion/ExplosionEntityFX.java index 38e1034..ffa91fa 100644 --- a/ihl/explosion/ExplosionEntityFX.java +++ b/ihl/explosion/ExplosionEntityFX.java @@ -45,7 +45,7 @@ public class ExplosionEntityFX extends EntityFX { this.lastTickPosZ=this.posZ=this.prevPosZ=this.center[2]=centerZ1; this.radius=radius1; float r2 = radius*radius; - int numParticles = (int)(r2*radius/32)+64; + int numParticles = Math.min((int)(r2*radius/32)+64,512); this.startPos = new double[numParticles][3]; this.pos = new double[numParticles][3]; this.prevPos = new double[numParticles][3]; diff --git a/ihl/explosion/ExplosionVectorBlockV2.java b/ihl/explosion/ExplosionVectorBlockV2.java index 4ccf638..4489e55 100644 --- a/ihl/explosion/ExplosionVectorBlockV2.java +++ b/ihl/explosion/ExplosionVectorBlockV2.java @@ -11,6 +11,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; + import java.util.Map.Entry; import net.minecraft.block.Block; @@ -26,527 +27,320 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; -public class ExplosionVectorBlockV2 -{ - public int[] startVectors = new int[1]; +public class ExplosionVectorBlockV2 { + final Set startVectors = new HashSet(); private final int[][] directionMasks = new int[8][3]; private final int bits = IHLMod.config.explosionVectorSizeBits; - private final int maxValue = (1<> cachedBlockDrops = new HashMap>(128); - public final List dropBlocksPos = new ArrayList(64); - public Set chunksToUpdate=new HashSet(64); - public Map cachedDrops = new HashMap(128); - public Set dropBlocks = new HashSet(); - public Map blastWaveByDimensionId = new HashMap(); - private Entity[] cachedEntities = new Entity[maxArraySize]; + private final int maxValue = (1 << bits) - 1; + private final int halfValue = (1 << bits - 1) - 1; + private final int maxArraySize = 1 << bits * 3; + private final int[][] vectors = new int[maxArraySize][2]; + private final Set chunksToUpdate = new HashSet(64); + private final Map cachedDrops = new HashMap(128); + final Map blastWaveByDimensionId = new HashMap(); + private final Map cachedEntities = new HashMap(); + public boolean isCalculating = false; - public ExplosionVectorBlockV2() - { + public ExplosionVectorBlockV2() { this.precalculateExplosion(); - directionMasks[0] = new int[] {1,1,1}; - directionMasks[1] = new int[] {-1,1,1}; - directionMasks[2] = new int[] {1,-1,1}; - directionMasks[3] = new int[] {1,1,-1}; - directionMasks[4] = new int[] {-1,-1,1}; - directionMasks[5] = new int[] {1,-1,-1}; - directionMasks[6] = new int[] {-1,1,-1}; - directionMasks[7] = new int[] {-1,-1,-1}; - Arrays.fill(cachedBlockHardness,-1); + startVectors.add(0); + directionMasks[0] = new int[] { 1, 1, 1 }; + directionMasks[1] = new int[] { -1, 1, 1 }; + directionMasks[2] = new int[] { 1, -1, 1 }; + directionMasks[3] = new int[] { 1, 1, -1 }; + directionMasks[4] = new int[] { -1, -1, 1 }; + directionMasks[5] = new int[] { 1, -1, -1 }; + directionMasks[6] = new int[] { -1, 1, -1 }; + directionMasks[7] = new int[] { -1, -1, -1 }; } - - private int encodeXYZ(int x, int y, int z) - { - return x<>bits*2,l>>bits&maxValue,l&maxValue}; + + private int[] decodeXYZ(int l) { + return new int[] { l >> bits * 2, l >> bits & maxValue, l & maxValue }; } - - public void precalculateExplosion() - { - startVectors[0]=0; - explosionPowerDampingFactor[0]=1f; - for(int levelRadius=1; levelRadiusMath.round(levelRadius*1.8f)) - { - pxyz[0]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[0]); - pxyz[1]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[1]); - pxyz[2]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[2]); - } - else if(Math.abs(pxyz[0])<=Math.abs(pxyz[1]) && Math.abs(pxyz[0])<=Math.abs(pxyz[2])) - { - pxyz[1]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[1]); - pxyz[2]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[2]); - } - else if(Math.abs(pxyz[1])<=Math.abs(pxyz[0]) && Math.abs(pxyz[1])<=Math.abs(pxyz[2])) - { - pxyz[0]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[0]); - pxyz[2]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[2]); + private void reduceCoordinate(int[] pxyz) { + + if (pxyz[0] >= pxyz[1] && pxyz[0] >= pxyz[2] && pxyz[0] > 0) { + pxyz[0]--; } - else if(Math.abs(pxyz[2])<=Math.abs(pxyz[0]) && Math.abs(pxyz[2])<=Math.abs(pxyz[1])) - { - pxyz[1]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[1]); - pxyz[0]=IHLUtils.reduceVariableByAbsoluteValue(pxyz[0]); + if (pxyz[1] >= pxyz[0] && pxyz[1] >= pxyz[2] && pxyz[1] > 0) { + pxyz[1]--; } - } - - public void setPower(int[] sv2, int power1) - { - for(int ev:sv2) - { - this.setPower(ev, power1); + if (pxyz[2] >= pxyz[1] && pxyz[2] >= pxyz[0] && pxyz[2] > 0) { + pxyz[2]--; } } - public void setPower(int ev, int power1) { - this.explosionPower[ev]=power1; - } - - public int[] breakBlocksAndGetDescendants(World world, int sourceX,int sourceY,int sourceZ, Explosion explosion, int ev, int[] directionMask) - { - int power1 = explosionPower[ev]; - power1 = this.getNewPowerAndProcessBlocks(world, ev, sourceX, sourceY, sourceZ, explosion, power1, directionMask); - power1 = (int)(power1*explosionPowerDampingFactor[ev])-1; - if(power1<=1 || this.vectors[ev][0]==0) - { - return null; - } - else - { - for(int d1:this.vectors[ev]) - { - if(d1!=0) - { - explosionPower[d1]=power1; + public void breakBlocksAndGetDescendants(World world, int sourceX, int sourceY, int sourceZ, Explosion explosion, + int ev, int power, int[] directionMask) { + power = this.getNewPowerAndProcessBlocks(world, ev, sourceX, sourceY, sourceZ, explosion, power, directionMask); + power = (int) (power * 0.94) - 1; + if (power > 1) { + if (this.vectors[ev][0] == 0) { + int[] xyz = decodeXYZ(ev); + int xb = xyz[0] >> bits - 1; + int yb = xyz[1] >> bits - 1; + int zb = xyz[2] >> bits - 1; + int hashb = xb << 2 | yb << 1 | zb; + xyz[0] -= xb * halfValue; + xyz[1] -= yb * halfValue; + xyz[2] -= zb * halfValue; + if (hashb == 0 || xb > 1 || yb > 1 || zb > 1) { + throw new ArithmeticException("End vectors shall be higher than half value"); + } + int ev2 = encodeXYZ(xyz[0], xyz[1], xyz[2]); + breakBlocksAndGetDescendants(world, sourceX + xb * halfValue * directionMask[0], + sourceY + yb * halfValue * directionMask[1], sourceZ + zb * halfValue * directionMask[2], + explosion, ev2, power, directionMask); + } else { + for (int d1 : this.vectors[ev]) { + if (d1 != 0) { + breakBlocksAndGetDescendants(world, sourceX, sourceY, sourceZ, explosion, d1, power, + directionMask); + } } } - return this.vectors[ev]; } - } - - private int getNewPowerAndProcessBlocks(World world, int ev, int sourceX, int sourceY, int sourceZ, Explosion explosion, int power2, int[] directionMask) - { - int power1=power2; + } + + private int getNewPowerAndProcessBlocks(World world, int ev, int sourceX, int sourceY, int sourceZ, + Explosion explosion, int power2, int[] directionMask) { + int power1 = power2; int[] xyz = decodeXYZ(ev); - int absX = xyz[0]*directionMask[0] + sourceX; - int absY = xyz[1]*directionMask[1] + sourceY; - int absZ = xyz[2]*directionMask[2] + sourceZ; - if(absY<0 || absY>=256) - { + int absX = xyz[0] * directionMask[0] + sourceX; + int absY = xyz[1] * directionMask[1] + sourceY; + int absZ = xyz[2] * directionMask[2] + sourceZ; + if (absY < 0 || absY >= 256) { return 0; } - int absEBSX = absX>>4; - int absEBSZ = absZ>>4; - if(world.getChunkProvider().chunkExists(absEBSX, absEBSZ)) - { - if(world.getChunkProvider().provideChunk(absEBSX, absEBSZ).getTopFilledSegment()+24>=absY) - { - int explosionResistance = this.getBlockResistance(world, ev, absX, absY, absZ, sourceX, sourceY, sourceZ, explosion, directionMask); - if(explosionResistance>=power1) - { - if(this.cachedFluidBlocks[ev]!=0) - { - //IHLMod.log.info("Schleduling update for "+Block.getBlockById(this.cachedFluidBlocks[ev]).getUnlocalizedName()); - Block block = Block.getBlockById(this.cachedFluidBlocks[ev]); - block.onNeighborBlockChange(world, absX, absY, absZ, block); - } - else - { - this.dropBlocksPos.add(new int[] {absX, absY+1, absZ}); - } - return 0; - } - else - { - power1-=explosionResistance; - this.onBlockDestroy(world, ev, absX, absY, absZ, power1, explosion); - return power1; - } - } - else - { + int absEBSX = absX >> 4; + int absEBSZ = absZ >> 4; + if (world.getChunkProvider().chunkExists(absEBSX, absEBSZ)) { + if (world.getChunkProvider().provideChunk(absEBSX, absEBSZ).getTopFilledSegment() + 24 >= absY) { + int remainingPower = this.tryDestroyBlock(world, absX, absY, absZ, sourceX, sourceY, sourceZ, power1, + explosion); + return remainingPower; + } else { return 0; } - } - else - { + } else { WorldSavedDataBlastWave blastWave = null; int dimensionId = world.provider.dimensionId; - if(this.blastWaveByDimensionId.containsKey(dimensionId)) - { - blastWave=this.blastWaveByDimensionId.get(dimensionId); - } - else - { - blastWave=new WorldSavedDataBlastWave("blastWave"); + if (this.blastWaveByDimensionId.containsKey(dimensionId)) { + blastWave = this.blastWaveByDimensionId.get(dimensionId); + } else { + blastWave = new WorldSavedDataBlastWave("blastWave"); this.blastWaveByDimensionId.put(dimensionId, blastWave); } - long chunkXZKey = ChunkCoordIntPair.chunkXZ2Int(absEBSX, absEBSZ); - blastWave.scheduleExplosionEffectsOnChunkLoad(chunkXZKey, ev, sourceX, sourceY, sourceZ, power1, directionMask); + long chunkXZKey = ChunkCoordIntPair.chunkXZ2Int(absEBSX, absEBSZ); + blastWave.scheduleExplosionEffectsOnChunkLoad(chunkXZKey, ev, sourceX, sourceY, sourceZ, power1, + directionMask); return 0; } } - - public int getBlockResistance(World world, int ev, int absX, int absY, int absZ, int sourceX, int sourceY, int sourceZ, Explosion explosion, int[] directionMask) - { - if(this.cachedBlockHardness[ev]!=-1) - { - return this.cachedBlockHardness[ev]; - } - else - { - this.precacheEBSBlocks(world, absX, absY, absZ, sourceX, sourceY, sourceZ, explosion, directionMask); - return this.cachedBlockHardness[ev]; - } - } - public void precacheEBSBlocks(World world, int absX, int absY, int absZ, int sourceX, int sourceY, int sourceZ, Explosion explosion, int[] directonMask) - { - Chunk chunk = world.getChunkProvider().provideChunk(absX>>4, absZ>>4); - List eList = this.getEntityList(chunk, absX, absY, absZ); - if(eList!=null) - { - Iterator eListI = eList.iterator(); - while(eListI.hasNext()) - { - Entity entity = eListI.next(); - int entityX = (int)entity.boundingBox.minX; - int entityY = (int)entity.boundingBox.minY; - int entityZ = (int)entity.boundingBox.minZ; - int rx = (entityX - sourceX) * directonMask[0]; - int ry = (entityY - sourceY) * directonMask[1]; - int rz = (entityZ - sourceZ) * directonMask[2]; - int ev = this.encodeXYZ(rx, ry, rz); - if(rx >= 0 && ry >= 0 && rz >= 0 && ev>=0 && ev> 4, absZ >> 4); ExtendedBlockStorage ebs = this.getEBS(chunk, absX, absY, absZ); - if(ebs==null) - { - for(int i4=0;i4<4096;i4++) - { - int blockWorldX = (i4 & 15)|(absX & 0xFFFFFFF0); - int blockWorldY = ((i4>>8) & 15)|(absY & 0xFFFFFFF0); - int blockWorldZ = ((i4>>4) & 15)|(absZ & 0xFFFFFFF0); - - int rx = (blockWorldX - sourceX) * directonMask[0]; - int ry = (blockWorldY - sourceY) * directonMask[1]; - int rz = (blockWorldZ - sourceZ) * directonMask[2]; - - int ev = this.encodeXYZ(rx, ry, rz); - if(rx >= 0 && ry >= 0 && rz >= 0 && ev>=0 && ev= 0) { + int array_index = (absY & 15) << 8 | (absZ & 15) << 4 | (absX & 15); + if (ebs.getBlockLSBArray()[array_index] != 0 && ebs.getBlockMSBArray() != null + && ebs.getBlockMSBArray().get(absX & 15, absY & 15, absZ & 15) != 0) { + ebs.blockRefCount--; + } + ebs.getBlockLSBArray()[array_index] = 0; + if (ebs.getBlockMSBArray() != null) { + ebs.getBlockMSBArray().set(absX & 15, absY & 15, absZ & 15, 0); + } + List dropsList = block.getDrops(world, absX, absY, absZ, + ebs.getExtBlockMetadata(absX & 15, absY & 15, absZ & 15), 0); + Iterator drops = dropsList.iterator(); + while (drops.hasNext()) { + ItemStack drop = drops.next(); + int key = Item.getIdFromItem(drop.getItem()) ^ (drop.getItemDamage() << 16); + if (this.cachedDrops.containsKey(key)) { + this.cachedDrops.get(key).stackSize += drop.stackSize; + } else { + this.cachedDrops.put(key, drop); + } + } + Entity[] entities = this.getFromOrCreateCache(world, ebs, absX, absY, absZ); + if (entities != null && entities[array_index] != null) { + entities[array_index].attackEntityFrom(DamageSource.setExplosionSource(explosion), power / 10f); + } + } else { + block.onNeighborBlockChange(world, absX, absY, absZ, block); + if ((++absY & 15) != 0) { + int array_index = (absY & 15) << 8 | (absZ & 15) << 4 | (absX & 15); + if (ebs.getBlockLSBArray()[array_index] == 0 && (ebs.getBlockMSBArray() == null + || ebs.getBlockMSBArray().get(absX & 15, absY & 15, absZ & 15) == 0)) { + this.placeDrops(world, absX, absY, absZ); + } + } } + return remainingPower; } } - else - { - byte[] lbsArray = ebs.getBlockLSBArray(); - for(int i4=0;i4>8) & 15, (i4>>4) & 15) << 8; - } - int blockWorldX = (i4 & 15)|(absX & 0xFFFFFFF0); - int blockWorldY = ((i4>>8) & 15)|(absY & 0xFFFFFFF0); - int blockWorldZ = ((i4>>4) & 15)|(absZ & 0xFFFFFFF0); - int rx = (blockWorldX - sourceX) * directonMask[0]; - int ry = (blockWorldY - sourceY) * directonMask[1]; - int rz = (blockWorldZ - sourceZ) * directonMask[2]; - - int ev = this.encodeXYZ(rx, ry, rz); - if(rx >= 0 && ry >= 0 && rz >= 0 && ev>=0 && ev dropsList = (block.getDrops(world, blockWorldX, blockWorldY, blockWorldZ, ebs.getExtBlockMetadata(i4 & 15, (i4>>8) & 15, (i4>>4) & 15), 0)); - if(dropsList!=null) - { - this.cachedBlockDrops.put(ev, dropsList); - } - } - if(block.getBlockHardness(world, blockWorldX, blockWorldY, blockWorldZ)<0) - { - this.cachedBlockHardness[ev]=Integer.MAX_VALUE; - } - else if(ev==0 && directonMask[0]+directonMask[1]+directonMask[2]==3) - { - this.cachedBlockHardness[ev]=0; - } - else - { - int br=Math.round(block.getExplosionResistance(null, world, blockWorldX, blockWorldY, blockWorldZ, sourceX, sourceY, sourceZ)*10f); - this.cachedBlockHardness[ev]=br; - } - if(block.getMaterial().isLiquid()) - { - this.cachedFluidBlocks[ev]=var4; - } + } + + public Entity[] getFromOrCreateCache(World world, ExtendedBlockStorage ebs, int absX, int absY, int absZ) { + Entity[] entities = this.cachedEntities.get(ebs); + if (entities == null) { + Chunk chunk = world.getChunkProvider().provideChunk(absX >> 4, absZ >> 4); + List eList = this.getEntityList(chunk, absX, absY, absZ); + if (eList != null && !eList.isEmpty()) { + entities = new Entity[4096]; + Iterator eListI = eList.iterator(); + this.cachedEntities.put(ebs, entities); + while (eListI.hasNext()) { + Entity entity = eListI.next(); + int entityX = (int) entity.boundingBox.minX; + int entityY = (int) entity.boundingBox.minY; + int entityZ = (int) entity.boundingBox.minZ; + int rx = entityX & 15; + int ry = entityY & 15; + int rz = entityZ & 15; + int array_index = ry << 8 | rz << 4 | rx; + entities[array_index] = entity; } } } - } - - public ExtendedBlockStorage getEBS(Chunk chunk, int absX, int absY, int absZ) - { + return entities; + } + + public ExtendedBlockStorage getEBS(Chunk chunk, int absX, int absY, int absZ) { ExtendedBlockStorage[] ebsA = chunk.getBlockStorageArray(); - ExtendedBlockStorage ebs = ebsA[absY>>4]; - if(ebs!=null) - { + ExtendedBlockStorage ebs = ebsA[absY >> 4]; + if (ebs != null) { this.chunksToUpdate.add(chunk); } return ebs; } @SuppressWarnings("unchecked") - public List getEntityList(Chunk chunk, int absX, int absY, int absZ) - { - return chunk.entityLists[absY>>4]; + public List getEntityList(Chunk chunk, int absX, int absY, int absZ) { + return chunk.entityLists[absY >> 4]; } - - public void onBlockDestroy(World world, int ev, int absX,int absY,int absZ, int power, Explosion explosion) - { - Chunk chunk = world.getChunkProvider().provideChunk(absX>>4, absZ>>4); - ExtendedBlockStorage ebs = this.getEBS(chunk, absX, absY, absZ); - if(ebs==null || ebs.isEmpty()) - { - return; - } - int array_index = (absY & 15)<<8 | (absZ & 15)<<4 | (absX & 15); - if(ebs.getBlockLSBArray()[array_index] != 0 && - ebs.getBlockMSBArray()!=null && - ebs.getBlockMSBArray().get(absX & 15, absY & 15, absZ & 15) != 0) - { - ebs.blockRefCount--; - } - ebs.getBlockLSBArray()[array_index] = 0; - if(ebs.getBlockMSBArray()!=null){ - ebs.getBlockMSBArray().set(absX & 15, absY & 15, absZ & 15, 0); - } - if(this.cachedBlockDrops.containsKey(ev)) - { - Iterator drops = this.cachedBlockDrops.remove(ev).iterator(); - while(drops.hasNext()) - { - ItemStack drop = drops.next(); - int key = Item.getIdFromItem(drop.getItem())^(drop.getItemDamage()<<16); - if(this.cachedDrops.containsKey(key)) - { - this.cachedDrops.get(key).stackSize+=drop.stackSize; - } - else - { - this.cachedDrops.put(key, drop); - } - } - } - Entity victim = this.cachedEntities[ev]; - if(victim!=null) - { - victim.attackEntityFrom(DamageSource.setExplosionSource(explosion), power/10f); - this.cachedEntities[ev]=null; - } - this.dropBlocks.add(ev); - } - - private void addDrops(World world, int sourceX, int sourceY, int sourceZ, int[] directionMask) - { + private void placeDrops(World world, int x, int y, int z) { Iterator> di = this.cachedDrops.entrySet().iterator(); - Entry cde = di.next(); - while(di.hasNext() && this.dropBlocksPos.size() > 0) - { - int[] xyz = this.dropBlocksPos.remove(this.dropBlocksPos.size()-1); - int x = xyz[0]; - int y = xyz[1]; - int z = xyz[2]; - int rx = (x - sourceX) * directionMask[0]; - int ry = (y - sourceY) * directionMask[1]; - int rz = (z - sourceZ) * directionMask[2]; - int ev = encodeXYZ(rx,ry,rz); - int ev2 = encodeXYZ(rx,ry-1,rz); - if(this.dropBlocks.contains(ev) && !this.dropBlocks.contains(ev2)) - { - ItemStack stack = cde.getValue(); - if(stack!=null && stack.getItem()!=null && stack.stackSize>0) - { - if(stack.stackSize <= stack.getMaxStackSize()) - { - if(stack.stackSize>0) - { - PileTileEntity pte = new PileTileEntity(); - pte.xCoord=x; - pte.yCoord=y; - pte.zCoord=z; - pte.setWorldObj(world); - pte.validate(); - pte.setContent(stack); - IHLUtils.setBlockAndTileEntityRaw(world, x, y, z, PileBlock.instance, pte); - } - di.remove(); - if(di.hasNext()) - { - cde = di.next(); - } - else - { - return; - } - } - else - { - ItemStack stack1=stack.copy(); - stack1.stackSize=stack.getMaxStackSize(); - PileTileEntity pte = new PileTileEntity(); - pte.content=stack1; - IHLUtils.setBlockAndTileEntityRaw(world, x, y, z, PileBlock.instance, pte); - stack.stackSize-=stack.getMaxStackSize(); + if (di.hasNext()) { + Entry cde = di.next(); + ItemStack stack = cde.getValue(); + if (stack != null && stack.getItem() != null && stack.stackSize > 0) { + if (stack.stackSize <= stack.getMaxStackSize()) { + if (stack.stackSize > 0) { + PileTileEntity pte = new PileTileEntity(); + pte.xCoord = x; + pte.yCoord = y; + pte.zCoord = z; + pte.setWorldObj(world); + pte.validate(); + pte.setContent(stack); + IHLUtils.setBlockAndTileEntityRaw(world, x, y, z, PileBlock.instance, pte); } + di.remove(); + } else { + ItemStack stack1 = stack.copy(); + stack1.stackSize = stack.getMaxStackSize(); + PileTileEntity pte = new PileTileEntity(); + pte.content = stack1; + IHLUtils.setBlockAndTileEntityRaw(world, x, y, z, PileBlock.instance, pte); + stack.stackSize -= stack.getMaxStackSize(); } } } } - - public void sendChunkUpdateToPlayersInExplosionAffectedZone(World world, int sourceX, int sourceY, int sourceZ) - { -// Set clientSideChunkXZKeySet = new HashSet(); + + public void sendChunkUpdateToPlayersInExplosionAffectedZone(World world, int sourceX, int sourceY, int sourceZ) { Iterator ci = this.chunksToUpdate.iterator(); - while(ci.hasNext()) - { + while (ci.hasNext()) { Chunk chunk = ci.next(); chunk.generateSkylightMap(); Arrays.fill(chunk.updateSkylightColumns, true); chunk.func_150804_b(false); -// long chunkXZKey = ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition); -// clientSideChunkXZKeySet.add(chunkXZKey); } List chunks = new ArrayList(); chunks.addAll(this.chunksToUpdate); - for(Object player:world.playerEntities) - { - if(player instanceof EntityPlayerMP) - { - EntityPlayerMP playerMP = (EntityPlayerMP)player; + for (Object player : world.playerEntities) { + if (player instanceof EntityPlayerMP) { + EntityPlayerMP playerMP = (EntityPlayerMP) player; playerMP.playerNetServerHandler.sendPacket(new S26PacketMapChunkBulk(chunks)); } } -// IHLMod.proxy.sendChunksLightUpdateQuery(world, sourceX, sourceY, sourceZ, clientSideChunkXZKeySet); this.chunksToUpdate.clear(); } - public void doExplosion(World world, int sourceX, int sourceY, int sourceZ, final int[] startVectors1, int[] directionMask, Explosion explosion) - { - boolean doExplosion=true; - int[] sv = null; - int svsize = 0; - while(doExplosion) - { - int[] sv2= new int[1< startVectors1, + int startPower, int[] directionMask, Explosion explosion) { + for (int sv : startVectors1) { + this.breakBlocksAndGetDescendants(world, sourceX - (directionMask[0] < 0 ? 1 : 0), + sourceY - (directionMask[1] < 0 ? 1 : 0), sourceZ - (directionMask[2] < 0 ? 1 : 0), explosion, sv, + startPower, directionMask); } // Free and clean resources - this.cachedBlockDrops.clear(); this.cachedDrops.clear(); - this.dropBlocks.clear(); - this.dropBlocksPos.clear(); - Arrays.fill(cachedBlockHardness,-1); - Arrays.fill(cachedFluidBlocks,0); - } + this.cachedEntities.clear(); + } - public void doExplosion(World world, int sourceX, int sourceY, int sourceZ, final int[] startVectors1) - { + public void doExplosion(World world, int sourceX, int sourceY, int sourceZ, final Set startVectors1, + int startPower) { IHLMod.log.info("Starting explosion server"); + isCalculating = true; Explosion explosion = new Explosion(world, null, sourceX, sourceY, sourceZ, 100f); - for(int[] directionMask:directionMasks) - { - this.doExplosion(world, sourceX, sourceY, sourceZ, startVectors1, directionMask, explosion); + for (int[] directionMask : directionMasks) { + this.doExplosion(world, sourceX, sourceY, sourceZ, startVectors1, startPower, directionMask, explosion); } sendChunkUpdateToPlayersInExplosionAffectedZone(world, sourceX, sourceY, sourceZ); + isCalculating = false; } } \ No newline at end of file diff --git a/ihl/explosion/ExplosiveBlock.java b/ihl/explosion/ExplosiveBlock.java index 446b177..5943be2 100644 --- a/ihl/explosion/ExplosiveBlock.java +++ b/ihl/explosion/ExplosiveBlock.java @@ -50,12 +50,12 @@ public class ExplosiveBlock extends Block implements ITileEntityProvider{ ItemStack result = new ItemStack(item); result.stackTagCompound=new NBTTagCompound(); result.stackTagCompound.setInteger("explosionType", 1);//0 - IC2; 1- IHL - result.stackTagCompound.setInteger("explosionPower", 100); + result.stackTagCompound.setInteger("explosionPower", 31000); itemList.add(result); result = new ItemStack(item); result.stackTagCompound=new NBTTagCompound(); result.stackTagCompound.setInteger("explosionType", 1);//0 - IC2; 1- IHL - result.stackTagCompound.setInteger("explosionPower", 31000);//31000 + result.stackTagCompound.setInteger("explosionPower", Integer.MAX_VALUE);//31000 itemList.add(result); } diff --git a/ihl/explosion/ExplosiveTileEntity.java b/ihl/explosion/ExplosiveTileEntity.java index 002c959..cfae646 100644 --- a/ihl/explosion/ExplosiveTileEntity.java +++ b/ihl/explosion/ExplosiveTileEntity.java @@ -4,82 +4,75 @@ import ic2.core.IC2; import ihl.IHLMod; import ihl.utils.IHLMathUtils; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.oredict.OreDictionary; public class ExplosiveTileEntity extends TileEntity { - - public int explosionPower=10000; - private int explosionType=1; - private int detonator_delay=1; - private int burn_time=0; - public boolean is_detonator_burning = false; + public int explosionPower = 10000; + private int explosionType = 1; + private int detonator_delay = 1; + private int burn_time = 0; + public boolean is_detonator_burning = false; - public void createExplosion(EntityPlayer player) - { + public void createExplosion(EntityPlayer player) { this.invalidate(); - int power = this.explosionPower; - this.explosionPower = 0; - IHLMod.explosionHandler.setPower(IHLMod.explosionHandler.startVectors, power); - IHLMod.explosionHandler.doExplosion(worldObj, xCoord, yCoord, zCoord, IHLMod.explosionHandler.startVectors); - IHLMod.proxy.createExplosionEffectFromServer(worldObj, xCoord, yCoord, zCoord, 32f*IHLMathUtils.sqrt(power/16384f)); + int power = this.explosionPower; + this.explosionPower = 0; + IHLMod.explosionHandler.doExplosion(worldObj, xCoord, yCoord, zCoord, IHLMod.explosionHandler.startVectors, + power); + IHLMod.proxy.createExplosionEffectFromServer(worldObj, xCoord, yCoord, zCoord, + 32f * IHLMathUtils.sqrt(power / 16384f)); } - + @Override - public boolean canUpdate() - { + public boolean canUpdate() { return IC2.platform.isSimulating(); } - + @Override - public void updateEntity() - { - if(is_detonator_burning) - { - IHLMod.proxy.spawnParticleFromServer(4, worldObj, xCoord+0.5d, yCoord+1d, zCoord+0.5d, 0d, 0.2d, 0d, 1f); - if(this.burn_time++>detonator_delay*20) - { + public void updateEntity() { + if (is_detonator_burning) { + IHLMod.proxy.spawnParticleFromServer(4, worldObj, xCoord + 0.5d, yCoord + 1d, zCoord + 0.5d, 0d, 0.2d, 0d, + 1f); + if (this.burn_time++ > detonator_delay * 20) { this.createExplosion(null); } } } - + @Override - public void readFromNBT(NBTTagCompound nbt) - { - if(nbt!=null) - { - explosionPower=nbt.getInteger("explosionPower"); - explosionType=nbt.getInteger("explosionType"); - detonator_delay=nbt.getInteger("detonator_delay"); + public void readFromNBT(NBTTagCompound nbt) { + if (nbt != null) { + explosionPower = nbt.getInteger("explosionPower"); + explosionType = nbt.getInteger("explosionType"); + detonator_delay = nbt.getInteger("detonator_delay"); } } - + @Override - public void writeToNBT(NBTTagCompound nbt) - { - nbt.setInteger("explosionPower",explosionPower); - nbt.setInteger("explosionType",explosionType); - nbt.setInteger("detonator_delay",detonator_delay); + public void writeToNBT(NBTTagCompound nbt) { + nbt.setInteger("explosionPower", explosionPower); + nbt.setInteger("explosionType", explosionType); + nbt.setInteger("detonator_delay", detonator_delay); } - public boolean ignite(EntityPlayer player) - { - if(player!=null && - player.getCurrentEquippedItem()!=null && - player.getCurrentEquippedItem().getItem()==Items.flint_and_steel) - { - ignite(); - return true; + public boolean ignite(EntityPlayer player) { + if (player != null && player.getCurrentEquippedItem() != null) { + for (int oid : OreDictionary.getOreIDs(player.getCurrentEquippedItem())) { + if (OreDictionary.getOreName(oid).matches("toolLighter")) { + ignite(); + return true; + } + } } return false; } - - public void ignite() - { - IHLMod.proxy.playSoundEffectFromServer(0, this.worldObj, this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 10.0F, 1.0F); - this.is_detonator_burning=true; + + public void ignite() { + IHLMod.proxy.playSoundEffectFromServer(0, this.worldObj, this.xCoord + 0.5D, this.yCoord + 0.5D, + this.zCoord + 0.5D, 10.0F, 1.0F); + this.is_detonator_burning = true; } } diff --git a/ihl/explosion/PileTileEntity.java b/ihl/explosion/PileTileEntity.java index b6046db..67f430a 100644 --- a/ihl/explosion/PileTileEntity.java +++ b/ihl/explosion/PileTileEntity.java @@ -11,46 +11,37 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -public class PileTileEntity extends TileEntity -{ +public class PileTileEntity extends TileEntity { public ItemStack content = new ItemStack(Blocks.sandstone); private boolean firstTick = true; - + @Override - public boolean canUpdate() - { + public boolean canUpdate() { return IC2.platform.isRendering(); } - + @Override - public void updateEntity() - { - if(firstTick && this.content!=null) - { - if(this.worldObj.isRemote) - { + public void updateEntity() { + if (firstTick && this.content != null) { + if (this.worldObj.isRemote) { IHLMod.proxy.requestTileEntityInitdataFromClientToServer(xCoord, yCoord, zCoord); - } - else - { + } else { checkAndFall(); } firstTick = false; } } - - public void setContent(ItemStack other) - { - this.content=other; + + public void setContent(ItemStack other) { + this.content = other; } - - public boolean checkAndFall() - { - Block underblock = this.worldObj.getBlock(xCoord, yCoord-1, zCoord); - if(underblock.isAir(worldObj, xCoord, yCoord-1, zCoord) || underblock==Blocks.air || underblock.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord-1, zCoord)==null) - { + + public boolean checkAndFall() { + Block underblock = this.worldObj.getBlock(xCoord, yCoord - 1, zCoord); + if (underblock.isAir(worldObj, xCoord, yCoord - 1, zCoord) || underblock == Blocks.air + || underblock.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord - 1, zCoord) == null) { IHLEntityFallingPile fallingPile = new IHLEntityFallingPile(worldObj); - fallingPile.setPosition(xCoord+0.5d, yCoord+0.5d, zCoord+0.5d); + fallingPile.setPosition(xCoord + 0.5d, yCoord + 0.5d, zCoord + 0.5d); fallingPile.setEntityItemStack(content); this.worldObj.setBlockToAir(xCoord, yCoord, zCoord); this.worldObj.spawnEntityInWorld(fallingPile); @@ -60,32 +51,28 @@ public class PileTileEntity extends TileEntity } @Override - public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - this.content = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("content")); - } + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + this.content = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("content")); + } - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - NBTTagCompound contentNBT = new NBTTagCompound(); - this.content.writeToNBT(contentNBT); - nbttagcompound.setTag("content", contentNBT); - } + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + NBTTagCompound contentNBT = new NBTTagCompound(); + this.content.writeToNBT(contentNBT); + nbttagcompound.setTag("content", contentNBT); + } - public void updateBlockRender() - { + public void updateBlockRender() { Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } - + @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) - { + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); - Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(xCoord, yCoord, zCoord); - } + if (checkAndFall()) { + Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + } } - - diff --git a/ihl/flexible_cable/IronWorkbenchTileEntity.java b/ihl/flexible_cable/IronWorkbenchTileEntity.java index 73a3eb1..d21b4c9 100644 --- a/ihl/flexible_cable/IronWorkbenchTileEntity.java +++ b/ihl/flexible_cable/IronWorkbenchTileEntity.java @@ -33,192 +33,166 @@ import ihl.recipes.RecipeInputDie; import ihl.recipes.RecipeInputObjectInstance; import ihl.utils.IHLUtils; -public class IronWorkbenchTileEntity extends TileEntityInventory implements IHasGui, INetworkClientTileEntityEventListener, INetworkTileEntityEventListener{ +public class IronWorkbenchTileEntity extends TileEntityInventory + implements IHasGui, INetworkClientTileEntityEventListener, INetworkTileEntityEventListener { public static List recipes = new ArrayList(); public int progress; - public int currentSlot=-1; + public int currentSlot = -1; public final int maxProgress; - public final InvSlotTool tools; - public final InvSlotWorkspaceElement workspaceElements; - public final InvSlotProcessableIronWorkbench inputMaterial; - public final InvSlotOutputInProgress output; - public boolean isGuiScreenOpened=false; - private boolean startProcess=false; - private boolean outputDefined=false; + public final InvSlotTool tools; + public final InvSlotWorkspaceElement workspaceElements; + public final InvSlotProcessableIronWorkbench inputMaterial; + public final InvSlotOutputInProgress output; + public boolean isGuiScreenOpened = false; + private boolean startProcess = false; + private boolean outputDefined = false; private EntityPlayer crafter; public ContainerBase container; private Map slotRecipeMap = new HashMap(); private boolean firstTick = true; - - public IronWorkbenchTileEntity() - { - this.maxProgress=80; - this.workspaceElements = new InvSlotWorkspaceElement(this, "workspaceElements", 3, Access.NONE, 6); - this.tools=new InvSlotTool(this, "tools", 0, Access.IO, 12); - this.inputMaterial=new InvSlotProcessableIronWorkbench(this, "input", 1, Access.IO, 12); - this.output=new InvSlotOutputInProgress(this, "output", 2, 18); - } - - public static void addRecipe(IronWorkbenchRecipe recipe) - { - IronWorkbenchTileEntity.recipes.add(recipe); - } - + + public IronWorkbenchTileEntity() { + this.maxProgress = 80; + this.workspaceElements = new InvSlotWorkspaceElement(this, "workspaceElements", 3, Access.NONE, 6); + this.tools = new InvSlotTool(this, "tools", 0, Access.IO, 12); + this.inputMaterial = new InvSlotProcessableIronWorkbench(this, "input", 1, Access.IO, 12); + this.output = new InvSlotOutputInProgress(this, "output", 2, 18); + } + + public static void addRecipe(IronWorkbenchRecipe recipe) { + IronWorkbenchTileEntity.recipes.add(recipe); + } + @Override - public String getInventoryName() - { + public String getInventoryName() { return "ironWorkbench"; } - @Override - public ItemStack getWrenchDrop(EntityPlayer player) - { + public ItemStack getWrenchDrop(EntityPlayer player) { return IHLUtils.getThisModItemStack("ironWorkbench"); } - + @Override @SideOnly(Side.CLIENT) - public void updateEntityClient() - { - if(firstTick) - { + public void updateEntityClient() { + if (firstTick) { IHLMod.proxy.requestTileEntityInitdataFromClientToServer(xCoord, yCoord, zCoord); - this.firstTick=false; + this.firstTick = false; } } - + @Override - public void updateEntityServer() - { - if(this.isGuiScreenOpened) - { - if(this.output.isEmpty() && !outputDefined) - { + public void updateEntityServer() { + if (this.isGuiScreenOpened) { + if (this.output.isEmpty() && !outputDefined) { this.workspaceElements.reset(); - Iterator iwri=IronWorkbenchTileEntity.recipes.iterator(); - while(iwri.hasNext()) - { + Iterator iwri = IronWorkbenchTileEntity.recipes.iterator(); + while (iwri.hasNext()) { IronWorkbenchRecipe recipe = iwri.next(); - if(recipe.isCanBeCrafted(this.tools.getItemStackList(), this.inputMaterial.getItemStackList(), this.workspaceElements.getItemStackList())) - { - if(recipe.workspaceElements==null || recipe.workspaceElements.isEmpty() || this.workspaceElements.containsAndCanUse(recipe.workspaceElements)) - { + if (recipe.isCanBeCrafted(this.tools.getItemStackList(), this.inputMaterial.getItemStackList(), + this.workspaceElements.getItemStackList())) { + if (recipe.workspaceElements == null || recipe.workspaceElements.isEmpty() + || this.workspaceElements.containsAndCanUse(recipe.workspaceElements)) { List newOutputs = recipe.outputs; - for(IRecipeInput rinput:recipe.tools) - { - if(rinput instanceof RecipeInputDie) - { - newOutputs = ((RecipeInputDie)rinput).transformOutput(this.getMatchedItemStack(rinput),recipe.outputs); + for (IRecipeInput rinput : recipe.tools) { + if (rinput instanceof RecipeInputDie) { + newOutputs = ((RecipeInputDie) rinput) + .transformOutput(this.getMatchedItemStack(rinput), recipe.outputs); } } - for(IRecipeInput rinput:recipe.materials) - { - if(rinput instanceof RecipeInputDetonator) - { - newOutputs = ((RecipeInputDetonator)rinput).transformOutput(this.getMatchedItemStack(rinput),recipe.outputs); + for (IRecipeInput rinput : recipe.materials) { + if (rinput instanceof RecipeInputDetonator) { + newOutputs = ((RecipeInputDetonator) rinput) + .transformOutput(this.getMatchedItemStack(rinput), recipe.outputs); } } int slot = this.output.put(newOutputs); - if(slot<0)break; + if (slot < 0) + break; slotRecipeMap.put(slot, recipe); - this.startProcess=false; + this.startProcess = false; } } } - for(int i=0; i list = this.getListOfSameWires(stack); ItemStack result = stack.copy(); result.stackTagCompound.setInteger("length", fullLength); result.stackTagCompound.setInteger("fullLength", fullLength); - IronWorkbenchRecipe recipe = new IronWorkbenchRecipe(null, list, Arrays.asList(new ItemStack[] {result})); + IronWorkbenchRecipe recipe = new IronWorkbenchRecipe(null, list, + Arrays.asList(new ItemStack[] { result })); int slot = this.output.put(recipe.outputs); - if(slot<0)break; + if (slot < 0) + break; slotRecipeMap.put(slot, recipe); - this.startProcess=false; + this.startProcess = false; break; } } - outputDefined=true; - } - else if(!this.output.isEmpty()) - { + outputDefined = true; + } else if (!this.output.isEmpty()) { Set crafterEmptyInventorySlotsList = getCrafterEmptyInventorySlotsList(); - if(startProcess && crafterEmptyInventorySlotsList.size()>=this.slotRecipeMap.get(currentSlot).outputs.size()) - { - if(++this.progress>=this.maxProgress) - { - IronWorkbenchRecipe crecipe = this.slotRecipeMap.get(currentSlot); - List opts = this.output.getRecipeOutputs(currentSlot); - int multiplier = this.inputMaterial.getMultiplier(crecipe.materials); - Iterator optsi = opts.iterator(); - Iterator emptySlotsIterator = crafterEmptyInventorySlotsList.iterator(); - while(optsi.hasNext()) - { - int slot = emptySlotsIterator.next(); - ItemStack stack = optsi.next(); - if(stack.getItem() instanceof IWire) - { - this.crafter.inventory.mainInventory[slot]=IHLUtils.getWireItemStackCopyWithLengthMultiplied(stack,multiplier); - } - else - { - this.crafter.inventory.mainInventory[slot]=stack.copy(); - this.crafter.inventory.mainInventory[slot].stackSize*=multiplier; - } + if (startProcess && crafterEmptyInventorySlotsList.size() >= this.slotRecipeMap.get(currentSlot).outputs + .size()) { + if (++this.progress >= this.maxProgress) { + IronWorkbenchRecipe crecipe = this.slotRecipeMap.get(currentSlot); + List opts = this.output.getRecipeOutputs(currentSlot); + int multiplier = this.inputMaterial.getMultiplier(crecipe.materials); + Iterator optsi = opts.iterator(); + Iterator emptySlotsIterator = crafterEmptyInventorySlotsList.iterator(); + while (optsi.hasNext()) { + int slot = emptySlotsIterator.next(); + ItemStack stack = optsi.next(); + if (stack.getItem() instanceof IWire) { + this.crafter.inventory.mainInventory[slot] = IHLUtils + .getWireItemStackCopyWithLengthMultiplied(stack, multiplier); + } else { + this.crafter.inventory.mainInventory[slot] = stack.copy(); + this.crafter.inventory.mainInventory[slot].stackSize *= multiplier; } - Iterator emptyContainers = this.inputMaterial.substract(crecipe.materials, multiplier).iterator(); - while(emptyContainers.hasNext()) - { - if(emptySlotsIterator.hasNext()) - { - int slot = emptySlotsIterator.next(); - ItemStack stack = emptyContainers.next(); - this.crafter.inventory.mainInventory[slot]=stack.copy(); - this.crafter.inventory.mainInventory[slot].stackSize*=multiplier; - } - else - { - EntityItem eistack = new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, emptyContainers.next()); - this.worldObj.spawnEntityInWorld(eistack); - } - } - this.crafter.inventoryContainer.detectAndSendChanges(); - this.tools.damage(crecipe.tools); - if(!crecipe.workspaceElements.isEmpty()) - { - this.workspaceElements.use(crecipe.workspaceElements); + } + Iterator emptyContainers = this.inputMaterial + .substract(crecipe.materials, multiplier).iterator(); + while (emptyContainers.hasNext()) { + if (emptySlotsIterator.hasNext()) { + int slot = emptySlotsIterator.next(); + ItemStack stack = emptyContainers.next(); + this.crafter.inventory.mainInventory[slot] = stack.copy(); + this.crafter.inventory.mainInventory[slot].stackSize *= multiplier; + } else { + EntityItem eistack = new EntityItem(this.worldObj, this.xCoord, this.yCoord + 1, + this.zCoord, emptyContainers.next()); + this.worldObj.spawnEntityInWorld(eistack); } - this.resetOutput(); } + this.crafter.inventoryContainer.detectAndSendChanges(); + this.tools.damage(crecipe.tools); + if (!crecipe.workspaceElements.isEmpty()) { + this.workspaceElements.use(crecipe.workspaceElements); + } + this.resetOutput(); } + } } } } - private ItemStack getMatchedItemStack(IRecipeInput rinput) - { - for(ItemStack tool:this.tools.getItemStackList()) - { - if(rinput.matches(tool)) - { + private ItemStack getMatchedItemStack(IRecipeInput rinput) { + for (ItemStack tool : this.tools.getItemStackList()) { + if (rinput.matches(tool)) { return tool; } } - for(ItemStack material:this.inputMaterial.getItemStackList()) - { - if(rinput.matches(material)) - { + for (ItemStack material : this.inputMaterial.getItemStackList()) { + if (rinput.matches(material)) { return material; } } @@ -226,46 +200,38 @@ public class IronWorkbenchTileEntity extends TileEntityInventory implements IHas return null; } - private Set getCrafterEmptyInventorySlotsList() - { + private Set getCrafterEmptyInventorySlotsList() { Set list = new HashSet(4); - if(this.crafter!=null) - { - for (int var1 = 0; var1 < this.crafter.inventory.mainInventory.length; ++var1) - { - if (this.crafter.inventory.mainInventory[var1] == null) - { - list.add(var1); - } - } + if (this.crafter != null) { + for (int var1 = 0; var1 < this.crafter.inventory.mainInventory.length; ++var1) { + if (this.crafter.inventory.mainInventory[var1] == null) { + list.add(var1); + } + } } return list; } - - private List getListOfSameWires(ItemStack stack1) { - List list = new ArrayList(); - for(int i=0; i getListOfSameWires(ItemStack stack1) { + List list = new ArrayList(); + for (int i = 0; i < this.inputMaterial.size(); i++) { ItemStack stack = this.inputMaterial.get(i); - if(stack!=null && ((IWire)stack1.getItem()).isSameWire(stack1, stack)) - { + if (stack != null && ((IWire) stack1.getItem()).isSameWire(stack1, stack)) { list.add(new RecipeInputObjectInstance(stack)); } } - return list; + return list; } private int getFullLengthOfSameWires(ItemStack stack1) { - int fullLength=0; - for(int i=0; i getGuiContainer(EntityPlayer player) { resetOutput(); - this.isGuiScreenOpened=true; - this.crafter=player; + this.isGuiScreenOpened = true; + this.crafter = player; container = new IronWorkbenchContainer(player, this); return container; } @Override - public void onGuiClosed(EntityPlayer arg0) - { - this.isGuiScreenOpened=false; + public void onGuiClosed(EntityPlayer arg0) { + this.isGuiScreenOpened = false; } @Override - public void onNetworkEvent(EntityPlayer player, int event) - { - if(event==16) - { - this.isGuiScreenOpened=false; - this.crafter=null; - this.container=null; + public void onNetworkEvent(EntityPlayer player, int event) { + if (event == 16) { + this.isGuiScreenOpened = false; + this.crafter = null; + this.container = null; return; } - for(int i=event;i>=0;i--) - { - if(this.slotRecipeMap.containsKey(i)) - { - if(!this.slotRecipeMap.get(i).isCanBeCrafted(this.tools.getItemStackList(), this.inputMaterial.getItemStackList(), this.workspaceElements.getItemStackList())) - { + for (int i = event; i >= 0; i--) { + if (this.slotRecipeMap.containsKey(i)) { + if (!this.slotRecipeMap.get(i).isCanBeCrafted(this.tools.getItemStackList(), + this.inputMaterial.getItemStackList(), this.workspaceElements.getItemStackList())) { resetOutput(); - } - else - { - this.currentSlot=i; - this.startProcess=true; + } else { + this.currentSlot = i; + this.startProcess = true; return; } } } } - public void resetOutput() - { + public void resetOutput() { this.output.clear(); this.slotRecipeMap.clear(); - this.progress=0; - this.startProcess=false; - this.currentSlot=-1; - this.outputDefined=false; + this.progress = 0; + this.startProcess = false; + this.currentSlot = -1; + this.outputDefined = false; } - public void dropContents() { - for(int i=0;i recipeOutputsItems) - { + public static void removeRecipeByOutput(List recipeOutputsItems) { Iterator ri = recipes.iterator(); - while(ri.hasNext()) - { + while (ri.hasNext()) { IronWorkbenchRecipe recipe = ri.next(); - boolean removeEntry=false; + boolean removeEntry = false; Iterator roi = recipe.outputs.iterator(); - while(roi.hasNext()) - { - if(IHLUtils.isItemStacksIsEqual(recipeOutputsItems.get(0), roi.next(), true)) - { - removeEntry=true; + while (roi.hasNext()) { + if (IHLUtils.isItemStacksIsEqual(recipeOutputsItems.get(0), roi.next(), true)) { + removeEntry = true; } } - if(removeEntry) - { + if (removeEntry) { ri.remove(); } } } - public static void removeRecipeByInput(List recipeInputsTools1,List recipeInputsItems1,List recipeInputsMachines) { + public static void removeRecipeByInput(List recipeInputsTools1, List recipeInputsItems1, + List recipeInputsMachines) { List recipeInputsTools = IHLUtils.convertRecipeInputToItemStackList(recipeInputsTools1); List recipeInputsItems = IHLUtils.convertRecipeInputToItemStackList(recipeInputsItems1); Iterator ri = recipes.iterator(); - while(ri.hasNext()) - { + while (ri.hasNext()) { IronWorkbenchRecipe recipe = ri.next(); - if(recipe.isCanBeCrafted(recipeInputsTools, recipeInputsItems, recipeInputsMachines)) - { + if (recipe.isCanBeCrafted(recipeInputsTools, recipeInputsItems, recipeInputsMachines)) { ri.remove(); } } } - + @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) - { + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); - } + } } diff --git a/ihl/flexible_cable/SetOfDiesMiniGUI.java b/ihl/flexible_cable/SetOfDiesMiniGUI.java index 43f905d..6a94abb 100644 --- a/ihl/flexible_cable/SetOfDiesMiniGUI.java +++ b/ihl/flexible_cable/SetOfDiesMiniGUI.java @@ -12,72 +12,69 @@ import ihl.IHLMod; import ihl.interfaces.ItemMiniGUI; import ihl.utils.IHLUtils; -public class SetOfDiesMiniGUI extends ItemMiniGUI -{ +public class SetOfDiesMiniGUI extends ItemMiniGUI { private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIIronWorkbench.png"); private int transverseSectionValue; private GuiTextField transverseSectionTextField; private int xPos; private int yPos; - - public SetOfDiesMiniGUI(GuiContainer gui, Slot slot) - { + + public SetOfDiesMiniGUI(GuiContainer gui, Slot slot) { super(gui, slot); - transverseSectionValue=slot.getStack().stackTagCompound.getInteger("transverseSection"); - xPos = this.slotBase.xDisplayPosition-18; - yPos = this.slotBase.yDisplayPosition+18; - transverseSectionTextField=new GuiTextField(this.guiBase.mc.fontRenderer, xPos+78, yPos+3, 28, 11); - transverseSectionTextField.setText(Float.toString(transverseSectionValue/10f)); + transverseSectionValue = slot.getStack().stackTagCompound.getInteger("transverseSection"); + xPos = this.slotBase.xDisplayPosition - 18; + yPos = this.slotBase.yDisplayPosition + 18; + transverseSectionTextField = new GuiTextField(this.guiBase.mc.fontRenderer, xPos + TEXT_BOX_POSX, yPos + TEXT_BOX_POSY, TEXT_BOX_WIDTH, + 11); + transverseSectionTextField.setText(Float.toString(transverseSectionValue / 10f)); transverseSectionTextField.setFocused(true); } @Override - public void displayGUI() - { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - this.guiBase.mc.renderEngine.bindTexture(background); - this.guiBase.drawTexturedModalRect(xPos, yPos, 0, 202, 126, 25); - int runnerXPos=xPos+5+114*transverseSectionValue/1350; - this.guiBase.drawTexturedModalRect(runnerXPos, yPos+18, 126, 202, 3, 5); - this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.transversesection"), xPos+3, yPos+4, 0xFFCC00); + public void displayGUI() { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.guiBase.mc.renderEngine.bindTexture(background); + this.guiBase.drawTexturedModalRect(xPos, yPos, 0, 202, 126, HEIGHT); + int runnerXPos = xPos + 5 + 114 * transverseSectionValue / 1350; + this.guiBase.drawTexturedModalRect(runnerXPos, yPos + RUNNER_POSY, 126, 202, 3, 5); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.transversesection"), + xPos + 3, yPos + 4, 0xFFCC00); this.transverseSectionTextField.drawTextBox(); - this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("mm\u00B2"), xPos+110, yPos+4, 0xFFCC00); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("mm\u00B2"), xPos + UNITS_LABEL_POSX, + yPos + 18, 0xFFCC00); } @Override - public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) - { - if(mouseX>=xPos+5 && mouseX<=xPos+119 && mouseY>=yPos+17 && mouseY<=yPos+24) - { - this.transverseSectionValue=Math.max(1, Math.min(1350,(mouseX-xPos-5)*1350/114)); - this.transverseSectionTextField.setText(Float.toString(transverseSectionValue/10f)); + public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) { + if (mouseX >= xPos + 5 && mouseX <= xPos + 119 && mouseY >= yPos + RUNNER_POSY - 1 && mouseY <= yPos + HEIGHT) { + this.transverseSectionValue = Math.max(1, Math.min(1350, (mouseX - xPos - 5) * 1350 / 114)); + this.transverseSectionTextField.setText(Float.toString(transverseSectionValue / 10f)); } - if(mouseX>=xPos+78 && mouseX<=xPos+78+28 && mouseY>=yPos+3 && mouseY<=yPos+3+11) - { + if (mouseX >= xPos + TEXT_BOX_POSX && mouseX <= xPos + TEXT_BOX_POSX + TEXT_BOX_WIDTH && mouseY >= yPos + TEXT_BOX_POSY && mouseY <= yPos + TEXT_BOX_POSY + 11) { this.transverseSectionTextField.setFocused(true); } - return mouseX>=xPos && mouseX<=xPos+202 && mouseY>=yPos && mouseY<=yPos+25; + return mouseX >= xPos && mouseX <= xPos + 202 && mouseY >= yPos && mouseY <= yPos + HEIGHT; } - + @Override - public boolean handleKeyTyped(char characterTyped, int keyIndex) - { - this.transverseSectionTextField.textboxKeyTyped(characterTyped, keyIndex); - if(keyIndex==KeyEvent.VK_ACCEPT || keyIndex==KeyEvent.VK_ENTER || keyIndex==28 || keyIndex==156)//28 - enter;156 - numpad enter - { - this.transverseSectionValue=Math.max(1, Math.min(1350,(int)(IHLUtils.parseFloatSafe(this.transverseSectionTextField.getText(),this.transverseSectionValue)*10f))); - this.transverseSectionTextField.setText(Float.toString(transverseSectionValue/10f)); + public boolean handleKeyTyped(char characterTyped, int keyIndex) { + this.transverseSectionTextField.textboxKeyTyped(characterTyped, keyIndex); + // 28 - enter; 156 - numpad enter + if (keyIndex == KeyEvent.VK_ACCEPT || keyIndex == KeyEvent.VK_ENTER || keyIndex == 28 || keyIndex == 156) { + this.transverseSectionValue = Math.max(1, Math.min(1350, (int) (IHLUtils + .parseFloatSafe(this.transverseSectionTextField.getText(), this.transverseSectionValue) * 10f))); + this.transverseSectionTextField.setText(Float.toString(transverseSectionValue / 10f)); this.transverseSectionTextField.setFocused(false); return true; - } + } return false; - } + } @Override - public void onGUIClosed() - { - IHLMod.proxy.sendItemStackNBTTagFromClientToServerPlayer(this.guiBase.mc.thePlayer, this.slotBase.slotNumber, "transverseSection", this.transverseSectionValue); + public void onGUIClosed() { + IHLMod.proxy.sendItemStackNBTTagFromClientToServerPlayer(this.guiBase.mc.thePlayer, this.slotBase.slotNumber, + "transverseSection", this.transverseSectionValue); } } diff --git a/ihl/guidebook/IHLGuidebookContainer.java b/ihl/guidebook/IHLGuidebookContainer.java deleted file mode 100644 index 4510dcd..0000000 --- a/ihl/guidebook/IHLGuidebookContainer.java +++ /dev/null @@ -1,30 +0,0 @@ -package ihl.guidebook; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Slot; -import ic2.core.ContainerBase; - -public class IHLGuidebookContainer extends ContainerBase -{ - public IHLGuidebookInventory box; - public int xSize=256; - public int ySize=211; - - public IHLGuidebookContainer(EntityPlayer entityPlayer, IHLGuidebookInventory box) - { - super(box); - this.box = box; - int col; - for (col = 0; col < 4; ++col) - { - this.addSlotToContainer(new Slot(box, col, 18 + col * 18, 20)); - } - } - - @Override - public void onContainerClosed(EntityPlayer entityPlayer) - { - this.box.onGuiClosed(entityPlayer); - super.onContainerClosed(entityPlayer); - } -} diff --git a/ihl/guidebook/IHLGuidebookGui.java b/ihl/guidebook/IHLGuidebookGui.java deleted file mode 100644 index 316660b..0000000 --- a/ihl/guidebook/IHLGuidebookGui.java +++ /dev/null @@ -1,276 +0,0 @@ -package ihl.guidebook; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.lwjgl.opengl.GL11; -import org.xml.sax.SAXException; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -import ihl.IHLMod; -import ihl.datanet.GuiInvisibleButton; -import ihl.utils.IHLRenderUtils; - -public class IHLGuidebookGui extends GuiContainer -{ - public IHLGuidebookContainer container; - private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIGuidebook.png"); - public Map linksCoordinatesMap = new HashMap(); - private String title; - private String[] localisedContent=new String[2];;// By text block and row - private ResourceLocation[] resourceLocationCache = new ResourceLocation[16];//By section number - private int currentSection=0; - private final int titleX=25; - private final int titleY=7; - private final int textBlockWidth=104; - private final int textBlockX1=20; - private final int textBlockY1=38; - private final int textBlockX2=130; - private final int textBlockY2=5; - private final int textBlockMaxY=200; - private int stringHeight=10; - private int textRowInNextPage=0; - private int textBlockInNextPage=0; - private int[] textRowStart=new int[2]; - private int textBlockStart=0; - private int pictureWidth; - private int pictureHeight; - private int maxSection=0; - - public IHLGuidebookGui(IHLGuidebookContainer container1) { - super(container1); - this.container = container1; - this.xSize=this.container.xSize; - this.ySize=this.container.ySize; - } - - @Override - public void initGui() - { - super.initGui(); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - new GuiInvisibleButton(0, x, y, xSize/2, 162, linksCoordinatesMap, buttonList); - new GuiInvisibleButton(1, x+xSize/2, y, xSize/2, 162, linksCoordinatesMap, buttonList); - this.clear(); - try { - IHLMod.xmlparser.setupGuidebookGUI(this, 0); - } catch (SAXException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void actionPerformed(GuiButton button) - { - super.actionPerformed(button); - switch(button.id) - { - case 0: - currentSection--; - if(currentSection<0) - { - currentSection=this.maxSection; - } - this.textBlockStart=0; - this.textRowStart[0]=0; - this.textRowStart[1]=0; - break; - case 1: - if(textRowInNextPage==0 && textBlockInNextPage==0) - { - currentSection++; - this.textBlockStart=0; - this.textRowStart[0]=0; - this.textRowStart[1]=0; - } - else - { - this.textBlockStart=textBlockInNextPage; - this.textRowStart[textBlockStart]=textRowInNextPage; - textRowInNextPage=0; - textBlockInNextPage=0; - } - break; - } - this.clear(); - try { - IHLMod.xmlparser.setupGuidebookGUI(this, currentSection); - } catch (SAXException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void clear() - { - for(int i=0;i splittedText = IHLRenderUtils.instance.splitStringByWidth(this.localisedContent[0], Math.round(textBlockWidth)); - for(int i1=this.textRowStart[0]; i1 < splittedText.size(); i1++) - { - yPos+=stringHeight; - if(yPos splittedText = IHLRenderUtils.instance.splitStringByWidth(this.localisedContent[1], Math.round(textBlockWidth)); - for(int i1=this.textRowStart[1]; i1 < splittedText.size(); i1++) - { - yPos+=stringHeight; - if(yPos getGuiContainer(EntityPlayer player) { - return new IHLGuidebookContainer(player, this); - } - - @Override - public String getInventoryName() { - return "IHLGuidebook"; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean isItemValidForSlot(int arg0, ItemStack stack) { - return false; - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - - @Override - public ItemStack getStackInSlot(int slotNumber) { - return content[slotNumber]; - } - - @Override - public void setInventorySlotContents(int arg0, ItemStack arg1) - { - } - - @Override - public void closeInventory() { - // TODO Auto-generated method stub - - } - - @Override - public ItemStack decrStackSize(int arg0, int arg1) { - // TODO Auto-generated method stub - return null; - } - - @Override - public int getSizeInventory() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public ItemStack getStackInSlotOnClosing(int arg0) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer arg0) { - // TODO Auto-generated method stub - return true; - } - - @Override - public void markDirty() { - // TODO Auto-generated method stub - - } - - @Override - public void openInventory() { - // TODO Auto-generated method stub - - } - - @Override - public void onGuiClosed(EntityPlayer arg0) { - // TODO Auto-generated method stub - - } - - public boolean isThisContainer(ItemStack stack) - { - return this.thisItemStack.equals(stack); - } -} diff --git a/ihl/guidebook/IHLGuidebookItem.java b/ihl/guidebook/IHLGuidebookItem.java deleted file mode 100644 index e616455..0000000 --- a/ihl/guidebook/IHLGuidebookItem.java +++ /dev/null @@ -1,63 +0,0 @@ -package ihl.guidebook; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import ic2.core.IC2; -import ic2.core.IHasGui; -import ic2.core.item.IHandHeldInventory; -import ihl.IHLCreativeTab; -import ihl.IHLModInfo; - -public class IHLGuidebookItem extends Item implements IHandHeldInventory{ - - public IHLGuidebookItem() { - super(); - this.setUnlocalizedName("guidebook"); - this.setCreativeTab(IHLCreativeTab.tab); - this.maxStackSize=1; - this.setCreativeTab(IHLCreativeTab.tab); - this.setMaxDamage(0); - } - - public static void init() - { - GameRegistry.registerItem(new IHLGuidebookItem(), "guidebook"); - } - - @Override - public IHasGui getInventory(EntityPlayer entityPlayer, ItemStack itemStack) - { - return new IHLGuidebookInventory(entityPlayer, itemStack); - } - - @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) - { - if (IC2.platform.isSimulating()) - { - IC2.platform.launchGui(entityPlayer, this.getInventory(entityPlayer, itemStack)); - } - return itemStack; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) - { - itemIcon=register.registerIcon(IHLModInfo.MODID + ":guidebook"); - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) - { - return false; - } - -} diff --git a/ihl/guidebook/IHLGuidebookSlot.java b/ihl/guidebook/IHLGuidebookSlot.java deleted file mode 100644 index b945ae3..0000000 --- a/ihl/guidebook/IHLGuidebookSlot.java +++ /dev/null @@ -1,20 +0,0 @@ -package ihl.guidebook; - -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class IHLGuidebookSlot extends Slot -{ - IHLGuidebookInventory inventory; - public IHLGuidebookSlot(IHLGuidebookInventory arg0, int arg1, int arg2, int arg3) - { - super(arg0, arg1, arg2, arg3); - inventory=arg0; - } - - @Override - public boolean isItemValid(ItemStack itemstack) - { - return false; - } -} diff --git a/ihl/handpump/AdvancedHandPump.java b/ihl/handpump/AdvancedHandPump.java index c655391..e9b8bf8 100644 --- a/ihl/handpump/AdvancedHandPump.java +++ b/ihl/handpump/AdvancedHandPump.java @@ -28,7 +28,6 @@ import ic2.core.Ic2Items; import ic2.core.util.LiquidUtil; import ihl.IHLModInfo; import ihl.IHLMod; -import ihl.i_hate_liquids.XYZ; import ihl.utils.IHLUtils; import ihl.worldgen.ores.IHLFluid; @@ -79,11 +78,11 @@ public class AdvancedHandPump extends IHLHandPump { { fluid1 = ((BlockFluidBase)block).drain(world, blockXYZ.x, blockXYZ.y, blockXYZ.z, false); } - else if(block==Blocks.water||block==Blocks.flowing_water||block==IHLMod.flowing_water) + else if(block==Blocks.water||block==Blocks.flowing_water) { fluid1 = new FluidStack(FluidRegistry.WATER, 1000); } - else if(block==Blocks.lava||block==Blocks.flowing_lava||block==IHLMod.flowing_lava) + else if(block==Blocks.lava||block==Blocks.flowing_lava) { fluid1 = new FluidStack(FluidRegistry.LAVA, 1000); } diff --git a/ihl/handpump/BlockWithCoordinates.java b/ihl/handpump/BlockWithCoordinates.java index 0cdc965..d934b35 100644 --- a/ihl/handpump/BlockWithCoordinates.java +++ b/ihl/handpump/BlockWithCoordinates.java @@ -1,6 +1,5 @@ package ihl.handpump; -import ihl.IHLMod; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; @@ -27,7 +26,7 @@ public boolean setMetadataOrDestroyBlock(World world, int meta, int maxMeta) { return world.setBlockToAir(x, y, z); } - else if(isWaterBlock() && IHLMod.cccFiniteWater) + else if(isWaterBlock()) { if(world.setBlock(x,y,z,Blocks.flowing_water,meta,3)) { @@ -36,24 +35,6 @@ public boolean setMetadataOrDestroyBlock(World world, int meta, int maxMeta) } return false; } - else if(isWaterBlock()) - { - if(world.setBlock(x,y,z,IHLMod.flowing_water,meta,3)) - { - world.scheduleBlockUpdate(x,y,z,IHLMod.flowing_water,2); - return true; - } - return false; - } - else if(isLavaBlock() && world.provider.isHellWorld && !IHLMod.cccFiniteWater) - { - if(world.setBlock(x,y,z,IHLMod.flowing_lava,meta,3)) - { - world.scheduleBlockUpdate(x,y,z,IHLMod.flowing_lava,2); - return true; - } - return false; - } else if(isLavaBlock()) { if(world.setBlock(x,y,z,Blocks.flowing_lava,meta,3)) @@ -71,11 +52,11 @@ public boolean isSameTypeBlock(World world, int x2, int y2, int z2) Block block2 = world.getBlock(x2, y2, z2); if(isWaterBlock()) { - return block2==Blocks.water||block2==Blocks.flowing_water||block2==IHLMod.flowing_water; + return block2==Blocks.water||block2==Blocks.flowing_water; } else if(isLavaBlock()) { - return block2==Blocks.lava||block2==Blocks.flowing_lava||block2==IHLMod.flowing_lava; + return block2==Blocks.lava||block2==Blocks.flowing_lava; } else { @@ -85,7 +66,7 @@ public boolean isSameTypeBlock(World world, int x2, int y2, int z2) public boolean isWaterBlock() { - if(block==Blocks.water||block==Blocks.flowing_water||block==IHLMod.flowing_water) + if(block==Blocks.water||block==Blocks.flowing_water) { return true; } @@ -94,7 +75,7 @@ public boolean isWaterBlock() public boolean isLavaBlock() { - if(block==Blocks.lava||block==Blocks.flowing_lava||block==IHLMod.flowing_lava) + if(block==Blocks.lava||block==Blocks.flowing_lava) { return true; } diff --git a/ihl/handpump/XYZ.java b/ihl/handpump/XYZ.java new file mode 100644 index 0000000..9a2627e --- /dev/null +++ b/ihl/handpump/XYZ.java @@ -0,0 +1,26 @@ +package ihl.handpump; + +public class XYZ { + public int x; + public int y; + public int z; + + public XYZ(int x1,int y1,int z1) + { + this.x=x1; + this.y=y1; + this.z=z1; + } + + @Override + public boolean equals(Object obj) + { + if(obj instanceof XYZ) + { + XYZ xyz2 = (XYZ) obj; + return (this.x==xyz2.x && this.y==xyz2.y && this.z==xyz2.z); + } + return false; + } + +} diff --git a/ihl/i_hate_liquids/BlockDynamicLiquidPlus.java b/ihl/i_hate_liquids/BlockDynamicLiquidPlus.java deleted file mode 100644 index ed8ddac..0000000 --- a/ihl/i_hate_liquids/BlockDynamicLiquidPlus.java +++ /dev/null @@ -1,80 +0,0 @@ -package ihl.i_hate_liquids; - -import java.util.Random; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ihl.IHLModInfo; -import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlockDynamicLiquidPlus extends BlockLiquid{ - - public BlockDynamicLiquidPlus(Material material) - { - super(material); - this.enableStats = false; - //this.setCreativeTab(CreativeTabs.tabMisc); - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) - { - this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID+":metalShards"); - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - return this.blockIcon; - } - - @Override - public void updateTick(World world, int x, int y, int z, Random p_149674_5_) - { - if(!world.isRemote) - { - int meta = world.getBlockMetadata(x, y, z); - if(meta>=7) - { - world.setBlockToAir(x,y,z); - return; - } - int meta2=16; - int fd; - int xz[] = {0,-1,0,1,0}; - for(int i=0;i<=3;i++) - { - fd=getFlowDecay(world,x+xz[i], y, z+xz[i+1]); - if(fd!=-1 && meta2>fd) - { - meta2=fd; - } - } - if(meta2==16) - { - world.setBlockMetadataWithNotify(x,y,z,meta+1,3); - } - else if(meta2>=6) - { - world.setBlockToAir(x,y,z); - return; - } - else - { - world.setBlockMetadataWithNotify(x,y,z,meta2+1,3); - } - world.scheduleBlockUpdate(x, y, z, this,20); - } - } - - private int getFlowDecay(World par1World, int par2, int par3, int par4) - { - Block block = par1World.getBlock(par2, par3, par4); - return block.getMaterial().isLiquid() ? par1World.getBlockMetadata(par2, par3, par4) : -1; - } -} diff --git a/ihl/i_hate_liquids/IHLBucketHandler.java b/ihl/i_hate_liquids/IHLBucketHandler.java deleted file mode 100644 index d8a9943..0000000 --- a/ihl/i_hate_liquids/IHLBucketHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -package ihl.i_hate_liquids; - -import ihl.items_blocks.IHLFluidBlock; -import net.minecraft.block.Block; -import net.minecraftforge.event.entity.player.FillBucketEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class IHLBucketHandler -{ - public IHLBucketHandler() {} - @SubscribeEvent - public void onBucketFill(FillBucketEvent event) - { - Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ); - if (block instanceof IHLFluidBlock && event.isCancelable()) - { - event.setCanceled(true); - } - } - -} diff --git a/ihl/i_hate_liquids/IHLEventHandler.java b/ihl/i_hate_liquids/IHLEventHandler.java deleted file mode 100644 index cd777ed..0000000 --- a/ihl/i_hate_liquids/IHLEventHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -package ihl.i_hate_liquids; - -import net.minecraft.block.Block; -import net.minecraft.world.World; -import net.minecraftforge.event.world.BlockEvent.BreakEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class IHLEventHandler { - - public IHLEventHandler() {} - - - @SubscribeEvent - public void onBlockBreak(BreakEvent event) - { - World world = event.world; - if(!world.isRemote) - { - int x = event.x; - int y = event.y; - int z = event.z; - Block block = world.getBlock(x, y+1, z); - if(block.getMaterial().isLiquid()) - { - InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z); - world.spawnEntityInWorld(im); - return; - } - block = world.getBlock(x+1, y, z); - if(block.getMaterial().isLiquid()) - { - InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z); - world.spawnEntityInWorld(im); - return; - } - block = world.getBlock(x-1, y, z); - if(block.getMaterial().isLiquid()) - { - InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z); - world.spawnEntityInWorld(im); - return; - } - block = world.getBlock(x, y, z+1); - if(block.getMaterial().isLiquid()) - { - InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z); - world.spawnEntityInWorld(im); - return; - } - block = world.getBlock(x, y, z-1); - if(block.getMaterial().isLiquid()) - { - InvisibleMagicanEntity im = new InvisibleMagicanEntity(world, x, y, z); - world.spawnEntityInWorld(im); - return; - } - } - } -} diff --git a/ihl/i_hate_liquids/InvisibleMagicanEntity.java b/ihl/i_hate_liquids/InvisibleMagicanEntity.java deleted file mode 100644 index 2ad56d3..0000000 --- a/ihl/i_hate_liquids/InvisibleMagicanEntity.java +++ /dev/null @@ -1,458 +0,0 @@ -package ihl.i_hate_liquids; - -import java.util.ArrayList; -import java.util.List; - -import ihl.IHLMod; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraftforge.fluids.IFluidBlock; - -public class InvisibleMagicanEntity extends Entity { - private int entityAge=0; - private int viscosityTimer=0; - private int viscosity=5; - public int x0=0; - public int y0=0; - public int z0=0; - public List flowXYZ = new ArrayList(); - public List blockList = new ArrayList(); - private Block block; - private int lowestPointsCounter=0; - - public InvisibleMagicanEntity(World arg0) - { - super(arg0); - this.isImmuneToFire=true; - this.noClip=true; - this.setSize(0F, 0F); - } - - public InvisibleMagicanEntity(World arg0, int x, int y, int z) - { - super(arg0); - this.x0=x; - this.y0=y; - this.z0=z; - this.setPosition(x, y, z); - this.isImmuneToFire=true; - this.noClip=true; - this.setSize(0F, 0F); - } - - @Override - public void onUpdate() - { - if(!this.worldObj.isRemote) - { - if(this.blockList.isEmpty()) - { - if(!takeLowestPoint()) - { - this.setDead(); - return; - } - else - { - if(this.block!=null) - { - if(this.block==Blocks.water||this.block==Blocks.flowing_water) - { - this.viscosity=-1; - } - else if(this.block instanceof IFluidBlock) - { - IFluidBlock bf = (IFluidBlock) this.block; - if(bf.getFluid()!=null && bf.getFluid().getViscosity()>600) - { - this.viscosity=bf.getFluid().getViscosity()/300; - } - } - else if(this.block.getMaterial()==Material.lava) - { - this.viscosity=20; - } - else - { - this.viscosity=20; - } - } - else - { - this.entityAge++; - } - } - } - else - { - if(this.viscosityTimer < this.viscosity) - { - this.viscosityTimer++; - } - else - { - this.viscosityTimer=0; - XYZ xyz; - if(!this.flowXYZ.isEmpty()) - { - xyz = this.flowXYZ.remove(0); - if(this.flowXYZ.isEmpty()) - { - Block block1=this.blockList.get(0); - //System.out.println("Trying to create new source"); - if(this.setBlock(xyz.x, xyz.y, xyz.z, block1)) - { - this.blockList.remove(0); - //System.out.println("Creating new source at "+xyz.x+","+xyz.y+","+xyz.z); - } - else - { - //System.out.println("Failed to create new source!"); - } - if(!takeLowestPoint()) - { - this.setDead(); - return; - } - } - else - { - Block blockToReplace = this.worldObj.getBlock(xyz.x, xyz.y, xyz.z); - if(blockToReplace==null || blockToReplace.isAir(worldObj, xyz.x, xyz.y, xyz.z) || blockToReplace.getMaterial().isLiquid() || blockToReplace==Blocks.snow_layer || blockToReplace==Blocks.vine || blockToReplace==Blocks.tallgrass || blockToReplace==Blocks.deadbush) - { - if(this.flowXYZ.size()<=this.blockList.size()) - { - Block block1=this.blockList.get(0); - if(this.setBlock(xyz.x, xyz.y, xyz.z, block1)) - { - this.blockList.remove(0); - //System.out.println("Creating new source at "+xyz.x+","+xyz.y+","+xyz.z); - } - } - else - { - if(!this.setNonSourceBlock(xyz.x, xyz.y, xyz.z, block)) - { - //System.out.println("Failed to setNonSourceBlock at "+xyz.x+","+xyz.y+","+xyz.z); - } - } - } - else - { - this.flowXYZ.clear(); - } - } - } - } - } - if(this.lowestPointsCounter > this.blockList.size()) - { - this.searchSourceDestroyCount(worldObj, this.x0, this.y0, this.z0, block, this.lowestPointsCounter); - if(!this.blockList.isEmpty()) - { - this.block=this.blockList.get(0); - } - } - if(this.entityAge>200) - { - this.setDead(); - return; - } - } - } - - @Override - protected void entityInit() {} - - @Override - protected void readEntityFromNBT(NBTTagCompound arg0) {} - - @Override - protected void writeEntityToNBT(NBTTagCompound arg0) {} - - private int getFlowDecay(int par2, int par3, int par4) - { - Block block = this.worldObj.getBlock(par2, par3, par4); - return block.getMaterial().isLiquid() ? this.worldObj.getBlockMetadata(par2, par3, par4) : -1; - } - - public boolean replaceBlock(int x,int y,int z, Block block) - { - if(!IHLMod.cccFiniteWater&&(block==Blocks.flowing_water || block==Blocks.water)) - { - if(this.worldObj.setBlock(x,y,z,IHLMod.flowing_water,6,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z,IHLMod.flowing_water,10); - return true; - } - return false; - } - else - if(!IHLMod.cccFiniteWater&&this.worldObj.provider.isHellWorld&&(block==Blocks.flowing_lava || block==Blocks.lava)) - { - if(this.worldObj.setBlock(x,y,z,IHLMod.flowing_lava,6,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z,IHLMod.flowing_lava,10); - return true; - } - return false; - } - else - { - if(this.worldObj.setBlockMetadataWithNotify(x, y, z, 6,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z,this.worldObj.getBlock(x, y, z),10); - return true; - } - return false; - } - } - - public boolean setNonSourceBlock(int x,int y,int z,Block block) - { - if(block==Blocks.flowing_water || block==Blocks.water) - { - if(this.worldObj.setBlock(x,y,z,Blocks.flowing_water,1,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z,Blocks.flowing_water,80); - return true; - } - return false; - } - else - if(block==Blocks.flowing_lava || block==Blocks.lava) - { - if(this.worldObj.setBlock(x,y,z,Blocks.flowing_lava,1,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z,Blocks.flowing_lava,80); - return true; - } - return false; - } - else - { - if(this.worldObj.setBlock(x, y, z, block, 1,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z, block ,80); - return true; - } - return false; - } - } - - public boolean setBlock(int x,int y,int z, Block block) - { - if(block==Blocks.flowing_water || block==Blocks.water) - { - if(this.worldObj.setBlock(x,y,z,Blocks.flowing_water,0,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z,Blocks.flowing_water,20); - return true; - } - return false; - } - else - if(block==Blocks.flowing_lava || block==Blocks.lava) - { - if(this.worldObj.setBlock(x,y,z,Blocks.flowing_lava,0,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z,Blocks.flowing_lava,20); - return true; - } - return false; - } - else - { - if(this.worldObj.setBlock(x,y,z,block,0,3)) - { - this.worldObj.scheduleBlockUpdate(x,y,z,block,20); - return true; - } - return false; - } - } - - private boolean takeLowestPoint() - { - int xz[]={0,1,0,-1,0}; - Block block; - int x=x0; - int y=y0; - int z=z0; - List list = new ArrayList(); - this.flowXYZ.clear(); - for(int thread=0;thread<=256;thread++) - { - - long number = new Long(x*256L*256L+y*256L+z); - list.add(number); - boolean skip=false; - block = this.worldObj.getBlock(x, y-1, z); - number = new Long(x*256L*256L+(y-1)*256L+z); - if((block.isAir(this.worldObj, x, y-1, z)||getFlowDecay(x, y-1, z)>=1) && !list.contains(number)) - { - y--; - this.lowestPointsCounter=1; - skip=true; - } - if(!skip) - { - for(int i=0;i<=3;i++) - { - block = this.worldObj.getBlock(x+xz[i], y, z+xz[i+1]); - number = new Long((x+xz[i])*256L*256L+y*256L+z+xz[i+1]); - if((block.isAir(this.worldObj, x+xz[i], y, z+xz[i+1])||getFlowDecay(x+xz[i], y, z+xz[i+1])>=1) && !list.contains(number)) - { - x+=xz[i]; - z+=xz[i+1]; - skip=true; - this.lowestPointsCounter++; - break; - } - } - } - XYZ xyz=new XYZ(x,y,z); - this.flowXYZ.add(xyz); - if(!skip) - { - break; - } - } - if(y=0) - { - starty++; - currentFlowDecay=getFlowDecay(world, startx, starty, startz); - } - - else if(getFlowDecay(world, startx+1, starty+1, startz)>=0) - { - starty++; - startx++; - currentFlowDecay=getFlowDecay(world, startx, starty, startz); - } - - else if(getFlowDecay(world, startx-1, starty+1, startz)>=0) - { - starty++; - startx--; - currentFlowDecay=getFlowDecay(world, startx, starty, startz); - } - - else if(getFlowDecay(world, startx, starty+1, startz+1)>=0) - { - starty++; - startz++; - currentFlowDecay=getFlowDecay(world, startx, starty, startz); - } - - else if(getFlowDecay(world, startx, starty+1, startz-1)>=0) - { - starty++; - startz--; - currentFlowDecay=getFlowDecay(world, startx, starty, startz); - } - //Start checking neighbor blocks to lower flow decay. - else if(getFlowDecay(world, startx-1, starty, startz) xyzlist = new ArrayList(); - if(currentFlowDecay==0) - { - xyzlist.add(new XYZ(startx, starty, startz)); - Block block=worldObj.getBlock(startx, starty, startz); - replaceBlock(startx, starty, startz, block); - this.blockList.add(block); - int listPos=0; - for(int i=0;i<=countCells;i++) - { - if(getFlowDecay(world, startx-1, starty, startz)==0 && !xyzlist.contains(new XYZ(startx-1, starty, startz))) - { - startx--; - xyzlist.add(new XYZ(startx, starty, startz)); - listPos=xyzlist.size()-1; - block=worldObj.getBlock(startx, starty, startz); - replaceBlock(startx, starty, startz, block); - this.blockList.add(block); - } - else if(getFlowDecay(world, startx, starty, startz+1)==0 && !xyzlist.contains(new XYZ(startx, starty, startz+1))) - { - startz++; - xyzlist.add(new XYZ(startx, starty, startz)); - listPos=xyzlist.size()-1; - block=worldObj.getBlock(startx, starty, startz); - replaceBlock(startx, starty, startz, block); - this.blockList.add(block); - } - else if(getFlowDecay(world, startx, starty, startz-1)==0 && !xyzlist.contains(new XYZ(startx, starty, startz-1))) - { - startz--; - xyzlist.add(new XYZ(startx, starty, startz)); - listPos=xyzlist.size()-1; - block=worldObj.getBlock(startx, starty, startz); - replaceBlock(startx, starty, startz, block); - this.blockList.add(block); - } - else if(getFlowDecay(world, startx+1, starty, startz)==0 && !xyzlist.contains(new XYZ(startx+1, starty, startz))) - { - startx++; - xyzlist.add(new XYZ(startx, starty, startz)); - listPos=xyzlist.size()-1; - block=worldObj.getBlock(startx, starty, startz); - replaceBlock(startx, starty, startz, block); - this.blockList.add(block); - } - else - { - if(listPos>0) - { - listPos--; - XYZ xyz = xyzlist.get(listPos); - startx=xyz.x; - starty=xyz.y; - startz=xyz.z; - } - } - } - } - return xyzlist.size(); - } - - private int getFlowDecay(World world, int startx, int starty, int startz) { - return this.getFlowDecay(startx, starty, startz); - } -} diff --git a/ihl/i_hate_liquids/XYZ.java b/ihl/i_hate_liquids/XYZ.java deleted file mode 100644 index 287b11a..0000000 --- a/ihl/i_hate_liquids/XYZ.java +++ /dev/null @@ -1,26 +0,0 @@ -package ihl.i_hate_liquids; - -public class XYZ { - public int x; - public int y; - public int z; - - public XYZ(int x1,int y1,int z1) - { - this.x=x1; - this.y=y1; - this.z=z1; - } - - @Override - public boolean equals(Object obj) - { - if(obj instanceof XYZ) - { - XYZ xyz2 = (XYZ) obj; - return (this.x==xyz2.x && this.y==xyz2.y && this.z==xyz2.z); - } - return false; - } - -} diff --git a/ihl/interfaces/IDataCableHolder.java b/ihl/interfaces/IDataCableHolder.java deleted file mode 100644 index f527f1b..0000000 --- a/ihl/interfaces/IDataCableHolder.java +++ /dev/null @@ -1,12 +0,0 @@ -package ihl.interfaces; - -import ihl.datanet.Contact; -import net.minecraft.nbt.NBTTagCompound; - -public interface IDataCableHolder extends ICableHolder -{ - boolean addDataCable(NBTTagCompound cable); - Contact[] getContacts(int chainUID); - void removeCable(int chainUID); - Contact getContact(int innerId1); -} diff --git a/ihl/interfaces/IDataNode.java b/ihl/interfaces/IDataNode.java deleted file mode 100644 index d13af00..0000000 --- a/ihl/interfaces/IDataNode.java +++ /dev/null @@ -1,21 +0,0 @@ -package ihl.interfaces; - -import ihl.processing.invslots.InvSlotSignalProcessor; - -import java.util.Set; - -public interface IDataNode -{ - int getAttachedSlotNumber(); - int getDataGridID(); - void setDataGrid(int newGridID); - Set getConnectedDataNodes(); - int getXPos(); - int getYPos(); - int getZPos(); - int getInnerId(); - boolean isIndirectlyConnectedWithContact(int id); - void checkAttachedSlots(); - InvSlotSignalProcessor getAttachedSlot(); - int getType(); -} diff --git a/ihl/interfaces/ItemMiniGUI.java b/ihl/interfaces/ItemMiniGUI.java index 4be2fe9..249fb7d 100644 --- a/ihl/interfaces/ItemMiniGUI.java +++ b/ihl/interfaces/ItemMiniGUI.java @@ -3,19 +3,27 @@ package ihl.interfaces; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Slot; -public abstract class ItemMiniGUI -{ +public abstract class ItemMiniGUI { protected final GuiContainer guiBase; protected final Slot slotBase; - - public ItemMiniGUI(GuiContainer gui, Slot slot) - { - guiBase=gui; - slotBase=slot; + + protected final int TEXT_BOX_POSX = 50; + protected final int TEXT_BOX_POSY = 16; + protected final int TEXT_BOX_WIDTH = 42; + protected final int UNITS_LABEL_POSX = 105; + protected final int HEIGHT = 39; + protected final int RUNNER_POSY = 30; + + public ItemMiniGUI(GuiContainer gui, Slot slot) { + guiBase = gui; + slotBase = slot; } - + public abstract void displayGUI(); + public abstract boolean handleMouseClick(int mouseButton, int mouseX, int mouseY); - public abstract boolean handleKeyTyped(char characterTyped, int keyIndex); + + public abstract boolean handleKeyTyped(char characterTyped, int keyIndex); + public abstract void onGUIClosed(); } diff --git a/ihl/items_blocks/FlexibleCableItem.java b/ihl/items_blocks/FlexibleCableItem.java index 7fd2583..9944f4c 100644 --- a/ihl/items_blocks/FlexibleCableItem.java +++ b/ihl/items_blocks/FlexibleCableItem.java @@ -28,7 +28,6 @@ import ihl.flexible_cable.AnchorTileEntity; import ihl.flexible_cable.NodeEntity; import ihl.flexible_cable.PowerCableNodeEntity; import ihl.interfaces.ICableHolder; -import ihl.interfaces.IDataCableHolder; import ihl.interfaces.IEnergyNetNode; import ihl.interfaces.IMultiPowerCableHolder; import ihl.interfaces.IWire; @@ -100,8 +99,7 @@ public class FlexibleCableItem extends Item implements IWire { world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "step.stone", 1.0F, 0.8F); if (!world.isRemote && t != null && ((t instanceof IEnergyNetNode && !isDataCable) - || (t instanceof IMultiPowerCableHolder && !isDataCable) - || (t instanceof IDataCableHolder && isDataCable)) + || (t instanceof IMultiPowerCableHolder && !isDataCable)) && stack.stackTagCompound.getInteger("fullLength") >= 1) { double ppx, ppy, ppz; ICableHolder te; @@ -138,10 +136,15 @@ public class FlexibleCableItem extends Item implements IWire { stack.stackTagCompound.setBoolean("firstConnection", false); return false; } else { - if (t2 instanceof IMultiPowerCableHolder) { - te = ((IMultiPowerCableHolder) t2).getEnergyNetNode(facing); + if (t instanceof IMultiPowerCableHolder) { + facing = ((IMultiPowerCableHolder) t).getSide(player); + if (facing == -1) { + return false; + } else { + te = ((IMultiPowerCableHolder) t).getEnergyNetNode(facing); + } } else { - te = (ICableHolder) t2; + te = (ICableHolder) t; } te.setCableCheck(true); } diff --git a/ihl/items_blocks/IHLBucketHandler.java b/ihl/items_blocks/IHLBucketHandler.java new file mode 100644 index 0000000..c0a23b6 --- /dev/null +++ b/ihl/items_blocks/IHLBucketHandler.java @@ -0,0 +1,20 @@ +package ihl.items_blocks; + +import net.minecraft.block.Block; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class IHLBucketHandler +{ + public IHLBucketHandler() {} + @SubscribeEvent + public void onBucketFill(FillBucketEvent event) + { + Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ); + if (block instanceof IHLFluidBlock && event.isCancelable()) + { + event.setCanceled(true); + } + } + +} diff --git a/ihl/items_blocks/IHLItemBlock.java b/ihl/items_blocks/IHLItemBlock.java index 3bde475..c25450d 100644 --- a/ihl/items_blocks/IHLItemBlock.java +++ b/ihl/items_blocks/IHLItemBlock.java @@ -10,9 +10,6 @@ import ic2.api.tile.IWrenchable; import ic2.core.IC2; import ihl.IHLCreativeTab; import ihl.IHLModInfo; -import ihl.collector.ChargerEjectorTileEntity; -import ihl.processing.metallurgy.PassiveBlock; -import ihl.tunneling_shield.DriverTileEntity; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -101,25 +98,6 @@ public class IHLItemBlock extends ItemBlock{ this.field_150939_a.onBlockPlacedBy(world, x, y, z, player, par1ItemStack); this.field_150939_a.onPostBlockPlaced(world, x, y, z, var13); TileEntity tile=world.getTileEntity(x, y, z); - if(tile!=null && par1ItemStack.stackTagCompound!=null && par1ItemStack.stackTagCompound.hasKey("energy") && tile instanceof ChargerEjectorTileEntity && IC2.platform.isSimulating()) - { - ChargerEjectorTileEntity te=(ChargerEjectorTileEntity)tile; - double energy; - try - { - energy = par1ItemStack.stackTagCompound.getDouble("energy"); - } - catch (Exception var3) - { - energy = par1ItemStack.stackTagCompound.getInteger("energy"); - - if (energy > Integer.MAX_VALUE) - { - energy *= 10.0D; - } - } - te.setStored(energy); - } if(tile instanceof IWrenchable && IC2.platform.isSimulating()) { IWrenchable te=(IWrenchable)tile; @@ -234,27 +212,6 @@ public class IHLItemBlock extends ItemBlock{ } } - @Override - public boolean onItemUseFirst(ItemStack itemstack, EntityPlayer entityPlayer, World world, int x, int y, int z, int l, float hitX, float hitY, float hitZ) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - if (tileEntity instanceof DriverTileEntity && IC2.platform.isSimulating()) - { - DriverTileEntity dte = (DriverTileEntity) tileEntity; - if(itemstack.getUnlocalizedName()==PassiveBlock.Type.IHLShieldAssemblyUnitBlock.unlocalizedName) - { - dte.installShield(); - itemstack.stackSize--; - } - else if(itemstack.getUnlocalizedName()==PassiveBlock.Type.AdvancedShieldAssemblyUnitBlock.unlocalizedName) - { - dte.installAdvancedShield(); - itemstack.stackSize--; - } - } - return false; - } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) diff --git a/ihl/items_blocks/ItemSubstance.java b/ihl/items_blocks/ItemSubstance.java index d934172..7404a54 100644 --- a/ihl/items_blocks/ItemSubstance.java +++ b/ihl/items_blocks/ItemSubstance.java @@ -34,304 +34,286 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class ItemSubstance extends Item implements IItemHasMiniGUI{ - +public class ItemSubstance extends Item implements IItemHasMiniGUI { + private static Map iconMap = new HashMap(); private static Map nameMap = new HashMap(); private static Map descriptionMap = new HashMap(); public static ItemSubstance instance; - - public ItemSubstance() - { + + public ItemSubstance() { super(); this.setMaxDamage(0); this.setNoRepair(); this.setHasSubtypes(true); this.setCreativeTab(IHLCreativeTab.tab); this.setUnlocalizedName("ihlSimpleItem"); - instance=this; + instance = this; } - - public static void init() - { - Item breadWithLard = (new ItemFood(4, 0.1F, false)).setUnlocalizedName("breadWithLard").setTextureName(IHLModInfo.MODID+":breadWithLard").setCreativeTab(IHLCreativeTab.tab); - GameRegistry.registerItem(breadWithLard,"food"); - IHLUtils.registerLocally("breadWithLard", new ItemStack(breadWithLard,1,0)); + + public static void init() { + Item breadWithLard = (new ItemFood(4, 0.1F, false)).setUnlocalizedName("breadWithLard") + .setTextureName(IHLModInfo.MODID + ":breadWithLard").setCreativeTab(IHLCreativeTab.tab); + GameRegistry.registerItem(breadWithLard, "food"); + IHLUtils.registerLocally("breadWithLard", new ItemStack(breadWithLard, 1, 0)); ItemSubstance item = new ItemSubstance(); - GameRegistry.registerItem(item,item.getUnlocalizedName()); + GameRegistry.registerItem(item, item.getUnlocalizedName()); Type[] var1 = Type.values(); - for(int i=0;i teclass; boolean isNormalBlock=true; boolean hasSpecialBlockRenderer=false; @@ -845,24 +715,6 @@ public class MachineBaseBlock extends Block implements ITileEntityProvider{ { case BronzeTub: return this.bronzeTubSide; - case GlassBox: - switch(flag) - { - case 0: - return this.glassBoxInnerSide; - case 1: - return this.glassBoxInnerBottom; - } - case RedstoneSignalConverter: - switch(flag) - { - case 0: - return this.redstoneSignalConverterEmptySide; - case 1: - return this.redstoneSignalConverterEmitterSide; - case 2: - return this.redstoneSignalConverterSensorSide; - } default: return this.blockIcon; } diff --git a/ihl/model/FlexibleCableItemRender.java b/ihl/model/FlexibleCableItemRender.java index 92b2036..02fc5f7 100644 --- a/ihl/model/FlexibleCableItemRender.java +++ b/ihl/model/FlexibleCableItemRender.java @@ -13,30 +13,30 @@ import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; -public class FlexibleCableItemRender implements IItemRenderer -{ +public class FlexibleCableItemRender implements IItemRenderer { private ModelTube model; private ModelTube modelThin; private ModelTube modelLong; private ModelTube modelThinLong; - private final int segmentsAmount=19; - private final float spiralStepAngle=1f; - private final float scale=1/32f; + private final int segmentsAmount = 19; + private final float spiralStepAngle = 1f; + private final float scale = 1 / 32f; private final int[] displayListCache = new int[4]; - -public FlexibleCableItemRender() -{ - float vOffset=16f; - int longFragmensSize=24; - model=new ModelTube(null, 0, 0, -2F, -3F, -2F+vOffset, 4, 6, 4,0f, 0.5f,0.99f, ForgeDirection.UP); - modelLong=new ModelTube(null, 0, 0, -2F, -3F, -2F+vOffset, 4, longFragmensSize, 4,0f, 0f,0.99f, ForgeDirection.UP); - modelThin=new ModelTube(null, 0, 0, -1F, -3F, -1F+vOffset, 2, 6, 2,0f, 0.5f,0.99f, ForgeDirection.UP); - modelThinLong=new ModelTube(null, 0, 0, -1F, -3F, -1F+vOffset, 2, longFragmensSize, 2,0f, 0.5f,0.99f, ForgeDirection.UP); -} -@Override -public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { + public FlexibleCableItemRender() { + float vOffset = 16f; + int longFragmensSize = 24; + model = new ModelTube(null, 0, 0, -2F, -3F, -2F + vOffset, 4, 6, 4, 0f, 0.5f, 0.99f, ForgeDirection.UP); + modelLong = new ModelTube(null, 0, 0, -2F, -3F, -2F + vOffset, 4, longFragmensSize, 4, 0f, 0f, 0.99f, + ForgeDirection.UP); + modelThin = new ModelTube(null, 0, 0, -1F, -3F, -1F + vOffset, 2, 6, 2, 0f, 0.5f, 0.99f, ForgeDirection.UP); + modelThinLong = new ModelTube(null, 0, 0, -1F, -3F, -1F + vOffset, 2, longFragmensSize, 2, 0f, 0.5f, 0.99f, + ForgeDirection.UP); + } + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + switch (type) { case ENTITY: return true; case EQUIPPED: @@ -47,171 +47,136 @@ public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; default: return false; + } } -} -@Override -public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return true; -} + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } -@Override -public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glScalef(1F, -1F, -1F); - switch (type) { + @Override + public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glScalef(1F, -1F, -1F); + switch (type) { case ENTITY: - GL11.glTranslatef(0,-1.0F,0); - this.rendercoil(stack); + GL11.glTranslatef(0, -1.0F, 0); + this.rendercoil(stack); break; case EQUIPPED: - GL11.glTranslatef(0.25F,-2F,-0.75F); - this.rendercoil(stack); - break; + GL11.glTranslatef(0.25F, -2F, -0.75F); + this.rendercoil(stack); + break; case EQUIPPED_FIRST_PERSON: - RenderPlayer var25; - EntityClientPlayerMP var3 = Minecraft.getMinecraft().thePlayer; + RenderPlayer var25; + EntityClientPlayerMP var3 = Minecraft.getMinecraft().thePlayer; Minecraft.getMinecraft().getTextureManager().bindTexture(var3.getLocationSkin()); - var25 = (RenderPlayer)RenderManager.instance.getEntityRenderObject(Minecraft.getMinecraft().thePlayer); + var25 = (RenderPlayer) RenderManager.instance.getEntityRenderObject(Minecraft.getMinecraft().thePlayer); GL11.glRotatef(135F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(35F, 0.0F, 1.0F, 0.0F); var25.renderFirstPersonArm(Minecraft.getMinecraft().thePlayer); GL11.glRotatef(-35F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-135F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F,0.2F,0F); - GL11.glTranslatef(-0.25F,-1.0F,0F); - this.rendercoil(stack); + GL11.glTranslatef(0.0F, 0.2F, 0F); + GL11.glTranslatef(-0.25F, -1.0F, 0F); + this.rendercoil(stack); break; case INVENTORY: - GL11.glTranslatef(0.0F,-0.2F,0F); - this.rendercoil(stack); + GL11.glTranslatef(0.0F, -0.2F, 0F); + this.rendercoil(stack); break; default: } - GL11.glPopMatrix(); + GL11.glPopMatrix(); } - private void rendercoil(ItemStack stack) - { + private void rendercoil(ItemStack stack) { int type = this.getCableType(stack); - if (this.displayListCache[type] != 0) - { + if (this.displayListCache[type] != 0) { GL11.glCallList(displayListCache[type]); - } - else - { - - this.displayListCache[type]=GLAllocation.generateDisplayLists(1); - GL11.glNewList(displayListCache[type], 4864 /*GL_COMPILE*/); - - GL11.glDisable(GL11.GL_TEXTURE_2D); - int saMax=this.segmentsAmount*2+this.segmentsAmount/2; - for(int i=0; i<=saMax;i++) - { - GL11.glRotatef(-spiralStepAngle, 0f, 0f, 1f); - GL11.glRotatef(360f/this.segmentsAmount, 1f, 0f, 0f); - GL11.glTranslatef(0.004f,0f,0f); - GL11.glRotatef(spiralStepAngle, 0f, 0f, 1f); - if(((FlexibleCableItem)stack.getItem()).isDataCable) - { - GL11.glColor3f(1f,0.2f, 0f); - } - else - { - GL11.glColor3f(1f,1f, 1f); - } - if(i==0) - { - if(isNoInsulation(stack)) - { - if(FlexibleCableItem.instance.yellowColoredWires.contains(FlexibleCableItem.instance.getMaterial(stack))) - { - GL11.glColor3f(1f,0.75f, 0.1f); - } - else - { - GL11.glColor3f(0.65f,0.65f, 0.67f); - } - this.modelThinLong.render(Tessellator.instance, scale); - - } - else - { - this.modelLong.render(Tessellator.instance, scale); + } else { + + this.displayListCache[type] = GLAllocation.generateDisplayLists(1); + GL11.glNewList(displayListCache[type], 4864 /* GL_COMPILE */); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + int saMax = this.segmentsAmount * 2 + this.segmentsAmount / 2; + for (int i = 0; i <= saMax; i++) { + GL11.glRotatef(-spiralStepAngle, 0f, 0f, 1f); + GL11.glRotatef(360f / this.segmentsAmount, 1f, 0f, 0f); + GL11.glTranslatef(0.004f, 0f, 0f); + GL11.glRotatef(spiralStepAngle, 0f, 0f, 1f); + if (((FlexibleCableItem) stack.getItem()).isDataCable) { + GL11.glColor3f(1f, 0.2f, 0f); + } else { + GL11.glColor3f(1f, 1f, 1f); } - } - else if(i==saMax) - { - GL11.glTranslatef(0.0F,-0.55F,0F); - if(isNoInsulation(stack)) - { - if(FlexibleCableItem.instance.yellowColoredWires.contains(FlexibleCableItem.instance.getMaterial(stack))) - { - GL11.glColor3f(1f,0.75f, 0.1f); - } - else - { - GL11.glColor3f(0.65f,0.65f, 0.67f); + if (i == 0) { + if (isNoInsulation(stack)) { + if (FlexibleCableItem.instance.yellowColoredWires + .contains(FlexibleCableItem.instance.getMaterial(stack))) { + GL11.glColor3f(1f, 0.75f, 0.1f); + } else { + GL11.glColor3f(0.65f, 0.65f, 0.67f); + } + this.modelThinLong.render(Tessellator.instance, scale); + + } else { + this.modelLong.render(Tessellator.instance, scale); } - this.modelThinLong.render(Tessellator.instance, scale); - - } - else - { - this.modelLong.render(Tessellator.instance, scale); - } - GL11.glTranslatef(0.0F,0.55F,0F); - } - else - { - if(isNoInsulation(stack)) - { - if(FlexibleCableItem.instance.yellowColoredWires.contains(FlexibleCableItem.instance.getMaterial(stack))) - { - GL11.glColor3f(1f,0.75f, 0.1f); + } else if (i == saMax) { + GL11.glTranslatef(0.0F, -0.55F, 0F); + if (isNoInsulation(stack)) { + if (FlexibleCableItem.instance.yellowColoredWires + .contains(FlexibleCableItem.instance.getMaterial(stack))) { + GL11.glColor3f(1f, 0.75f, 0.1f); + } else { + GL11.glColor3f(0.65f, 0.65f, 0.67f); + } + this.modelThinLong.render(Tessellator.instance, scale); + + } else { + this.modelLong.render(Tessellator.instance, scale); } - else - { - GL11.glColor3f(0.65f,0.65f, 0.67f); + GL11.glTranslatef(0.0F, 0.55F, 0F); + } else { + if (isNoInsulation(stack)) { + if (FlexibleCableItem.instance.yellowColoredWires + .contains(FlexibleCableItem.instance.getMaterial(stack))) { + GL11.glColor3f(1f, 0.75f, 0.1f); + } else { + GL11.glColor3f(0.65f, 0.65f, 0.67f); + } + this.modelThin.render(Tessellator.instance, scale); + + } else { + this.model.render(Tessellator.instance, scale); } - this.modelThin.render(Tessellator.instance, scale); - - } - else - { - this.model.render(Tessellator.instance, scale); } } - } - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEndList(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEndList(); } } - - private int getCableType(ItemStack stack) - { - if(((FlexibleCableItem)stack.getItem()).isDataCable) - { + + private int getCableType(ItemStack stack) { + if (((FlexibleCableItem) stack.getItem()).isDataCable) { return 3; - } - else if(isNoInsulation(stack)) - { - if(FlexibleCableItem.instance.yellowColoredWires.contains(FlexibleCableItem.instance.getMaterial(stack))) - { + } else if (isNoInsulation(stack)) { + if (FlexibleCableItem.instance.yellowColoredWires.contains(FlexibleCableItem.instance.getMaterial(stack))) { return 1; - } - else - { + } else { return 2; } } return 0; } - private boolean isNoInsulation(ItemStack stack) - { - return stack.stackTagCompound!=null && FlexibleCableItem.instance.getInsulationMaterial(stack).equals("null") && !((FlexibleCableItem)stack.getItem()).isDataCable; + private boolean isNoInsulation(ItemStack stack) { + return stack.stackTagCompound != null && FlexibleCableItem.instance.getInsulationMaterial(stack).equals("null") + && !((FlexibleCableItem) stack.getItem()).isDataCable; } } \ No newline at end of file diff --git a/ihl/model/IHLToolRenderer.java b/ihl/model/IHLToolRenderer.java index a5ba87b..14e610b 100644 --- a/ihl/model/IHLToolRenderer.java +++ b/ihl/model/IHLToolRenderer.java @@ -33,21 +33,6 @@ public class IHLToolRenderer implements IItemRenderer @Override public void renderItem(ItemRenderType irt, ItemStack stack, Object... arg2) { - if(irt.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) - { - if(stack.getItemDamage()==IHLTool.Type.Thermometer.itemDamage && stack.stackTagCompound!=null) - { - if(stack.stackTagCompound.getByte("showTemperature")>0) - { - RenderGameOverlayEventHandler.instance.temperature=stack.stackTagCompound.getLong("temperature"); - RenderGameOverlayEventHandler.instance.displayCurrentGUITimer=2000; - } - else - { - RenderGameOverlayEventHandler.instance.displayCurrentGUITimer=500; - } - } - } IIcon icon = stack.getItem().getIcon(stack, 0); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); if(irt.equals(ItemRenderType.INVENTORY)) diff --git a/ihl/model/RenderGameOverlayEventHandler.java b/ihl/model/RenderGameOverlayEventHandler.java deleted file mode 100644 index 6770c3d..0000000 --- a/ihl/model/RenderGameOverlayEventHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package ihl.model; - -import ihl.utils.IHLRenderUtils; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.RenderGameOverlayEvent; - -public class RenderGameOverlayEventHandler -{ - - private static final ResourceLocation thermometerGUI = new ResourceLocation("ihl", "textures/gui/GUIThermometer.png"); - public static RenderGameOverlayEventHandler instance; - public long temperature = 0; - public int displayCurrentGUITimer = 0; - - public RenderGameOverlayEventHandler() - { - instance=this; - } - - public void showThermometerTemperature(int temperature1, int displayCurrentGUITimer1) - { - - } - - @SubscribeEvent - public void renderGameOverlayEvent(RenderGameOverlayEvent.Pre/*.Post*/ event) - { - if(displayCurrentGUITimer>0) - { - displayCurrentGUITimer--; - Minecraft.getMinecraft().renderEngine.bindTexture(thermometerGUI); - IHLRenderUtils.instance.drawThermometerTemperature(temperature, displayCurrentGUITimer>500); - } - } - -} diff --git a/ihl/model/SwitchBoxBlockRender.java b/ihl/model/SwitchBoxBlockRender.java deleted file mode 100644 index 87c9fb9..0000000 --- a/ihl/model/SwitchBoxBlockRender.java +++ /dev/null @@ -1,127 +0,0 @@ -package ihl.model; - -import ic2.core.Ic2Items; -import ihl.datanet.RedstoneSignalConverterTileEntity; -import ihl.items_blocks.MachineBaseBlock; -import ihl.utils.IHLUtils; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.client.registry.RenderingRegistry; - -public class SwitchBoxBlockRender implements ISimpleBlockRenderingHandler -{ - public static int renderId; - - public SwitchBoxBlockRender() - { - renderId = RenderingRegistry.getNextAvailableRenderId(); - } - - @Override - public int getRenderId() - { - return renderId; - } - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks) - { - Tessellator tessellator = Tessellator.instance; - block.setBlockBoundsForItemRender(); - renderblocks.setRenderBoundsFromBlock(block); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 0, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 1, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 2, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 3, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 4, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 5, metadata)); - tessellator.draw(); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - @Override - public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta, RenderBlocks blockRenderer) - { - TileEntity te = blockAccess.getTileEntity(x, y, z); - IIcon emptyIcon,emitterIcon,sensorIcon = block.getBlockTextureFromSide(0); - emptyIcon=emitterIcon=sensorIcon; - if(block instanceof MachineBaseBlock) - { - emptyIcon = ((MachineBaseBlock)block).getAdditionalIconsForBlockRenderer(0); - emitterIcon = ((MachineBaseBlock)block).getAdditionalIconsForBlockRenderer(1); - sensorIcon = ((MachineBaseBlock)block).getAdditionalIconsForBlockRenderer(2); - } - IIcon[] sideToTypes = new IIcon[6]; - if(te instanceof RedstoneSignalConverterTileEntity) - { - RedstoneSignalConverterTileEntity rscte = (RedstoneSignalConverterTileEntity) te; - for(int side=0;side> 16 & 255) / 255.0F; - float var8 = (var6 >> 8 & 255) / 255.0F; - float var9 = (var6 & 255) / 255.0F; - var5.setColorOpaque_F(var7, var8, var9); - blockRenderer.renderFaceXPos(block, x, y, z, sideToTypes[4]); - blockRenderer.renderFaceXNeg(block, x, y, z, sideToTypes[5]); - blockRenderer.renderFaceZPos(block, x, y, z, sideToTypes[2]); - blockRenderer.renderFaceZNeg(block, x, y, z, sideToTypes[3]); - blockRenderer.renderFaceYPos(block, x, y, z, sideToTypes[0]); - blockRenderer.renderFaceYNeg(block, x, y, z, sideToTypes[1]); - return true; - } - - @Override - public boolean shouldRender3DInInventory(int arg0) - { - return true; - } -} diff --git a/ihl/nei_integration/ElectrolysisBathRecipeHandler.java b/ihl/nei_integration/ElectrolysisBathRecipeHandler.java index 38f10ee..ff07163 100644 --- a/ihl/nei_integration/ElectrolysisBathRecipeHandler.java +++ b/ihl/nei_integration/ElectrolysisBathRecipeHandler.java @@ -1,5 +1,6 @@ package ihl.nei_integration; +import java.awt.Rectangle; import java.util.Map; import ihl.processing.chemistry.ElectrolysisBathGui; @@ -65,6 +66,12 @@ public class ElectrolysisBathRecipeHandler extends MachineRecipeHandler { return "electrolysisBath"; } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(115-5,10-10, 172-115, 72), this.getRecipeId(), new Object[0])); + } @Override public Map getRecipeList() diff --git a/ihl/processing/chemistry/ElectrolysisBathGui.java b/ihl/processing/chemistry/ElectrolysisBathGui.java index a7788a5..89b8ddb 100644 --- a/ihl/processing/chemistry/ElectrolysisBathGui.java +++ b/ihl/processing/chemistry/ElectrolysisBathGui.java @@ -8,7 +8,8 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import ihl.collector.GuiMultiTextureButton; + +import ihl.utils.GuiMultiTextureButton; import ihl.utils.IHLRenderUtils; @SideOnly(Side.CLIENT) diff --git a/ihl/processing/invslots/InvSlotSignalProcessor.java b/ihl/processing/invslots/InvSlotSignalProcessor.java deleted file mode 100644 index f66ab13..0000000 --- a/ihl/processing/invslots/InvSlotSignalProcessor.java +++ /dev/null @@ -1,123 +0,0 @@ -package ihl.processing.invslots; - -import net.minecraft.block.Block; -import net.minecraftforge.common.util.ForgeDirection; -import ic2.core.Ic2Items; -import ic2.core.block.invslot.InvSlot; -import ihl.datanet.Contact; -import ihl.datanet.RedstoneSignalConverterTileEntity; -import ihl.interfaces.IDataNode; -import ihl.utils.IHLUtils; - -public class InvSlotSignalProcessor extends InvSlot -{ - private RedstoneSignalConverterTileEntity rscBase; - public final boolean[] slotStatus;//false=normal;true=activated - public InvSlotSignalProcessor(RedstoneSignalConverterTileEntity base1, String name1, int oldStartIndex1, Access access1, int count, int linksPerSlot) { - super(base1, name1, oldStartIndex1, access1, count); - rscBase = base1; - slotStatus = new boolean[count]; - } - - public Contact getOppositeContact(IDataNode contact3) - { - for(Contact contact1 : this.rscBase.contacts) - { - if(contact1.attachedSlot==this && - contact3.getAttachedSlotNumber()==contact1.attachedSlotNumber) - { - switch(contact3.getType()) - { - case 0: - if(contact1.type==1) - { - return contact1; - } - break; - case 1: - if(contact1.type==0) - { - return contact1; - } - break; - case 2: - if(slotStatus[contact1.attachedSlotNumber]) - { - if(contact1.type==3) - { - return contact1; - } - } - else - { - if(contact1.type==4) - { - return contact1; - } - } - break; - case 3: - if(slotStatus[contact1.attachedSlotNumber]) - { - if(contact1.type==2) - { - return contact1; - } - } - break; - case 4: - if(!slotStatus[contact1.attachedSlotNumber]) - { - if(contact1.type==2) - { - return contact1; - } - } - break; - } - } - } - return null; - } - - public boolean isSlotActivated(int slot) - { - return this.slotStatus[slot]; - } - - public void notifyNeighbors() - { - int xyz[] = {0,0,1,0,0,-1,0,0}; - Block block; - int x,y,z; - for(int i=0;i<=5;i++) - { - x=rscBase.xCoord+xyz[i]; - y=rscBase.yCoord+xyz[i+1]; - z=rscBase.zCoord+xyz[i+2]; - block = rscBase.getWorldObj().getBlock(rscBase.xCoord,rscBase.yCoord,rscBase.zCoord); - rscBase.getWorldObj().notifyBlockOfNeighborChange(x,y,z,block); - } - } - - public boolean isIndirectlyConnectedWithContact(Contact contact, int id) - { - if(this.get(contact.attachedSlotNumber)!=null) - { - if(IHLUtils.isItemStacksIsEqual(this.get(contact.attachedSlotNumber), Ic2Items.splitterCableItem, true))//Redstone sensor - { - ForgeDirection dir1 = ForgeDirection.getOrientation(contact.attachedSlotNumber); - if(this.base.getWorldObj().getIndirectPowerOutput(base.xCoord+dir1.offsetX, base.yCoord+dir1.offsetY, base.zCoord+dir1.offsetZ, dir1.getOpposite().flag)) - { - Contact oppositeContact = this.getOppositeContact(contact); - if(oppositeContact.getDataGridID()!=contact.getDataGridID()) - { - return oppositeContact.isConnectedToContact(id); - } - } - } - } - return false; - } - -} \ No newline at end of file diff --git a/ihl/processing/metallurgy/CrucibleInventory.java b/ihl/processing/metallurgy/CrucibleInventory.java index 57d9c17..cc5707a 100644 --- a/ihl/processing/metallurgy/CrucibleInventory.java +++ b/ihl/processing/metallurgy/CrucibleInventory.java @@ -9,27 +9,26 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.oredict.OreDictionary; import ic2.core.ContainerBase; import ic2.core.IC2; import ic2.core.item.tool.HandHeldInventory; import ic2.core.util.StackUtil; -public class CrucibleInventory extends HandHeldInventory{ +public class CrucibleInventory extends HandHeldInventory { ItemStack thisItemStack; IInventory inventoryContainer; + public CrucibleInventory(EntityPlayer player, ItemStack stack) { super(player, stack, 1); - thisItemStack=stack; - inventoryContainer=player.inventory; + thisItemStack = stack; + inventoryContainer = player.inventory; } - - public CrucibleInventory(IInventory inventoryContainer1, ItemStack stack) - { + + public CrucibleInventory(IInventory inventoryContainer1, ItemStack stack) { super(null, stack, 1); - thisItemStack=stack; - inventoryContainer=inventoryContainer1; + thisItemStack = stack; + inventoryContainer = inventoryContainer1; } @Override @@ -55,101 +54,73 @@ public class CrucibleInventory extends HandHeldInventory{ @Override public boolean isItemValidForSlot(int arg0, ItemStack stack) { - if(((Crucible)thisItemStack.getItem()).isEmpty(thisItemStack)) - { - int[] arrayIDs = OreDictionary.getOreIDs(stack); - for(int i=0; i= 0) - { - var9 = inventoryContainer.getStackInSlot(var8); - } - - if (var9 != null) - { - NBTTagCompound nbtTagCompoundSlot = var9.getTagCompound(); - - if (nbtTagCompoundSlot != null && nbtTagCompound.getInteger("uid") == nbtTagCompoundSlot.getInteger("uid")) - { - this.thisItemStack.stackSize = 1; - - if (var8 == -1 && inventoryContainer instanceof InventoryPlayer) - { - ((InventoryPlayer) inventoryContainer).setItemStack(this.thisItemStack); - } - else - { - inventoryContainer.setInventorySlotContents(var8, this.thisItemStack); - } - - break; - } - } - } - - } - } + public void save() { + if (IC2.platform.isSimulating()) { + NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(this.thisItemStack); + + for (int nbtTagList = 0; nbtTagList < this.getSizeInventory(); ++nbtTagList) { + if (this.inventory[nbtTagList] != null) { + NBTTagCompound i = StackUtil.getOrCreateNbtData(this.inventory[nbtTagList]); + + if (nbtTagCompound.getInteger("uid") == i.getInteger("uid")) { + this.thisItemStack.stackSize = 1; + this.inventory[nbtTagList] = null; + break; + } + } + } + + NBTTagList var7 = new NBTTagList(); + int var8; + + for (var8 = 0; var8 < this.inventory.length; ++var8) { + if (this.inventory[var8] != null) { + NBTTagCompound itemStackSlot = new NBTTagCompound(); + itemStackSlot.setByte("Slot", (byte) var8); + this.inventory[var8].writeToNBT(itemStackSlot); + var7.appendTag(itemStackSlot); + } + } + + nbtTagCompound.setTag("Items", var7); + + for (var8 = -1; var8 < inventoryContainer.getSizeInventory(); ++var8) { + ItemStack var9 = null; + + if (var8 == -1 && inventoryContainer instanceof InventoryPlayer) { + var9 = ((InventoryPlayer) inventoryContainer).getItemStack(); + } else if (var8 >= 0) { + var9 = inventoryContainer.getStackInSlot(var8); + } + + if (var9 != null) { + NBTTagCompound nbtTagCompoundSlot = var9.getTagCompound(); + + if (nbtTagCompoundSlot != null + && nbtTagCompound.getInteger("uid") == nbtTagCompoundSlot.getInteger("uid")) { + this.thisItemStack.stackSize = 1; + + if (var8 == -1 && inventoryContainer instanceof InventoryPlayer) { + ((InventoryPlayer) inventoryContainer).setItemStack(this.thisItemStack); + } else { + inventoryContainer.setInventorySlotContents(var8, this.thisItemStack); + } + + break; + } + } + } + + } + } } diff --git a/ihl/processing/metallurgy/CrucibleSlot.java b/ihl/processing/metallurgy/CrucibleSlot.java index e0b702d..5fc6a33 100644 --- a/ihl/processing/metallurgy/CrucibleSlot.java +++ b/ihl/processing/metallurgy/CrucibleSlot.java @@ -3,18 +3,16 @@ package ihl.processing.metallurgy; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class CrucibleSlot extends Slot -{ +public class CrucibleSlot extends Slot { CrucibleInventory inventory; - public CrucibleSlot(CrucibleInventory arg0, int arg1, int arg2, int arg3) - { + + public CrucibleSlot(CrucibleInventory arg0, int arg1, int arg2, int arg3) { super(arg0, arg1, arg2, arg3); - inventory=arg0; + inventory = arg0; } @Override - public boolean isItemValid(ItemStack itemstack) - { - return itemstack == null ? false : inventory.isItemValidForSlot(0, itemstack); - } + public boolean isItemValid(ItemStack itemstack) { + return itemstack != null; + } } diff --git a/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java b/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java index c5a54c7..55db3db 100644 --- a/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java +++ b/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java @@ -1,6 +1,5 @@ package ihl.processing.metallurgy; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -17,15 +16,15 @@ import net.minecraft.item.ItemStack; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class MuffleFurnanceTileEntity extends MachineBaseTileEntity{ +public class MuffleFurnanceTileEntity extends MachineBaseTileEntity { protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("mufflefurnace"); - - public MuffleFurnanceTileEntity() - { + + public MuffleFurnanceTileEntity() { super(2); + this.input.setStackSizeLimit(32); } - + @Override public String getStartSoundFile() { return null; @@ -56,80 +55,72 @@ public class MuffleFurnanceTileEntity extends MachineBaseTileEntity{ public ContainerBase getGuiContainer(EntityPlayer player) { return new MuffleFurnanceContainer(player, this); } - - @Override - public boolean canOperate() - { - ItemStack crucible = input.getItemStack(IHLMod.crucible); - if(crucible!=null) - { - return true; - } - ItemStack mold = input.getItemStack(IHLUtils.getThisModItem("injectionMold")); - if(mold!=null) - { - return true; - } - return getOutput()!=null; - } - + + @Override + public boolean canOperate() { + ItemStack crucible = input.getItemStack(IHLMod.crucible); + if (crucible != null) { + return true; + } + ItemStack mold = input.getItemStack(IHLUtils.getThisModItem("injectionMold")); + if (mold != null) { + return true; + } + return getOutput() != null; + } + @Override - public void operate() - { - ItemStack crucible = input.getItemStack(IHLMod.crucible); - if(crucible!=null) - { - ((Crucible)crucible.getItem()).processContent(crucible, this); - return; - } - ItemStack mold = input.getItemStack(IHLUtils.getThisModItem("injectionMold")); - if(mold!=null) - { - mold.stackTagCompound.setBoolean("isContainStearin", false); - return; - } - if(this.getOutput()!=null) - { - List output = MuffleFurnanceTileEntity.recipeManager.getOutputFor(null,this.input.getItemStackList(), true, true).getItemOutputs(); - for(int i=0; i output = routput.getItemOutputs(); + for (int i = 0; i < this.input.size(); i++) { + if (i < output.size() && output.get(i) != null) { ItemStack outStack = output.get(i).itemStack.copy(); - outStack.stackSize=Math.round(output.get(i).quantity); - if(this.input.get(i)!=null) - { - outStack.stackTagCompound=this.input.get(i).stackTagCompound; + outStack.stackSize = Math.round(output.get(i).quantity); + if (this.input.get(i) != null) { + outStack.stackTagCompound = this.input.get(i).stackTagCompound; } - this.input.put(i,outStack); + this.input.put(i, outStack); } - if(this.input.get(i)!=null && this.input.get(i).stackSize<=0)this.input.put(i, null); + if (this.input.get(i) != null && this.input.get(i).stackSize <= 0) + this.input.put(i, null); } } } - - public static void addRecipe(ItemStack input1, ItemStack output) - { - recipeManager.addRecipe(new UniversalRecipeInput(null, (new ItemStack [] {input1})),new UniversalRecipeOutput(null, (new ItemStack [] {output}),20)); + + public static void addRecipe(ItemStack input1, ItemStack output) { + recipeManager.addRecipe(new UniversalRecipeInput(null, (new ItemStack[] { input1 })), + new UniversalRecipeOutput(null, (new ItemStack[] { output }), 20)); } - public static Map getRecipes() { return recipeManager.getRecipes(); } - - @Override - public UniversalRecipeOutput getOutput() - { - return MuffleFurnanceTileEntity.recipeManager.getOutputFor(null,this.input.getItemStackList(), false, false); - } - - public static void addRecipe(UniversalRecipeInput universalRecipeInput, UniversalRecipeOutput universalRecipeOutput) - { + + @Override + public UniversalRecipeOutput getOutput() { + return MuffleFurnanceTileEntity.recipeManager.getOutputFor(null, this.input.getItemStackList(), false, false); + } + + public static void addRecipe(UniversalRecipeInput universalRecipeInput, + UniversalRecipeOutput universalRecipeOutput) { recipeManager.addRecipe(universalRecipeInput, universalRecipeOutput); } public static void addRecipe(ItemStack input1, ItemStack output, float f) { - recipeManager.addRecipe(new UniversalRecipeInput(null, (new ItemStack [] {input1})),new UniversalRecipeOutput(null, (new RecipeOutputItemStack [] {new RecipeOutputItemStack(output,f)}),20)); + recipeManager.addRecipe(new UniversalRecipeInput(null, (new ItemStack[] { input1 })), new UniversalRecipeOutput( + null, (new RecipeOutputItemStack[] { new RecipeOutputItemStack(output, f) }), 20)); } } diff --git a/ihl/processing/metallurgy/PassiveBlock.java b/ihl/processing/metallurgy/PassiveBlock.java deleted file mode 100644 index 74eb0e8..0000000 --- a/ihl/processing/metallurgy/PassiveBlock.java +++ /dev/null @@ -1,99 +0,0 @@ -package ihl.processing.metallurgy; - -import ihl.IHLCreativeTab; -import ihl.IHLModInfo; -import ihl.items_blocks.IHLItemBlock; -import ihl.utils.IHLUtils; -import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class PassiveBlock extends Block{ - - @SideOnly(Side.CLIENT) - private IIcon[][] textures; - - private static PassiveBlock instance; - - public PassiveBlock() - { - super(Material.iron); - this.setCreativeTab(IHLCreativeTab.tab); - this.setBlockName("IHLShieldAssemblyUnitBlock"); - this.setHardness(2F); - this.setResistance(1F); - instance=this; - } - - public static void init() - { - PassiveBlock block = new PassiveBlock(); - GameRegistry.registerBlock(block, IHLItemBlock.class, "IHLShieldAssemblyUnitBlock"); - Type[] var1 = Type.values(); - for(int i=0;i fluidTankFluidList; - private boolean vacuumPumpState=true; - - public VacuumInductionMeltingFurnaceContainer(EntityPlayer entityPlayer, VacuumInductionMeltingFurnaceTileEntity tileEntity1) { - super(tileEntity1); - this.tileEntity=tileEntity1; - fluidTankFluidList = this.tileEntity.fluidTank.getFluidList(); - this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 141, 8)); - } - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)this.crafters.get(i); - - if (this.tileEntity.fluidTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.fluidTank.getNumberOfFluids() != this.lastNumberOfFluids) - { - IC2.network.get().sendContainerField(this, "fluidTankFluidList"); - } - - if (this.tileEntity.progress != this.lastProgress) - { - icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); - } - - if (this.tileEntity.vacuumPumpConnected != this.vacuumPumpState) - { - icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.vacuumPumpConnected?1:0); - } - } - - this.lastNumberOfFluids = this.tileEntity.fluidTank.getNumberOfFluids(); - this.lastFluidAmount = this.tileEntity.fluidTank.getFluidAmount(); - this.lastProgress = this.tileEntity.progress; - this.vacuumPumpState = this.tileEntity.vacuumPumpConnected; - } - - @Override - public void updateProgressBar(int index, int value) - { - super.updateProgressBar(index, value); - switch (index) - { - case 0: - this.tileEntity.progress=(short) value; - break; - case 1: - this.tileEntity.vacuumPumpConnected=value>0; - break; - } - } - - @Override - public boolean canInteractWith(EntityPlayer var1) { - return tileEntity.isUseableByPlayer(var1); - } -} diff --git a/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java deleted file mode 100644 index 2f22a4d..0000000 --- a/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java +++ /dev/null @@ -1,85 +0,0 @@ -package ihl.processing.metallurgy; - -import ic2.core.IC2; -import ihl.collector.GuiMultiTextureButton; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -import org.lwjgl.opengl.GL11; - -public class VacuumInductionMeltingFurnaceGui extends GuiContainer { - protected static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIVacuumInductionMeltingFurnace.png"); - private VacuumInductionMeltingFurnaceContainer container; - private GuiMultiTextureButton button1; - private int timer=10; - - - public VacuumInductionMeltingFurnaceGui(VacuumInductionMeltingFurnaceContainer vacuumInductionMeltingFurnaceContainer) { - //the container is instanciated and passed to the superclass for handling - super(vacuumInductionMeltingFurnaceContainer); - this.container=vacuumInductionMeltingFurnaceContainer; - } - - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - button1=new GuiMultiTextureButton(0, x+13, y+55, 27, 27, background,13,55,229,229); - this.buttonList.add(button1); - } - - @Override - public void actionPerformed(GuiButton button) - { - super.actionPerformed(button); - IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, button.id); - if (button.id == 0) - { - button1.isActive=false; - timer=10; - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - fontRendererObj.drawString(StatCollector.translateToLocal("ihl.gui.muffleFurnace"), 40, 12, 14722081); - this.mc.renderEngine.bindTexture(background); - int i1; - if (this.container.tileEntity.getEnergy() > 0D) - { - i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); - this.drawTexturedModalRect(8, 6 + 12 - i1, 179, 12 - i1, 14, i1 + 2); - } - if (this.container.tileEntity.progress > 0) - { - i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(50),50); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - this.drawTexturedModalRect(64, 63, 197, 0, i1 + 1, 13); - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, - int par3) { - //draw your Gui here, only thing you need to change is the path - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - if(timer>0) - { - timer--; - } - if(timer==1) - { - button1.isActive=true; - } - } -} diff --git a/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java deleted file mode 100644 index e2867bc..0000000 --- a/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java +++ /dev/null @@ -1,200 +0,0 @@ -package ihl.processing.metallurgy; - -import java.util.Arrays; -import java.util.Map; - -import ic2.api.network.INetworkClientTileEntityEventListener; -import ic2.api.recipe.IRecipeInput; -import ic2.api.recipe.RecipeInputOreDict; -import ic2.core.ContainerBase; -import ihl.processing.chemistry.GaedesMercuryRotaryPumpTileEntity; -import ihl.recipes.UniversalRecipeInput; -import ihl.recipes.UniversalRecipeManager; -import ihl.recipes.UniversalRecipeOutput; -import ihl.utils.IHLFluidTank; -import ihl.utils.IHLUtils; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class VacuumInductionMeltingFurnaceTileEntity extends MachineBaseTileEntity implements INetworkClientTileEntityEventListener{ - - protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("vacuuminductionmeltingfurnace"); - public final IHLFluidTank fluidTank = new IHLFluidTank(864); - public boolean vacuumPumpConnected=false; - private GaedesMercuryRotaryPumpTileEntity lastGMRP; - - public VacuumInductionMeltingFurnaceTileEntity() - { - super(1); - } - - @Override - public void setFacing(short facing1) - { - short facing2 = (short) Math.max(facing1, 2); - super.setFacing(facing2); - } - - @Override - public String getStartSoundFile() { - return null; - } - - @Override - public String getLoopSoundFile() { - return null; - } - - @Override - public String getStopSoundFile() { - return null; - } - - @Override - public String getInventoryName() { - return "VacuumInductionMeltingFurnace"; - } - - @Override - @SideOnly(Side.CLIENT) - public GuiScreen getGui(EntityPlayer player, boolean arg1) { - return new VacuumInductionMeltingFurnaceGui(new VacuumInductionMeltingFurnaceContainer(player, this)); - } - - @Override - public ContainerBase getGuiContainer(EntityPlayer player) { - return new VacuumInductionMeltingFurnaceContainer(player, this); - } - - @Override - public void operate() - { - ItemStack content = this.input.get(); - if(content!=null) - { - UniversalRecipeOutput routput = recipeManager.getOutputFor(null, Arrays.asList(new ItemStack [] {content}),false, false); - if(routput!=null && !routput.getFluidOutputs().isEmpty()) - { - FluidStack fluidStack = routput.getFluidOutputs().get(0).copy(); - fluidStack.amount *= content.stackSize; - this.input.clear(); - this.fluidTank.fill(fluidStack, true); - useVacuumPump(); - } - } - } - - @Override - public boolean canOperate() - { - return checkSpecialConditionVacuumPump() && getOutput()!=null; - } - - private void useVacuumPump() - { - if(lastGMRP!=null && !lastGMRP.isInvalid() && lastGMRP.ready) - { - lastGMRP.ready=false; - } - } - - private boolean checkSpecialConditionVacuumPump() - { - if(lastGMRP!=null && !lastGMRP.isInvalid() && lastGMRP.ready) - { - this.vacuumPumpConnected=true; - return true; - } - int[] xz = new int [] {0,1,1,0,-1,-1,0}; - for(int i0=-1;i0<=0;i0++) - { - for(int i=0;i getRecipes() { - return recipeManager.getRecipes(); - } - - @Override - public UniversalRecipeOutput getOutput() - { - return VacuumInductionMeltingFurnaceTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); - } - - @Override - public void onNetworkEvent(EntityPlayer player, int event) - { - switch(event) - { - case 0: - TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord); - if(te instanceof InjectionMoldTileEntity) - { - InjectionMoldTileEntity im = (InjectionMoldTileEntity)te; - im.fill(ForgeDirection.UP, this.fluidTank.drain(this.fluidTank.getCapacity(), true), true); - } - break; - } - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - try - { - this.energy = nbttagcompound.getDouble("energy"); - } - catch (Exception var3)//This was blindlessly copied from IC2 source a lot of time ago. And this is not necessary here. And still... - { - this.energy = nbttagcompound.getInteger("energy"); - - if (this.maxStorage > Integer.MAX_VALUE) - { - this.energy *= 10.0D; - } - } - this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - nbttagcompound.setDouble("energy", this.energy); - NBTTagCompound fluidTankTag = new NBTTagCompound(); - this.fluidTank.writeToNBT(fluidTankTag); - nbttagcompound.setTag("fluidTank", fluidTankTag); - } -} diff --git a/ihl/recipes/RecipeInputOreDictionaryList.java b/ihl/recipes/RecipeInputOreDictionaryList.java index 572f15b..e438d98 100644 --- a/ihl/recipes/RecipeInputOreDictionaryList.java +++ b/ihl/recipes/RecipeInputOreDictionaryList.java @@ -10,140 +10,113 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -public class RecipeInputOreDictionaryList implements IRecipeInput -{ - - public final String[] input; - public final int amount; - public final Integer meta; - private List ores; - - public RecipeInputOreDictionaryList(String[] input1) - { - this(input1, 1); - } - - public RecipeInputOreDictionaryList(String[] input1, int amount1) - { - this(input1, amount1, (Integer)null); - } - - public RecipeInputOreDictionaryList(String[] input1, int amount1, Integer meta) - { - this.input = input1; - this.amount = amount1; - this.meta = meta; - } +public class RecipeInputOreDictionaryList implements IRecipeInput { + + public final String[] input; + public final int amount; + public final Integer meta; + private List ores; + + public RecipeInputOreDictionaryList(String[] input1) { + this(input1, 1); + } + + public RecipeInputOreDictionaryList(String[] input1, int amount1) { + this(input1, amount1, (Integer) null); + } + + public RecipeInputOreDictionaryList(String[] input1, int amount1, Integer meta) { + this.input = input1; + this.amount = amount1; + this.meta = meta; + } + + @Override + public boolean matches(ItemStack subject) { + List inputs = this.getOres(); + boolean useOreStackMeta = this.meta == null; + Item subjectItem = subject.getItem(); + int subjectMeta = subject.getItemDamage(); + Iterator i$ = inputs.iterator(); + Item oreItem; + int metaRequired; + + do { + do { + ItemStack oreStack; + + do { + if (!i$.hasNext()) { + return false; + } + + oreStack = i$.next(); + oreItem = oreStack.getItem(); + } while (oreItem == null); + + metaRequired = useOreStackMeta ? oreStack.getItemDamage() : this.meta.intValue(); + } while (subjectItem != oreItem); + } while (subjectMeta != metaRequired && metaRequired != 32767); + + return true; + } + + @Override + public int getAmount() { + return this.amount; + } + + @Override + public List getInputs() { + List ores = this.getOres(); + boolean hasInvalidEntries = false; + Iterator ret = ores.iterator(); + + while (ret.hasNext()) { + ItemStack i$ = ret.next(); + + if (i$.getItem() == null) { + hasInvalidEntries = true; + break; + } + } + + if (!hasInvalidEntries) { + return ores; + } else { + ArrayList ret1 = new ArrayList(ores.size()); + Iterator i$1 = ores.iterator(); + + while (i$1.hasNext()) { + ItemStack stack = i$1.next(); + + if (stack.getItem() != null) { + ret1.add(stack); + } + } + + return Collections.unmodifiableList(ret1); + } + } @Override - public boolean matches(ItemStack subject) - { - List inputs = this.getOres(); - boolean useOreStackMeta = this.meta == null; - Item subjectItem = subject.getItem(); - int subjectMeta = subject.getItemDamage(); - Iterator i$ = inputs.iterator(); - Item oreItem; - int metaRequired; - - do - { - do - { - ItemStack oreStack; - - do - { - if (!i$.hasNext()) - { - return false; - } - - oreStack = i$.next(); - oreItem = oreStack.getItem(); - } - while (oreItem == null); - - metaRequired = useOreStackMeta ? oreStack.getItemDamage() : this.meta.intValue(); - } - while (subjectItem != oreItem); - } - while (subjectMeta != metaRequired && metaRequired != 32767); - - return true; - } - - @Override - public int getAmount() - { - return this.amount; - } - - @Override - public List getInputs() - { - List ores = this.getOres(); - boolean hasInvalidEntries = false; - Iterator ret = ores.iterator(); - - while (ret.hasNext()) - { - ItemStack i$ = ret.next(); - - if (i$.getItem() == null) - { - hasInvalidEntries = true; - break; - } - } - - if (!hasInvalidEntries) - { - return ores; - } - else - { - ArrayList ret1 = new ArrayList(ores.size()); - Iterator i$1 = ores.iterator(); - - while (i$1.hasNext()) - { - ItemStack stack = i$1.next(); - - if (stack.getItem() != null) - { - ret1.add(stack); - } - } - - return Collections.unmodifiableList(ret1); - } - } - - @Override - public String toString() - { - return this.meta == null ? "RInputOreDict<" + this.amount + "x" + this.input + ">" : "RInputOreDict<" + this.amount + "x" + this.input + "@" + this.meta + ">"; - } - - private List getOres() - { - if (this.ores != null) - { - return this.ores; - } - else - { - this.ores = new ArrayList(); - for(int i=0;i ret = OreDictionary.getOres(this.input[i]); - if (ret != OreDictionary.EMPTY_LIST) - { - this.ores.addAll(ret); - } - } - return this.ores; - } - } + public String toString() { + return this.meta == null ? "RInputOreDict<" + this.amount + "x" + this.input + ">" + : "RInputOreDict<" + this.amount + "x" + this.input + "@" + this.meta + ">"; + } + + private List getOres() { + if (this.ores != null) { + return this.ores; + } else { + this.ores = new ArrayList(); + for (int i = 0; i < this.input.length; i++) { + ArrayList ret = OreDictionary.getOres(this.input[i]); + if (ret != OreDictionary.EMPTY_LIST) { + this.ores.addAll(ret); + } + } + return this.ores; + } + } } diff --git a/ihl/recipes/RecipeInputWire.java b/ihl/recipes/RecipeInputWire.java index 0bf2855..a7d5310 100644 --- a/ihl/recipes/RecipeInputWire.java +++ b/ihl/recipes/RecipeInputWire.java @@ -9,79 +9,64 @@ import ihl.items_blocks.FlexibleCableItem; import ihl.utils.IHLUtils; import net.minecraft.item.ItemStack; -public class RecipeInputWire implements IRecipeInput -{ - public final ItemStack input; - public final int amount; +public class RecipeInputWire implements IRecipeInput { + public final ItemStack input; + public final int amount; - public RecipeInputWire(final ItemStack aInput) - { - this(aInput, IHLUtils.getWireLength(aInput)); - } + public RecipeInputWire(final ItemStack aInput) { + this(aInput, IHLUtils.getWireLength(aInput)); + } - public RecipeInputWire(final ItemStack aInput, int aAmount) - { - if (aInput.getItem() == null || !(aInput.getItem() instanceof IWire)) - { - throw new IllegalArgumentException("Invalid item stack specfied"); - } - else - { - this.input = aInput; - this.amount = aAmount; - } - } + public RecipeInputWire(final ItemStack aInput, int aAmount) { + if (aInput.getItem() == null || !(aInput.getItem() instanceof IWire)) { + throw new IllegalArgumentException("Invalid item stack specfied"); + } else { + this.input = aInput; + this.amount = aAmount; + } + } - public RecipeInputWire(String string, int i) - { - this(IHLUtils.getThisModWireItemStackWithLength(string, i),i); + public RecipeInputWire(String string, int i) { + this(IHLUtils.getThisModWireItemStackWithLength(string, i), i); } - - public RecipeInputWire(String material, int length, int transverseSection) - { - this(IHLUtils.getUninsulatedWire(material, length, transverseSection),length); + + public RecipeInputWire(String material, int length, int transverseSection) { + this(IHLUtils.getUninsulatedWire(material, length, transverseSection), length); } - - public RecipeInputWire(String material, int length, int transverseSection, String insulationMaterial, int insulationThickness, int insulationBreakdownVoltage) - { - this(IHLUtils.getInsulatedWire(material, length, transverseSection, insulationMaterial, insulationThickness),length); + + public RecipeInputWire(String material, int length, int transverseSection, String insulationMaterial, + int insulationThickness, int insulationBreakdownVoltage) { + this(IHLUtils.getInsulatedWire(material, length, transverseSection, insulationMaterial, insulationThickness), + length); } @Override - public boolean matches(ItemStack subject) - { - if(subject.getItem() == this.input.getItem() && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767)) - { - if(subject.getItem() instanceof FlexibleCableItem) - { - FlexibleCableItem item = (FlexibleCableItem) subject.getItem(); - return item.isSameWire(this.input, subject); - } - else - { - return true; - } - } - return false; - } + public boolean matches(ItemStack subject) { + if (subject.getItem() == this.input.getItem() + && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767)) { + if (subject.getItem() instanceof FlexibleCableItem) { + FlexibleCableItem item = (FlexibleCableItem) subject.getItem(); + return item.isSameWire(this.input, subject); + } else { + return true; + } + } + return false; + } - @Override - public int getAmount() - { - return this.amount; - } + @Override + public int getAmount() { + return this.amount; + } - @Override - public List getInputs() - { - return Arrays.asList(new ItemStack[] {this.input}); - } + @Override + public List getInputs() { + return Arrays.asList(new ItemStack[] { this.input }); + } - @Override - public String toString() - { - ItemStack stack = this.input.copy(); - return "RInputWireItemStack<" + stack + ">"; - } + @Override + public String toString() { + ItemStack stack = this.input.copy(); + return "RInputWireItemStack<" + stack + ">"; + } } - diff --git a/ihl/recipes/UniversalRecipeInput.java b/ihl/recipes/UniversalRecipeInput.java index 62d6c87..a654c2e 100644 --- a/ihl/recipes/UniversalRecipeInput.java +++ b/ihl/recipes/UniversalRecipeInput.java @@ -132,7 +132,7 @@ public class UniversalRecipeInput { multiplier = multiplier1; } } - if (IHLUtils.reduceItemStackAmountUsingIRecipeInput(is, is1)) { + if (IHLUtils.reduceItemStackAmountUsingIRecipeInput(is, is1, multiplier)) { is1 = null; } } diff --git a/ihl/recipes/UniversalRecipeManager.java b/ihl/recipes/UniversalRecipeManager.java index 99f43bc..169d6f6 100644 --- a/ihl/recipes/UniversalRecipeManager.java +++ b/ihl/recipes/UniversalRecipeManager.java @@ -12,237 +12,188 @@ import net.minecraftforge.fluids.FluidStack; import ihl.utils.IHLUtils; public class UniversalRecipeManager { - - public static Map machineRecipeManagers = new HashMap(); + + public static Map machineRecipeManagers = new HashMap(); public final String machine; - public UniversalRecipeManager(String machine1) - { - machine=machine1; - if(machineRecipeManagers.containsKey(machine1)) - { - throw new IllegalArgumentException("Recipe manager for "+machine1+" already exist!"); + + public UniversalRecipeManager(String machine1) { + machine = machine1; + if (machineRecipeManagers.containsKey(machine1)) { + throw new IllegalArgumentException("Recipe manager for " + machine1 + " already exist!"); } machineRecipeManagers.put(machine1, this); } private final Map recipes = new HashMap(); private final Map keywordMap = new HashMap(); - - public void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) - { - if (input == null) - { - throw new NullPointerException("The recipe input is null"); - } - else - { - if (output.getFluidOutputs() == null || output.getItemOutputs() == null ||(output.getFluidOutputs().size()==0 && output.getItemOutputs().size()==0)) - { - throw new NullPointerException("The output is empty"); - } - } - - Iterator var8 = this.recipes.keySet().iterator(); - - while (var8.hasNext()) - { - UniversalRecipeInput existingInput = (UniversalRecipeInput)var8.next(); - if (existingInput.matches(input)) - { - StringBuffer ssError =new StringBuffer(255); - ssError.append("Ambiguous recipe. \n"); - ssError.append("Existing input: \n"); - Iterator iii1 = existingInput.getItemInputs().iterator(); - Iterator fii1 = existingInput.getFluidInputs().iterator(); - while(iii1!=null && iii1.hasNext()) - { - ssError.append(iii1.next().toString()); - ssError.append(" \n"); - } - while(fii1!=null && fii1.hasNext()) - { - ssError.append(fii1.next().toString()); - ssError.append(" \n"); - } - ssError.append("New input: \n"); - Iterator iii2 = input.getItemInputs().iterator(); - Iterator fii2 = input.getFluidInputs().iterator(); - while(iii2!=null && iii2.hasNext()) - { - ssError.append(iii2.next().toString()); - ssError.append(" \n"); - } - while(fii2!=null && fii2.hasNext()) - { - ssError.append(fii2.next().toString()); - ssError.append(" \n"); - } - throw new RuntimeException(ssError.toString()); - } - } - - this.recipes.put(input, output); - } - - public void addRecipe(String keyword, UniversalRecipeInput input, UniversalRecipeOutput output) - { - this.addRecipe(input, output); - this.keywordMap.put(keyword, input); - } - - public UniversalRecipeOutput getOutputFor(List fluidInputs, List itemInputs, boolean adjustInput, boolean inputAffectOutput) - { - if (fluidInputs == null && itemInputs == null) - { - return null; - } - else - { - Iterator> i$ = this.recipes.entrySet().iterator(); - - while (true) - { - if (i$.hasNext()) - { - Entry entry = i$.next(); - UniversalRecipeInput recipeInput = entry.getKey(); - - if (!recipeInput.matches(fluidInputs, itemInputs)) - { - continue; - } - - if (recipeInput.adjustAmounts(fluidInputs, itemInputs,true, false)) - { - UniversalRecipeOutput output = entry.getValue(); - if (adjustInput) - { - if(inputAffectOutput) - { - int multiplier = recipeInput.getMultiplierAndAdjustAmounts(fluidInputs, itemInputs); - return output.copyWithMultiplier(multiplier); - } - else - { - recipeInput.adjustAmounts(fluidInputs, itemInputs,true, true); - } - } - return output; - } - } - - return null; - } - } - } - - public Map getRecipes() - { - return this.recipes; - } + public void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) { + if (input == null) { + throw new NullPointerException("The recipe input is null"); + } else { + if (output.getFluidOutputs() == null || output.getItemOutputs() == null + || (output.getFluidOutputs().size() == 0 && output.getItemOutputs().size() == 0)) { + throw new NullPointerException("The output is empty"); + } + } - public UniversalRecipeInput getRecipeInput(List fluidInputs1, List itemInputs1) { - { - Iterator> i$ = this.recipes.entrySet().iterator(); - - while (true) - { - if (i$.hasNext()) - { - Entry entry = i$.next(); - UniversalRecipeInput recipeInput = entry.getKey(); - - if (!recipeInput.matches(fluidInputs1,itemInputs1)) - { - continue; - } - - if (recipeInput.adjustAmounts(fluidInputs1,itemInputs1,true, false)) - { - return recipeInput; - } - } - - return null; - } - } + Iterator var8 = this.recipes.keySet().iterator(); + + while (var8.hasNext()) { + UniversalRecipeInput existingInput = (UniversalRecipeInput) var8.next(); + if (existingInput.matches(input)) { + StringBuffer ssError = new StringBuffer(255); + ssError.append("Ambiguous recipe. \n"); + ssError.append("Existing input: \n"); + Iterator iii1 = existingInput.getItemInputs().iterator(); + Iterator fii1 = existingInput.getFluidInputs().iterator(); + while (iii1 != null && iii1.hasNext()) { + ssError.append(iii1.next().toString()); + ssError.append(" \n"); + } + while (fii1 != null && fii1.hasNext()) { + ssError.append(fii1.next().toString()); + ssError.append(" \n"); + } + ssError.append("New input: \n"); + Iterator iii2 = input.getItemInputs().iterator(); + Iterator fii2 = input.getFluidInputs().iterator(); + while (iii2 != null && iii2.hasNext()) { + ssError.append(iii2.next().toString()); + ssError.append(" \n"); + } + while (fii2 != null && fii2.hasNext()) { + ssError.append(fii2.next().toString()); + ssError.append(" \n"); + } + throw new RuntimeException(ssError.toString()); + } + } + + this.recipes.put(input, output); + } + + public void addRecipe(String keyword, UniversalRecipeInput input, UniversalRecipeOutput output) { + this.addRecipe(input, output); + this.keywordMap.put(keyword, input); + } + + public UniversalRecipeOutput getOutputFor(List fluidInputs, List itemInputs, + boolean adjustInput, boolean inputAffectOutput) { + if (fluidInputs == null && itemInputs == null) { + return null; + } else { + Iterator> i$ = this.recipes.entrySet().iterator(); + + while (true) { + if (i$.hasNext()) { + Entry entry = i$.next(); + UniversalRecipeInput recipeInput = entry.getKey(); + + if (!recipeInput.matches(fluidInputs, itemInputs)) { + continue; + } + + if (recipeInput.adjustAmounts(fluidInputs, itemInputs, true, false)) { + UniversalRecipeOutput output = entry.getValue(); + if (inputAffectOutput) { + int multiplier = recipeInput.getMultiplierAndAdjustAmounts(fluidInputs, itemInputs); + return output.copyWithMultiplier(multiplier); + } else if (adjustInput) { + recipeInput.adjustAmounts(fluidInputs, itemInputs, true, true); + } + return output; + } + } + + return null; + } + } + } + + public Map getRecipes() { + return this.recipes; } + public UniversalRecipeInput getRecipeInput(List fluidInputs1, List itemInputs1) { + { + Iterator> i$ = this.recipes.entrySet().iterator(); + + while (true) { + if (i$.hasNext()) { + Entry entry = i$.next(); + UniversalRecipeInput recipeInput = entry.getKey(); + + if (!recipeInput.matches(fluidInputs1, itemInputs1)) { + continue; + } + + if (recipeInput.adjustAmounts(fluidInputs1, itemInputs1, true, false)) { + return recipeInput; + } + } + + return null; + } + } + } @SuppressWarnings({ "unchecked", "rawtypes" }) - public UniversalRecipeOutput getOutputFor(List[] input, boolean adjustInput, boolean inputAffectOutput) - { + public UniversalRecipeOutput getOutputFor(List[] input, boolean adjustInput, boolean inputAffectOutput) { return this.getOutputFor(input[0], input[1], adjustInput, inputAffectOutput); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public UniversalRecipeInput getRecipeInput(List[] input) - { + public UniversalRecipeInput getRecipeInput(List[] input) { return this.getRecipeInput(input[0], input[1]); } - - public void removeRecipeByInput(UniversalRecipeInput uRecipeInput) - { + public void removeRecipeByInput(UniversalRecipeInput uRecipeInput) { List fluidInputs = IHLUtils.convertRecipeInputToFluidStackList(uRecipeInput.getFluidInputs()); List itemInputs = IHLUtils.convertRecipeInputToItemStackList(uRecipeInput.getItemInputs()); - { - Iterator> i$ = this.recipes.entrySet().iterator(); - while (i$.hasNext()) - { - Entry entry = i$.next(); - UniversalRecipeInput recipeInput = entry.getKey(); - if (recipeInput.matches(fluidInputs, itemInputs)) - { - i$.remove(); - break; - } - } - } + { + Iterator> i$ = this.recipes.entrySet().iterator(); + while (i$.hasNext()) { + Entry entry = i$.next(); + UniversalRecipeInput recipeInput = entry.getKey(); + if (recipeInput.matches(fluidInputs, itemInputs)) { + i$.remove(); + break; + } + } + } } - public void removeRecipeByOutput(UniversalRecipeOutput uRecipeOutput) - { + public void removeRecipeByOutput(UniversalRecipeOutput uRecipeOutput) { Iterator> i$ = this.recipes.entrySet().iterator(); - while (i$.hasNext()) - { - Entry entry = i$.next(); - UniversalRecipeOutput recipeOutput = entry.getValue(); - if (recipeOutputHasCommonEntries(recipeOutput,uRecipeOutput)) - { - i$.remove(); - } - } + while (i$.hasNext()) { + Entry entry = i$.next(); + UniversalRecipeOutput recipeOutput = entry.getValue(); + if (recipeOutputHasCommonEntries(recipeOutput, uRecipeOutput)) { + i$.remove(); + } + } } - - public boolean recipeOutputHasCommonEntries(UniversalRecipeOutput out, UniversalRecipeOutput out1) - { + + public boolean recipeOutputHasCommonEntries(UniversalRecipeOutput out, UniversalRecipeOutput out1) { List fluidOutputs = out.getFluidOutputs(); List itemOutputs = out.getItemOutputs(); - if(!fluidOutputs.isEmpty() && !out1.getFluidOutputs().isEmpty()) - { + if (!fluidOutputs.isEmpty() && !out1.getFluidOutputs().isEmpty()) { FluidStack fs1 = out1.getFluidOutputs().get(0); Iterator fi = fluidOutputs.iterator(); - while(fi.hasNext()) - { + while (fi.hasNext()) { FluidStack fs = fi.next(); - if(fs.getFluid()==fs1.getFluid()) - { + if (fs.getFluid() == fs1.getFluid()) { return true; } } } - if(!itemOutputs.isEmpty() && !out1.getItemOutputs().isEmpty()) - { + if (!itemOutputs.isEmpty() && !out1.getItemOutputs().isEmpty()) { RecipeOutputItemStack is1 = out1.getItemOutputs().get(0); Iterator ii = itemOutputs.iterator(); - while(ii.hasNext()) - { + while (ii.hasNext()) { RecipeOutputItemStack is = ii.next(); - if(is.matches(is1)) - { + if (is.matches(is1)) { return true; } } diff --git a/ihl/tunneling_shield/BlockItemRender.java b/ihl/tunneling_shield/BlockItemRender.java deleted file mode 100644 index 27b0f04..0000000 --- a/ihl/tunneling_shield/BlockItemRender.java +++ /dev/null @@ -1,206 +0,0 @@ -package ihl.tunneling_shield; - -import ic2.core.block.RenderBlockDefault; -import ihl.items_blocks.IHLItemBlock; -import ihl.model.IHLModelRenderer; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.IItemRenderer; -import org.lwjgl.opengl.GL11; - -public class BlockItemRender implements IItemRenderer{ - private ModelBase model; - private ResourceLocation tex; - private int renderFrom=0; - private int renderTo=0; - private RenderBlockDefault rbd; - private float amendment=0.0F; - private float inventoryOffset=0.0F; - private boolean renderHand; - -public BlockItemRender() -{ - rbd=new RenderBlockDefault(); -} - -public BlockItemRender(ModelBase model1, ResourceLocation texture, int renderFrom1, int renderTo1, float amendment1, float inventoryOffset1) -{ - this.model=model1; - this.tex=texture; - this.renderFrom=renderFrom1; - this.renderTo=renderTo1; - this.amendment=amendment1; - this.inventoryOffset=inventoryOffset1; - this.renderHand=false; -} - -public BlockItemRender(ModelBase model1, ResourceLocation texture, int renderFrom1, int renderTo1, float amendment1, float inventoryOffset1, boolean renderHand1) -{ - this.model=model1; - this.tex=texture; - this.renderFrom=renderFrom1; - this.renderTo=renderTo1; - this.amendment=amendment1; - this.inventoryOffset=inventoryOffset1; - this.renderHand=renderHand1; -} - -@Override -public boolean handleRenderType(ItemStack item, ItemRenderType type) { - switch (type) { - case ENTITY: - return true; - case EQUIPPED: - return true; - case EQUIPPED_FIRST_PERSON: - return true; - case INVENTORY: - return true; - default: - return false; - } -} - -@Override -public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { - return true; -} - -@Override -public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - if(tex!=null) - { - Minecraft.getMinecraft().renderEngine.bindTexture(tex); - } - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - IHLItemBlock bItem =(IHLItemBlock) item.getItem(); - Block block = bItem.getBlockContained(); - GL11.glScalef(1F, -1F+amendment, -1F); - switch (type) { - case ENTITY: - GL11.glTranslatef(0,-1.5F,0); - if(model!=null) - { - for(int i = this.renderFrom;i { - - protected DriverTileEntity tileEntity; - public int lastStorage = -1; - private final static int height=166; - - public DriverContainer(EntityPlayer entityPlayer, DriverTileEntity tileEntity1){ - super(tileEntity1); - this.tileEntity = tileEntity1; - int col; - - for (col = 0; col < 3; ++col) - { - for (int col1 = 0; col1 < 9; ++col1) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); - } - } - - for (col = 0; col < 9; ++col) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); - } - this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 26, 26)); - this.addSlotToContainer(new SlotInvSlot(tileEntity1.miningPipesSlot, 0, 48, 26)); - for(int row=0;row<=3;row++) - { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, row, 152, 8+row*18)); - } - } - - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)this.crafters.get(i); - - if (this.tileEntity.getStored() != this.lastStorage) - { - icrafting.sendProgressBarUpdate(this, 0, (this.tileEntity.getStored()>>15) & Short.MAX_VALUE); - icrafting.sendProgressBarUpdate(this, 1, (short)(this.tileEntity.getStored() & Short.MAX_VALUE)); - - } - } - - this.lastStorage = this.tileEntity.getStored(); - } - - @Override - public void updateProgressBar(int index, int value) - { - super.updateProgressBar(index, value); - - switch (index) - { - case 0: - this.tileEntity.setStored(value<<15); - break; - case 1: - this.tileEntity.setStored(this.tileEntity.getStored()+value); - break; - } - } - - @Override - public boolean canInteractWith(EntityPlayer var1) { - return tileEntity.isUseableByPlayer(var1); - } -} diff --git a/ihl/tunneling_shield/DriverEntity.java b/ihl/tunneling_shield/DriverEntity.java deleted file mode 100644 index e7e1c90..0000000 --- a/ihl/tunneling_shield/DriverEntity.java +++ /dev/null @@ -1,69 +0,0 @@ -package ihl.tunneling_shield; - -import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -public class DriverEntity extends Entity { - - public DriverTileEntity parent; - - public DriverEntity(World arg0) - { - super(arg0); - this.ignoreFrustumCheck = true; - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.noClip=true; - } - - public DriverEntity(World arg0, DriverTileEntity te, int x, int y, int z) - { - super(arg0); - this.parent=te; - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.lastTickPosX = this.prevPosX = this.posX = x; - this.lastTickPosY = this.prevPosY = this.posY = y; - this.lastTickPosZ = this.prevPosZ = this.posZ = z; - this.ignoreFrustumCheck = true; - } - - @Override - public boolean isInRangeToRenderDist(double par1) - { - return true; - } - - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(this.parent!=null) - { - this.motionX = 0.0D; - this.motionY = 0.0D; - this.motionZ = 0.0D; - this.lastTickPosX = this.prevPosX = this.posX =this.parent.xCoord+this.parent.getModelShiftAmount()*this.parent.mX(); - this.lastTickPosY = this.prevPosY = this.posY =(this.parent.yCoord); - this.lastTickPosZ = this.prevPosZ = this.posZ =this.parent.zCoord+this.parent.getModelShiftAmount()*this.parent.mZ(); - } - else - { - this.setDead(); - } - } - - @Override - protected void entityInit() {} - - @Override - protected void readEntityFromNBT(NBTTagCompound nbt) {} - - @Override - protected void writeEntityToNBT(NBTTagCompound nbt) {} -} diff --git a/ihl/tunneling_shield/DriverGui.java b/ihl/tunneling_shield/DriverGui.java deleted file mode 100644 index 446c9f1..0000000 --- a/ihl/tunneling_shield/DriverGui.java +++ /dev/null @@ -1,102 +0,0 @@ -package ihl.tunneling_shield; - -import cpw.mods.fml.relauncher.Side; - -import cpw.mods.fml.relauncher.SideOnly; -import ic2.core.IC2; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class DriverGui extends GuiContainer { - private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDriver.png"); - private DriverContainer container; - - public DriverGui (DriverContainer container1) { - //the container is instanciated and passed to the superclass for handling - super(container1); - this.container=container1; - } - - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - this.buttonList.add(new GuiButton(0, x+6, y+62, 20, 20, "R")); - this.buttonList.add(new GuiButton(1, x+6, y+42, 20, 20, "A")); - } - - @Override - public void actionPerformed(GuiButton button) - { - super.actionPerformed(button); - if (button.id == 0) - { - IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 0); - } - if (button.id == 1) - { - IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 1); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int param1, int param2) { - //the parameters for drawString are: string, x, y, color - String title = StatCollector.translateToLocal("ihl.gui.ts02"); - fontRendererObj.drawStringWithShadow(title, 8, 8, 16767839); - String reverseModeOn; - if(this.container.tileEntity.reverseModeOn) - { - reverseModeOn = StatCollector.translateToLocal("ihl.gui.ts02reverse_on"); - fontRendererObj.drawStringWithShadow(reverseModeOn, 30, 68, 16767839); - } - else - { - reverseModeOn = StatCollector.translateToLocal("ihl.gui.ts02reverse_off"); - fontRendererObj.drawString(reverseModeOn, 30, 68, 8947848); - } - - String autoReverseModeOn; - if(this.container.tileEntity.autoReverseModeOn) - { - autoReverseModeOn = StatCollector.translateToLocal("ihl.gui.ts02auto_reverse_on"); - fontRendererObj.drawStringWithShadow(autoReverseModeOn, 30, 48, 16767839); - } - else - { - autoReverseModeOn = StatCollector.translateToLocal("ihl.gui.ts02auto_reverse_off"); - fontRendererObj.drawString(autoReverseModeOn, 30, 48, 8947848); - } - //draws "Inventory" or your regional equivalent - //fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - //charge - if (this.container.tileEntity.getStored() > 0) - { - int chargeLevel=Math.min(Math.round(this.container.tileEntity.getStored()*13.0F/this.container.tileEntity.maxStorage),13); - this.drawTexturedModalRect(11, 28+13-chargeLevel, xSize, 13-chargeLevel, 7, chargeLevel); - } - - - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, - int par3) { - //draw your Gui here, only thing you need to change is the path - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } -} \ No newline at end of file diff --git a/ihl/tunneling_shield/DriverModel.java b/ihl/tunneling_shield/DriverModel.java deleted file mode 100644 index edb8aa8..0000000 --- a/ihl/tunneling_shield/DriverModel.java +++ /dev/null @@ -1,161 +0,0 @@ -package ihl.tunneling_shield; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; - -public class DriverModel extends ModelBase { - //fields - ModelRenderer Shield; - ModelRenderer ShieldA; - ModelRenderer ShieldB; - ModelRenderer ShieldC; - ModelRenderer AdvancedShieldA; - - ModelRenderer Base; - ModelRenderer ShaftA; - ModelRenderer ShaftB; - - public DriverModel() - { - textureWidth = 512; - textureHeight = 256; - setTextureOffset("ShieldB.Shape1", 0, 84); - setTextureOffset("ShieldB.Shape2", 0, 84); - setTextureOffset("ShieldB.Shape3", 0, 84); - setTextureOffset("ShieldB.Shape4", 0, 84); - setTextureOffset("ShieldC.Shape1", 0, 84); - setTextureOffset("ShieldC.Shape2", 0, 84); - setTextureOffset("ShieldC.Shape3", 0, 84); - setTextureOffset("ShieldC.Shape4", 0, 84); - setTextureOffset("ShieldA.Shape1", 0, 132); - setTextureOffset("ShieldA.Shape2", 0, 132); - setTextureOffset("ShieldA.Shape3", 0, 132); - - setTextureOffset("AdvancedShieldA.Shape1", 173, 132); - setTextureOffset("AdvancedShieldA.Shape2", 173, 132); - setTextureOffset("AdvancedShieldA.Shape3", 173, 132); - - setTextureOffset("Shield.Shape1", 0, 0); - setTextureOffset("Shield.Shape2", 0, 0); - setTextureOffset("Shield.Shape3", 0, 0); - setTextureOffset("Shield.Shape4", 98, 84); - setTextureOffset("Shield.Shape5", 98, 84); - setTextureOffset("Shield.Shape6", 0, 0); - setTextureOffset("Shield.Shape7", 0, 0); - setTextureOffset("Shield.Shape8", 98, 84); - setTextureOffset("Shield.Shape9", 0, 0); - setTextureOffset("Shield.Shape10", 0, 0); - setTextureOffset("Shield.Shape11", 98, 84); - - setTextureOffset("Base.Base1", 80, 0); - setTextureOffset("Base.Base2", 83, 0); - setTextureOffset("Base.Base3", 98, 0); - setTextureOffset("Base.Base4", 98, 0); - setTextureOffset("Base.Base5", 98, 4); - setTextureOffset("Base.Base6", 98, 4); - setTextureOffset("Base.Base7", 103, 1); - setTextureOffset("Base.Base8", 98, 0); - setTextureOffset("Base.Base9", 98, 0); - setTextureOffset("Base.Base10", 98, 0); - setTextureOffset("Base.Base11", 98, 0); - setTextureOffset("Base.Base12", 98, 0); - setTextureOffset("Base.Base13", 99, 3); - setTextureOffset("ShaftA.ShapeA", 144, 0); - setTextureOffset("ShaftB.ShapeA", 144, 0); - - ShieldB = new ModelRenderer(this, "ShieldB"); - ShieldB.setRotationPoint(0F, 16F, 0F); - setRotation(ShieldB, 0F, 0F, 0F); - ShieldB.mirror = true; - ShieldB.addBox("Shape1", -7F, -36F, 9F, 14, 16, 12); - ShieldB.addBox("Shape2", 20F, -7F, 9F, 16, 14, 12); - ShieldB.addBox("Shape3", -36F, -7F, 9F, 16, 14, 12); - ShieldB.addBox("Shape4", -7F, 20F, 9F, 14, 16, 12); - ShieldC = new ModelRenderer(this, "ShieldB"); - ShieldC.setRotationPoint(0F, 16F, 0F); - setRotation(ShieldC, 0F, 0F, 0F); - ShieldC.mirror = true; - ShieldC.addBox("Shape1", -7F, -36F, 9F, 14, 16, 12); - ShieldC.addBox("Shape2", 20F, -7F, 9F, 16, 14, 12); - ShieldC.addBox("Shape3", -36F, -7F, 9F, 16, 14, 12); - ShieldC.addBox("Shape4", -7F, 20F, 9F, 14, 16, 12); - ShieldA = new ModelRenderer(this, "ShieldA"); - ShieldA.setRotationPoint(0F, 16F, 0F); - setRotation(ShieldA, 0F, 0F, 0F); - ShieldA.mirror = true; - ShieldA.addBox("Shape1", -36F, -8F, 10F, 72, 16, 12); - ShieldA.addBox("Shape2", -8F, -36F, 10F, 16, 28, 12); - ShieldA.addBox("Shape3", -8F, 8F, 10F, 16, 28, 12); - - AdvancedShieldA = new ModelRenderer(this, "AdvancedShieldA"); - AdvancedShieldA.setRotationPoint(0F, 16F, 0F); - setRotation(AdvancedShieldA, 0F, 0F, 0F); - AdvancedShieldA.mirror = true; - AdvancedShieldA.addBox("Shape1", -36F, -8F, 10F, 72, 16, 12); - AdvancedShieldA.addBox("Shape2", -8F, -36F, 10F, 16, 28, 12); - AdvancedShieldA.addBox("Shape3", -8F, 8F, 10F, 16, 28, 12); - - Shield = new ModelRenderer(this, "Shield"); - Shield.setRotationPoint(0F, 16F, 0F); - setRotation(Shield, 0F, 0F, 0F); - Shield.mirror = true; - Shield.addBox("Shape1", -6F, -6F, 8F, 12, 12, 2); - Shield.addBox("Shape2", -8F, -35F, 11F, 7, 70, 12); - Shield.addBox("Shape3", 1F, -35F, 11F, 7, 70, 12); - Shield.addBox("Shape4", -2F, -36F, 20F, 2, 36, 4); - Shield.addBox("Shape5", 0F, 0F, 20F, 2, 36, 4); - Shield.addBox("Shape6", -35F, 1F, 11F, 27, 7, 12); - Shield.addBox("Shape7", -35F, -8F, 11F, 27, 7, 12); - Shield.addBox("Shape8", -36F, 0F, 20F, 28, 2, 4); - Shield.addBox("Shape9", 8F, 1F, 11F, 27, 7, 12); - Shield.addBox("Shape10", 8F, -8F, 11F, 27, 7, 12); - Shield.addBox("Shape11", 8F, -2F, 20F, 28, 2, 4); - - Base = new ModelRenderer(this, "Base"); - Base.setRotationPoint(-8F, 16F, 0F); - setRotation(Base, 0F, 0F, 0F); - Base.mirror = true; - Base.addBox("Base1", 0F, 7F, -8F, 16, 1, 16); - Base.addBox("Base2", 1F, -7F, -7F, 14, 13, 15); - Base.addBox("Base3", 0F, -6F, -6F, 1, 1, 13); - Base.addBox("Base4", 2F, -8F, -6F, 1, 1, 13); - Base.addBox("Base5", 0F, -4F, -6F, 1, 7, 14); - Base.addBox("Base6", 15F, -4F, -6F, 1, 7, 14); - Base.addBox("Base7", 5F, -8F, -6F, 6, 1, 14); - Base.addBox("Base8", 3F, 6F, -7F, 10, 1, 15); - Base.addBox("Base9", 0F, 4F, -6F, 1, 1, 13); - Base.addBox("Base10", 13F, -8F, -6F, 1, 1, 13); - Base.addBox("Base11", 15F, -6F, -6F, 1, 1, 13); - Base.addBox("Base12", 15F, 4F, -6F, 1, 1, 13); - Base.addBox("Base13", 3F, -5F, -8F, 10, 9, 1); - - ShaftA = new ModelRenderer(this, "ShaftA"); - ShaftA.setRotationPoint(0F, 16F, 0F); - setRotation(ShaftA, 0F, 0F, 0F); - ShaftA.mirror = true; - ShaftA.addBox("ShapeA", -5F, -5F, -0F, 10, 10, 8); - - ShaftB = new ModelRenderer(this, "ShaftB"); - ShaftB.setRotationPoint(0F, 16F, 0F); - setRotation(ShaftB, 0F, 0F, 0F); - ShaftB.mirror = true; - ShaftB.addBox("ShapeA", -5F, -5F, -8F, 10, 10, 8); - - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } - - @Override - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) - { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } -} - - diff --git a/ihl/tunneling_shield/DriverRender.java b/ihl/tunneling_shield/DriverRender.java deleted file mode 100644 index e2c6802..0000000 --- a/ihl/tunneling_shield/DriverRender.java +++ /dev/null @@ -1,50 +0,0 @@ -package ihl.tunneling_shield; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import ihl.IHLModInfo; - -public class DriverRender extends TileEntitySpecialRenderer{ -private DriverModel model = new DriverModel(); -private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/shield.png"); - -public DriverRender(){} - -public void renderAModelAt(DriverTileEntity tile, double d, double d1, double d2, float f) { -int rotation = 0; -if(tile.getWorldObj() != null) -{ - switch (tile.getFacing()) - { - case 2: - rotation = 0; - break; - case 5: - rotation = 1; - break; - case 3: - rotation = 2; - break; - case 4: - rotation = 3; - break; - default: - rotation = 0; - } -} -bindTexture(tex); //texture -GL11.glPushMatrix(); -GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); -GL11.glScalef(1.0F, -1F, -1F); -GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); -model.Base.render(1.0F/16.0F); -GL11.glPopMatrix(); //end -} - -@Override -public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) -{ -this.renderAModelAt((DriverTileEntity)par1TileEntity, par2, par4, par6, par8); -} -} \ No newline at end of file diff --git a/ihl/tunneling_shield/DriverRenderEntity.java b/ihl/tunneling_shield/DriverRenderEntity.java deleted file mode 100644 index 40ed977..0000000 --- a/ihl/tunneling_shield/DriverRenderEntity.java +++ /dev/null @@ -1,147 +0,0 @@ -package ihl.tunneling_shield; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import ihl.IHLModInfo; - -public class DriverRenderEntity extends Render{ - - private DriverModel model = new DriverModel(); - private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/shield.png"); - private float rotationAmount=1F; - private float rotationAmount2=0F; - public DriverRenderEntity() - { - super(); - } - - @Override - public void doRender(Entity entity, double x, double y, double z, float arg4, float arg5) - { - double d; - double d1; - double d2; - if(((DriverEntity)entity).parent!=null) - { - DriverTileEntity tile = ((DriverEntity)entity).parent; - float shift=tile.getModelShiftAmount(); - d=x-entity.lastTickPosX+tile.xCoord; - d1=y-entity.lastTickPosY+tile.yCoord; - d2=z-entity.lastTickPosZ+tile.zCoord; - int rotation = 0; - if(tile.getWorldObj() != null) - { - switch (tile.getFacing()) - { - case 2: - rotation = 0; - break; - case 5: - rotation = 1; - break; - case 3: - rotation = 2; - break; - case 4: - rotation = 3; - break; - default: - rotation = 0; - } - } - bindTexture(tex); - GL11.glPushMatrix(); - GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); - GL11.glScalef(1.0F, -1F, -1F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); - if(tile.hasShield && tile.getActive() && tile.shaftDestroyedAtA==0) - { - rotationAmount+=0.01F; - } - rotationAmount2 += 0.01F; - if(tile.hasShield) - { - if(tile.shaftDestroyedAtA==0) - { - model.ShieldB.rotateAngleZ=rotationAmount+(float)Math.PI/8.0F; - model.ShieldB.offsetZ=shift; - model.ShieldB.render(1.0F/16.0F); - - model.ShieldC.rotateAngleZ=rotationAmount+3*(float)Math.PI/8.0F; - model.ShieldC.offsetZ=shift; - model.ShieldC.render(1.0F/16.0F); - - if(tile.advancedShield) - { - model.AdvancedShieldA.rotateAngleZ=rotationAmount+(float)Math.PI/4.0F; - model.AdvancedShieldA.offsetZ=shift; - model.AdvancedShieldA.render(1.0F/16.0F); - } - else - { - model.ShieldA.rotateAngleZ=rotationAmount+(float)Math.PI/4.0F; - model.ShieldA.offsetZ=shift; - model.ShieldA.render(1.0F/16.0F); - } - - model.Shield.rotateAngleZ=rotationAmount; - model.Shield.offsetZ=shift; - model.Shield.render(1.0F/16.0F); - GL11.glScalef(1.0F, 1.0F, 1.0F + shift); - model.ShaftA.offsetZ=0.5F; - model.ShaftB.offsetZ=0.5F; - model.ShaftA.rotateAngleZ=rotationAmount; - model.ShaftB.rotateAngleZ=rotationAmount; - model.ShaftA.render(1.0F/16.0F); - model.ShaftB.render(1.0F/16.0F); - } - else - { - model.ShieldB.rotateAngleZ=rotationAmount+(float)Math.PI/8.0F; - model.ShieldC.rotateAngleZ=rotationAmount+3*(float)Math.PI/8.0F; - model.ShieldA.rotateAngleZ=rotationAmount+(float)Math.PI/4.0F; - model.AdvancedShieldA.rotateAngleZ=rotationAmount+(float)Math.PI/4.0F; - model.Shield.rotateAngleZ=rotationAmount; - model.ShaftA.rotateAngleZ=rotationAmount; - - model.ShieldB.offsetZ=shift; - model.ShieldB.render(1.0F/16.0F); - - model.ShieldC.offsetZ=shift; - model.ShieldC.render(1.0F/16.0F); - - if(tile.advancedShield) - { - model.AdvancedShieldA.offsetZ=shift; - model.AdvancedShieldA.render(1.0F/16.0F); - } - else - { - model.ShieldA.offsetZ=shift; - model.ShieldA.render(1.0F/16.0F); - } - - model.Shield.offsetZ=shift; - model.Shield.render(1.0F/16.0F); - GL11.glScalef(1.0F, 1.0F, tile.shaftDestroyedAtA*2); - model.ShaftB.offsetZ=0.5F-0.2F/tile.shaftDestroyedAtA; - model.ShaftB.rotateAngleZ=rotationAmount2; - model.ShaftB.render(1.0F/16.0F); - GL11.glScalef(1.0F, 1.0F, (shift-tile.shaftDestroyedAtB)/tile.shaftDestroyedAtA); - model.ShaftA.offsetZ=0.5F*(tile.shaftDestroyedAtB+0.5F)/(shift-tile.shaftDestroyedAtB); - model.ShaftA.render(1.0F/16.0F); - } - } - GL11.glPopMatrix(); //end - } - } - - @Override - protected ResourceLocation getEntityTexture(Entity arg0) { - return this.tex; - } -} \ No newline at end of file diff --git a/ihl/tunneling_shield/DriverTileEntity.java b/ihl/tunneling_shield/DriverTileEntity.java deleted file mode 100644 index f547dec..0000000 --- a/ihl/tunneling_shield/DriverTileEntity.java +++ /dev/null @@ -1,1136 +0,0 @@ -package ihl.tunneling_shield; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergySink; -import ic2.api.item.IC2Items; -import ic2.api.network.INetworkClientTileEntityEventListener; -import ic2.api.recipe.RecipeOutput; -import ic2.api.recipe.Recipes; -import ic2.core.ContainerBase; -import ic2.core.IC2; -import ic2.core.IHasGui; -import ic2.core.Ic2Items; -import ic2.core.audio.AudioSource; -import ic2.core.audio.PositionSpec; -import ic2.core.block.TileEntityInventory; -import ic2.core.block.invslot.InvSlotConsumableId; -import ic2.core.block.invslot.InvSlot; -import ic2.core.block.invslot.InvSlotUpgrade; -import ic2.core.block.invslot.InvSlot.Access; -import ic2.core.upgrade.IUpgradableBlock; -import ic2.core.upgrade.UpgradableProperty; -import ic2.core.util.StackUtil; -import ihl.IHLMod; -import ihl.utils.IHLInvSlotDischarge; -import ihl.utils.IHLUtils; -import net.minecraft.block.Block; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; - -public class DriverTileEntity extends TileEntityInventory implements IEnergySink, IHasGui, INetworkClientTileEntityEventListener, IUpgradableBlock, IMultiBlock { - - private AudioSource audioSource; - private AudioSource startAS; - private AudioSource loopAS; - private AudioSource stopAS; - private int startUpCounter=0; - public final InvSlotConsumableId miningPipesSlot; - public final InvSlotUpgrade upgradeSlot; - public final IHLInvSlotDischarge dischargeSlot; - public int tier; - private int defaultTier; - public int maxStorage; - private int defaultMaxStorage; - public boolean hasShield=false; - private boolean prevHasShield=false; - public int shaftDestroyedAtA=0; - private int prevShaftDestroyedAtA=0; - public int shaftDestroyedAtB=0; - private int prevShaftDestroyedAtB=0; - public int modelShift=0; - public int modelShiftSpeed; - private int defaultModelShiftSpeed; - public int blockShift=1; - private int lastBlockShift=1; - private double energy = 0; - private double energyConsume; - private double defaultEnergyConsume; - private boolean addedToEnergyNet=false; - public int xShaftMin, xShaftMax, yShaft, zShaftMin, zShaftMax, xShieldMin, xShieldMax, yShieldMin, yShieldMax, zShieldMin, zShieldMax; - private int updateChecksum=0; - private boolean renderHelperExist=false; - public DriverEntity renderHelper; - public boolean reverseModeOn=false; - public boolean autoReverseModeOn=true; - private float lastModelShiftAmount=1F; - private List blockBlackList = new ArrayList(); - private List blockWhiteList = new ArrayList(); - public boolean advancedShield=false; - - public DriverTileEntity() - { - super(); - this.miningPipesSlot = new InvSlotConsumableId(this, "miningPipesSlot", 1, 12, new Item[] {Ic2Items.miningPipe.getItem()}); - this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 2, 4); - this.dischargeSlot = new IHLInvSlotDischarge(this, 1, Access.IO, this.tier, InvSlot.InvSide.BOTTOM); - this.defaultTier=IHLMod.config.ts02DefaultTier; - this.defaultMaxStorage=IHLMod.config.ts02DefaultMaxEnergyStorage; - this.defaultModelShiftSpeed=IHLMod.config.ts02DefaultSpeed; - this.defaultEnergyConsume=IHLMod.config.ts02DefaultOperationEUCost; - this.tier=this.defaultTier; - this.maxStorage=this.defaultMaxStorage; - this.modelShiftSpeed=this.defaultModelShiftSpeed; - this.energyConsume=this.defaultEnergyConsume; - for(int i6=0;i6 getNetworkedFields() - { - List fields = super.getNetworkedFields(); - fields.add("hasShield"); - fields.add("modelShift"); - fields.add("shaftDestroyedAtA"); - fields.add("shaftDestroyedAtB"); - fields.add("tier"); - fields.add("modelShiftSpeed"); - fields.add("maxStorage"); - fields.add("reverseModeOn"); - fields.add("autoReverseModeOn"); - fields.add("advancedShield"); - return fields; - } - - public String getShieldSoundFile() - { - return "Machines/MinerOp.ogg"; - } - - public String getStartSoundFile() - { - return "Machines/IHL Tunneling Shield/TS02Start.ogg"; - } - - public String getLoopSoundFile() - { - return "Machines/IHL Tunneling Shield/TS02Loop.ogg"; - } - - public String getStopSoundFile() - { - return "Machines/IHL Tunneling Shield/TS02Stop.ogg"; - } - - @Override - public void onLoaded() - { - super.onLoaded(); - if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - this.addedToEnergyNet = true; - } - if (IC2.platform.isRendering() && (this.startAS==null||this.loopAS==null||this.stopAS==null)) - { - this.startAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(),false,false, 0.5F); - this.loopAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getLoopSoundFile(),true,false, 0.5F); - this.stopAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStopSoundFile(),false,false, 0.5F); - } - } - - @Override - public void onUnloaded() - { - super.onUnloaded(); - - if (IC2.platform.isRendering() && this.audioSource != null) - { - this.audioSource.stop(); - this.audioSource = null; - this.startAS.stop(); - this.loopAS.stop(); - this.stopAS.stop(); - this.startAS = null; - this.loopAS = null; - this.stopAS = null; - IC2.audioManager.removeSources(this); - } - - if (IC2.platform.isSimulating()&&this.addedToEnergyNet) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - this.addedToEnergyNet = false; - } - } - - - @SuppressWarnings("unchecked") - @Override - public void updateEntityClient() - { - super.updateEntityClient(); - updateEntityServer(); - if(!this.renderHelperExist) - { - List deList = this.worldObj.getEntitiesWithinAABB(DriverEntity.class, this.getOperationZone()); - if(deList.size()>0) - { - Iterator dei = deList.iterator(); - while(dei.hasNext()) - { - DriverEntity rh=dei.next(); - if(!rh.isDead) - { - this.renderHelper=rh; - rh.parent=this; - this.renderHelperExist=true; - break; - } - } - if(!this.renderHelperExist) - { - this.renderHelper=new DriverEntity(this.worldObj, this, this.xCoord+this.blockShift*this.mX(), this.yCoord, this.zCoord+this.blockShift*this.mZ()); - this.renderHelperExist=true; - } - } - else - { - this.renderHelper=new DriverEntity(this.worldObj, this, this.xCoord+this.blockShift*this.mX(), this.yCoord, this.zCoord+this.blockShift*this.mZ()); - this.renderHelper.parent=this; - this.renderHelperExist=true; - } - } - - if(this.renderHelper!=null && !this.renderHelper.isDead && !this.worldObj.loadedEntityList.contains(this.renderHelper)) - { - this.worldObj.spawnEntityInWorld(this.renderHelper); - } - if(this.audioSource==null && this.renderHelper!=null)this.audioSource = IC2.audioManager.createSource(this.renderHelper, PositionSpec.Center, this.getShieldSoundFile(),true,false, 1.0F); - if(this.audioSource!=null) - { - this.audioSource.updatePosition(); - } - if(this.audioSource!=null) - { - if(this.getActive()) - { - if(this.startUpCounter>62) - { - this.startUpCounter=0; - } - if(this.startUpCounter==0) - { - this.stopAS.stop(); - this.startAS.play(); - } - if(this.startUpCounter<60) - { - this.startUpCounter++; - } - else if(this.startUpCounter==60) - { - this.startAS.stop(); - this.loopAS.play(); - this.audioSource.play(); - this.startUpCounter++; - } - } - else if(this.startUpCounter>0) - { - this.startAS.stop(); - this.loopAS.stop(); - this.audioSource.stop(); - this.stopAS.play(); - if(this.startUpCounter<100) - { - this.startUpCounter++; - } - else - { - this.startUpCounter=0; - this.stopAS.stop(); - } - } - } - else if(!this.getActive() && this.audioSource!=null) - { - this.audioSource.stop(); - } - } - - @SuppressWarnings("unchecked") - @Override - public void updateEntityServer() - { - if (IC2.platform.isSimulating()) - { - this.setOverclockRates(); - } - if(this.dischargeSlot.tier!=this.tier) - { - this.dischargeSlot.tier=this.tier; - } - int xyz[]={0,0,1,0,-1,-1,1,1,-1,2,0,2,1,2,-1,-2,0,-2,1,-2,-1,0}; - boolean freeToDigForward = true; - boolean freeToMoveBack = true; - if(this.blockShift>=127) - { - freeToDigForward = false; - if(this.autoReverseModeOn && !this.reverseModeOn && this.worldObj.isRemote) - { - this.reverseModeOn=true; - IC2.network.get().initiateClientTileEntityEvent(this, 0); - } - } - else - { - for(int i = 0;i<21;i++) - { - Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift+1)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift+1)*this.mZ()); - if(this.blockBlackList.contains(block)) - { - freeToDigForward = false; - } - } - } - - if(this.blockShift<=3) - { - freeToMoveBack = false; - } - else - { - for(int i = 0;i<21;i++) - { - Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-3)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-3)*this.mZ()); - if(block.getCollisionBoundingBoxFromPool(worldObj, this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-3)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-3)*this.mZ())!=null && !block.getMaterial().isLiquid() && !this.blockWhiteList.contains(block)) - { - freeToMoveBack = false; - } - block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ()); - if(block.getCollisionBoundingBoxFromPool(worldObj, this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ())!=null && !block.getMaterial().isLiquid() && !this.blockWhiteList.contains(block)) - { - freeToMoveBack = false; - } - } - } - - if(IC2.platform.isSimulating()) - { - if(this.hasShield && this.shaftDestroyedAtA==0 && this.energy>=this.energyConsume) - { - if(this.reverseModeOn && freeToMoveBack) - { - this.energy-=this.energyConsume; - this.setActive(true); - } - else if((!this.reverseModeOn) && freeToDigForward && this.miningPipesSlot.get()!=null && this.miningPipesSlot.get().stackSize>=1) - { - this.energy-=this.energyConsume; - this.setActive(true); - } - else - { - this.setActive(false); - } - } - else - { - this.setActive(false); - } - } - if(this.getActive()) - { - double velocity; - if(this.reverseModeOn && this.modelShift>0) - { - this.modelShift--; - List entityList = this.worldObj.getEntitiesWithinAABB(Entity.class, this.getShieldBladesZone(0D)); - velocity = -0.5D; - if(entityList.size()>0) - { - for(int i0=0;i0 entityLivingList = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.getShieldBladesZone(2.5D)); - float damage = 800F/(this.modelShiftSpeed); - velocity = 0.1D*damage; - if(entityLivingList.size()>0) - { - for(int i1=0;i1 entityLivingList2 = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, this.getShieldBladesZone(2.5D)); - velocity*=0.1D; - if(entityLivingList2.size()>0) - { - for(int i2=0;i2 1.0D) - { - double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false); - this.energy += amount; - } - if(this.energy>this.maxStorage) - { - this.energy=this.maxStorage; - } - } - - if(this.blockShift!=this.lastBlockShift) - { - if(this.getActive() && this.reverseModeOn && IC2.platform.isSimulating() && this.lastModelShiftAmount-this.getModelShiftAmount()<1F) - { - if(this.miningPipesSlot.get()==null) - { - this.miningPipesSlot.put(Ic2Items.miningPipe.copy()); - } - else if(this.miningPipesSlot.get().stackSize<64) - { - this.miningPipesSlot.get().stackSize++; - } - else - { - this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj,this.xCoord,this.yCoord+1,this.zCoord,this.miningPipesSlot.get())); - this.miningPipesSlot.put(Ic2Items.miningPipe.copy()); - } - this.lastModelShiftAmount-=1F; - } - else if(this.getActive() && IC2.platform.isSimulating() && this.getModelShiftAmount()-this.lastModelShiftAmount>1F) - { - this.miningPipesSlot.consume(1); - this.lastModelShiftAmount+=1F; - IC2.network.get().updateTileEntityField(this, "modelShift"); - } - this.defineTechBlockVariables(); - if(this.getActive() && IC2.platform.isSimulating()) - { - if(this.reverseModeOn) - { - for(int i = 0;i<21;i++) - { - if(this.blockShift>=2) - { - this.worldObj.setBlockToAir(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift)*this.mZ()); - } - if(this.blockShift>=3) - { - Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ()); - if(block!=IHLMod.multiBlockSpacerBlock && block!=IHLMod.horizontalMiningPipeX && block!=IHLMod.horizontalMiningPipeZ) - { - this.harvestDrops(block, this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ(), this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-3)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-3)*this.mZ(), IHLMod.multiBlockSpacerBlock); - } - else - { - this.worldObj.setBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ(), IHLMod.multiBlockSpacerBlock); - } - } - } - } - else - { - for(int i = 0;i<21;i++) - { - Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+this.blockShift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+this.blockShift*this.mZ()); - this.harvestMiningDrops(block, this.xCoord+xyz[i+1]*this.mZ()+this.blockShift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+this.blockShift*this.mZ(), this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ(), IHLMod.multiBlockSpacerBlock); - if(this.blockShift>=3) - { - if(i!=0) - { - this.worldObj.setBlockToAir(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ()); - } - else - { - this.worldObj.setBlock(this.xCoord+(this.blockShift-2)*this.mX(), this.yCoord, this.zCoord+(this.blockShift-2)*this.mZ(), this.mX()!=0?IHLMod.horizontalMiningPipeZ:IHLMod.horizontalMiningPipeX); - } - } - - } - } - } - this.lastBlockShift=this.blockShift; - } - } - - private void harvestMiningDrops(Block block, int x, int y, int z, int x1, int y1, int z1, Block setToBlock) - { - if(block!=null && block!=Blocks.air && block!=Blocks.bedrock) - { - int meta = worldObj.getBlockMetadata(x, y, z); - ArrayList drops = block.getDrops(this.worldObj, x, y, z, meta, 0); - if(drops.size()>0) - { - if(!this.advancedShield || !this.handleDropsByHydrotransport(drops)) - { - for(int i1=0;i1 getGuiContainer(EntityPlayer arg0) { - return new DriverContainer(arg0, this); - } - - @Override - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) - { - return true; - } - - public boolean getGui(EntityPlayer player) - { - return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; - } - - public boolean canPlaceShield() - { - if(this.hasShield) - { - return false; - } - Block block; - int xyz[]={0,0,1,0,-1,-1,1,1,-1,2,0,2,1,2,-1,-2,0,-2,1,-2,-1,0}; - for(int i = 0;i<21;i++) - { - block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+this.mZ()); - if(!block.isAir(this.worldObj, this.xCoord+xyz[i+1]*this.mZ()+this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+this.mZ())) - { - return false; - } - } - return true; - } - - public int mX() - { - switch(this.getFacing()) - { - case 4: - return -1; - case 5: - return 1; - default: - return 0; - } - } - - public int mZ() - { - switch(this.getFacing()) - { - case 3: - return 1; - case 2: - return -1; - case 4: - return 0; - case 5: - return 0; - default: - return -1; - } - } - - public float getModelShiftAmount() { - return (float)this.modelShift/(float)this.modelShiftSpeed; - } - - private AxisAlignedBB getOperationZone() - { - int x=this.xCoord; - int y=this.yCoord; - int z=this.zCoord; - double extension=this.getModelShiftAmount()+1.0D; - return AxisAlignedBB.getBoundingBox(x + extension*Math.min(this.mX(),0)-2.0D, y-2.0D, z + extension*Math.min(this.mZ(),0)-2.0D, x + 3.0D + extension*Math.max(this.mX(),0), y + 3.0D, z + 3.0D + extension*Math.max(this.mZ(),0)); - } - - private AxisAlignedBB getShieldBladesZone(double offset) - { - double extension=this.getModelShiftAmount()+offset; - double xShieldMinD=this.xCoord+extension*this.mX()-1D*Math.max(this.mX(), 0)-2D*Math.abs(this.mZ()); - double xShieldMaxD=this.xCoord+extension*this.mX()-1D*Math.min(this.mX(), 0)+3D*Math.abs(this.mZ()); - double yShieldMinD=this.yCoord-2D; - double yShieldMaxD=this.yCoord+3D; - double zShieldMinD=this.zCoord+extension*this.mZ()-1D*Math.max(this.mZ(), 0)-2D*Math.abs(this.mX()); - double zShieldMaxD=this.zCoord+extension*this.mZ()-1D*Math.min(this.mZ(), 0)+3D*Math.abs(this.mX()); - return AxisAlignedBB.getBoundingBox(xShieldMinD, yShieldMinD, zShieldMinD, xShieldMaxD, yShieldMaxD, zShieldMaxD); - } - - public int getStored() { - return Math.round((float)this.energy); - } - - public void setStored(int value) { - this.energy=value; - } - - @Override - public void onGuiClosed(EntityPlayer arg0) {} - - public void installShield() { - if(IC2.platform.isSimulating()) - { - this.hasShield=true; - int x=this.xCoord; - int y=this.yCoord; - int z=this.zCoord; - MultiBlockSpacerBlock.teList.add(this); - this.defineTechBlockVariables(); - if(this.mX()==0) - { - HorizontalMiningPipe.teList.add(this); - } - else - { - HorizontalMiningPipe.teList.add(this); - } - - int xyz[]={0,0,1,0,-1,-1,1,1,-1,2,0,2,1,2,-1,-2,0,-2,1,-2,-1,0}; - for(int i1 = 0;i1<21;i1++) - { - this.worldObj.setBlock(x+xyz[i1+1]*this.mZ()+this.mX(), y+xyz[i1], z+xyz[i1+1]*this.mX()+this.mZ(), IHLMod.multiBlockSpacerBlock, 0, 3); - } - } - } - - public boolean isShaftCoord(int x, int y, int z) - { - if(IC2.platform.isSimulating() && y==this.yShaft && x>=this.xShaftMin && x<=this.xShaftMax && z>=this.zShaftMin && z<=this.zShaftMax) - { - int sda = (x-this.xCoord)*this.mX()+(z-this.zCoord)*this.mZ(); - if(this.shaftDestroyedAtA==0 && this.shaftDestroyedAtB==0) - { - this.shaftDestroyedAtA=this.shaftDestroyedAtB=sda; - } - else if(sda>this.shaftDestroyedAtB) - { - for(int i4=this.shaftDestroyedAtB;i4=this.yShieldMin && y<=this.yShieldMax && x>=this.xShieldMin && x<=this.xShieldMax && z>=this.zShieldMin && z<=this.zShieldMax) - { - if(onBlockBeak) - { - this.hasShield=false; - this.advancedShield=false; - this.modelShift=0; - this.lastBlockShift=this.blockShift=1; - this.shaftDestroyedAtA=0; - IC2.network.get().updateTileEntityField(this, "modelShift"); - IC2.network.get().updateTileEntityField(this, "advancedShield"); - this.cleanUp(); - } - return true; - } - return false; - } - - public boolean isShaftCoordNN(int x, int y, int z) - { - if(y==this.yShaft && x>=this.xShaftMin && x<=this.xShaftMax && z>=this.zShaftMin && z<=this.zShaftMax) - { - return true; - } - return false; - } - - public void cleanUp() - { - int xyz[]={0,0,1,0,-1,-1,1,1,-1,2,0,2,1,2,-1,-2,0,-2,1,-2,-1,0}; - for(int shift = 0;shift<=this.blockShift+1;shift++) - { - for(int i = 0;i<21;i++) - { - Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+shift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+shift*this.mZ()); - if(block instanceof HorizontalMiningPipe) - { - ArrayList drops = block.getDrops(this.worldObj, this.xCoord+xyz[i+1]*this.mZ()+shift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+shift*this.mZ(), 0, 3); - if(drops.size()>0) - { - for(int i1=0;i1 drops) - { - ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()).getOpposite(); - TileEntity te = worldObj.getTileEntity(xCoord+direction.offsetX, yCoord+direction.offsetY, zCoord+direction.offsetZ); - if(te instanceof HydrotransportPulpRegeneratorTileEntity) - { - HydrotransportPulpRegeneratorTileEntity hprte = (HydrotransportPulpRegeneratorTileEntity) te; - if(hprte.getActive()) - { - ArrayList drops1 = new ArrayList(); - Iterator dropsIterator = drops.iterator(); - while(dropsIterator.hasNext()) - { - ItemStack stack = dropsIterator.next(); - RecipeOutput maceratorOut = Recipes.macerator.getOutputFor(stack, false); - if(maceratorOut!=null && !maceratorOut.items.isEmpty()) - { - Iterator maceratorOutIterator = maceratorOut.items.iterator(); - while(maceratorOutIterator.hasNext()) - { - drops1.add(maceratorOutIterator.next().copy()); - } - } - else - { - drops1.add(stack); - } - } - if(hprte.outputSlot.canAdd(drops1)) - { - hprte.outputSlot.add(drops1); - } - else - { - for(int i1=0;i1 drops = block.getDrops(this.worldObj, x, y, z, meta, 0); - if(drops.size()>0) - { - for(int i1=0;i1= this.maxStorage) - { - return amount; - } - else - { - this.energy += amount; - return 0.0D; - } - } - - @Override - public double getEnergy() { - return this.energy; - } - - @Override - public boolean useEnergy(double amount) - { - if (this.energy >= amount) - { - this.energy -= amount; - return true; - } - else - { - return false; - } - } - - @Override - public boolean shouldRenderInPass(int pass) - { - return pass==0; - } - - @Override - public boolean getIsInvalid() - { - return this.isInvalid(); - } - - public void installAdvancedShield() - { - this.installShield(); - this.advancedShield=true; - IC2.network.get().updateTileEntityField(this, "advancedShield"); - } - - public ItemStack getOutput(int arg0) - { - return null; - } - - public int getOutputSize() { - return 0; - } - - public void setOutput(int arg0, ItemStack arg1) - { - } - - @Override - public Set getUpgradableProperties() - { - Set properties = new HashSet(); - properties.add(UpgradableProperty.EnergyStorage); - properties.add(UpgradableProperty.Processing); - properties.add(UpgradableProperty.Transformer); - return properties; - } -} diff --git a/ihl/tunneling_shield/HorizontalMiningPipe.java b/ihl/tunneling_shield/HorizontalMiningPipe.java deleted file mode 100644 index 9409d27..0000000 --- a/ihl/tunneling_shield/HorizontalMiningPipe.java +++ /dev/null @@ -1,276 +0,0 @@ -package ihl.tunneling_shield; -import ic2.core.IC2; -import ic2.core.Ic2Items; -import ic2.core.audio.PositionSpec; -import ic2.core.item.tool.ItemToolWrench; -import ihl.IHLMod; -import java.util.ArrayList; -import java.util.Random; - -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.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class HorizontalMiningPipe extends Block { - - public static ArrayList teList = new ArrayList(); - - public HorizontalMiningPipe() { - super(Material.iron); - this.setBlockBounds(0.1875F, 0.1875F, 0.1875F, 0.8125F, 0.8125F, 0.8125F); - } - - public HorizontalMiningPipe(int meta) { - super(Material.iron); - this.setBlockBounds(0.1875F*meta, 0.1875F, 0.1875F*(1-meta), 0.8125F+0.1875F*(1-meta), 0.8125F, 0.8125F+0.1875F*meta); - } - - @Override - public boolean canHarvestBlock(EntityPlayer player, int meta) - { - return true; - } - - @Override - public Item getItem(World world, int x, int y, int z) - { - return Ic2Items.miningPipe.getItem(); - } - - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) - { - return Ic2Items.miningPipe.getItem(); - } - - @Override - public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) - { - ItemStack result = Ic2Items.miningPipe; - result.stackSize=1; - this.dropBlockAsItem(world, x, y, z, result); - } - - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister par1IconRegister) - { - this.blockIcon = par1IconRegister.registerIcon("ic2:machine/blockMiningPipe"); - } - - @Override - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { - return this.blockIcon; - } - - /** - * The type of render function that is called for this block - */ - @Override - public int getRenderType() - { - return -2; - } - - /** - * Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two - * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. - */ - @Override - public boolean isOpaqueCube() - { - return false; - } - - /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) - { - super.onBlockDestroyedByExplosion(world, x, y, z, explosion); - this.checkIfMachinePart(world, x, y, z); - } - - @Override - public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) - { - super.onBlockDestroyedByPlayer(world, x, y, z, meta); - this.checkIfMachinePart(world, x, y, z); - } - - private void checkIfMachinePart(World world, int x, int y, int z) - { - if(teList.size()>0) - { - for (int i=0;i0) - { - for (int i=0;i0) - { - for (int i3=0;i3 { - - protected HydrotransportPulpRegeneratorTileEntity tileEntity; - public int lastFluidAmount = -1; - public int lastNumberOfFluids = -1; - public short lastProgress = -1; - public short lastTemperature = -1; - private int lastEnergy = -1; - @SuppressWarnings("unused") - private List fluidTankFluidList; - private final static int height=166; - - public HydrotransportPulpRegeneratorContainer(EntityPlayer entityPlayer, HydrotransportPulpRegeneratorTileEntity tileEntity1){ - super(tileEntity1); - this.tileEntity = tileEntity1; - fluidTankFluidList=tileEntity.fluidTank.getFluidList(); - int col,row; - for (col = 0; col < 3; ++col) - { - for (int col1 = 0; col1 < 9; ++col1) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); - } - } - for (col = 0; col < 9; ++col) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); - } - this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 32, 13)); - this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 32, 51)); - this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 8, 32)); - for(col=0;col<4;col++) - { - for(row=0;row<3;row++) - { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, col+row*4, 92+col*18, 13+row*18)); - } - } - } - - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)this.crafters.get(i); - - if (this.tileEntity.fluidTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.fluidTank.getNumberOfFluids() != this.lastNumberOfFluids) - { - IC2.network.get().sendContainerField(this, "fluidTankFluidList"); - } - if (this.tileEntity.progress != this.lastProgress) - { - icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); - } - if (this.tileEntity.getEnergy() != this.lastEnergy ) - { - icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); - } - } - - this.lastNumberOfFluids = this.tileEntity.fluidTank.getNumberOfFluids(); - this.lastFluidAmount = this.tileEntity.fluidTank.getFluidAmount(); - this.lastProgress = this.tileEntity.progress; - this.lastEnergy = this.tileEntity.getEnergy(); - } - - @Override - public void updateProgressBar(int index, int value) - { - super.updateProgressBar(index, value); - switch (index) - { - case 0: - this.tileEntity.progress=(short) value; - break; - case 1: - this.tileEntity.setEnergy(value); - break; - } - } - - @Override - public boolean canInteractWith(EntityPlayer var1) { - return tileEntity.isUseableByPlayer(var1); - } -} diff --git a/ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java b/ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java deleted file mode 100644 index bd86dd7..0000000 --- a/ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java +++ /dev/null @@ -1,59 +0,0 @@ -package ihl.tunneling_shield; - -import cpw.mods.fml.relauncher.Side; - -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -import ihl.utils.IHLRenderUtils; - -@SideOnly(Side.CLIENT) -public class HydrotransportPulpRegeneratorGui extends GuiContainer { - private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIHydrotransportPulpRegenerator.png"); - private HydrotransportPulpRegeneratorContainer container; - - public HydrotransportPulpRegeneratorGui (HydrotransportPulpRegeneratorContainer container1) { - //the container is instanciated and passed to the superclass for handling - super(container1); - this.container=container1; - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - int xOffset = (this.width - xSize) / 2; - int yOffset = (this.height - ySize) / 2; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - int i1; - if (this.container.tileEntity.getEnergy() > 0D) - { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); - i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); - this.drawTexturedModalRect(12, 16 + 12 - i1, 179, 13 - i1, 13, i1 + 1); - } - if (this.container.tileEntity.progress > 0) - { - i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); - this.drawTexturedModalRect(73, 34, 197, 0, i1 + 1, 13); - } - if (this.container.tileEntity.fluidTank.getFluidAmount() > 0) - { - IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTank, 57, 16, 69, 63, zLevel, par1, par2, xOffset, yOffset); - } - this.mc.renderEngine.bindTexture(background); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, - int par3) { - //draw your Gui here, only thing you need to change is the path - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(background); - int x = (width - xSize) / 2; - int y = (height - ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); - } -} \ No newline at end of file diff --git a/ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java b/ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java deleted file mode 100644 index dc5e114..0000000 --- a/ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java +++ /dev/null @@ -1,273 +0,0 @@ -package ihl.tunneling_shield; - -import java.util.List; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; -import ic2.api.Direction; -import ic2.core.ContainerBase; -import ic2.core.block.invslot.InvSlot; -import ic2.core.block.invslot.InvSlotConsumableLiquid; -import ic2.core.block.invslot.InvSlotOutput; -import ihl.processing.invslots.InvSlotConsumableLiquidIHL; -import ihl.processing.metallurgy.BasicElectricMotorTileEntity; -import ihl.utils.IHLFluidTank; -import ihl.utils.IHLUtils; - -public class HydrotransportPulpRegeneratorTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler -{ - public final InvSlotConsumableLiquidIHL drainInputSlot; - public final InvSlotOutput emptyFluidItemsSlot; - public final InvSlotOutput outputSlot; - final IHLFluidTank fluidTank = new IHLFluidTank(2000); - private int timer=0; - - public HydrotransportPulpRegeneratorTileEntity() { - super(); - this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); - this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); - this.outputSlot = new InvSlotOutput(this, "output", 3, 12); - this.operationLength=26; - } - - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) - { - super.readFromNBT(nbttagcompound); - this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); - } - - @Override - public void writeToNBT(NBTTagCompound nbttagcompound) - { - super.writeToNBT(nbttagcompound); - NBTTagCompound fluidTankTag = new NBTTagCompound(); - this.fluidTank.writeToNBT(fluidTankTag); - nbttagcompound.setTag("fluidTank", fluidTankTag); - } - - @Override - public ItemStack getWrenchDrop(EntityPlayer player) - { - return IHLUtils.getThisModItemStack("hydrotransportPulpRegenerator"); - } - - @Override - public void updateEntityServer() - { - super.updateEntityServer(); - ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()); - TileEntity te = worldObj.getTileEntity(xCoord+direction.offsetX,yCoord+direction.offsetY,zCoord+direction.offsetZ); - if(!this.getActive() && this.fluidTank.getFluid()!=null && isMachineOperational()) - { - if(te instanceof DriverTileEntity) - { - this.setActive(true); - } - } - else if(this.getActive()) - { - timer++; - if(!(te instanceof DriverTileEntity) || this.fluidTank.getFluid()==null || !isMachineOperational()) - { - this.setActive(false); - } - } - if(timer>100) - { - this.fluidTank.drain(1, true); - this.energy-=1d; - timer=0; - } - if(timer%10==0) - { - if(te instanceof DriverTileEntity) - { - DriverTileEntity dte = (DriverTileEntity) te; - if(dte.getActive()) - { - this.fluidTank.drain(1, true); - } - } - } - IHLUtils.handleFluidSlotsBehaviour(null, drainInputSlot, emptyFluidItemsSlot, fluidTank); - } - - @Override - public void operate() - { - ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()).getOpposite(); - TileEntity te = worldObj.getTileEntity(xCoord+direction.offsetX, yCoord+direction.offsetY,zCoord+direction.offsetZ); - int i0=0; - for(int i1=i0;i1si.getInventoryStackLimit()) - { - si.getStackInSlot(i).stackSize=si.getInventoryStackLimit(); - outputSlot.get(i0).stackSize-=si.getInventoryStackLimit()-stackSizeBefore; - if(outputSlot.get(i0).stackSize<=0) - { - outputSlot.put(i0,null); - } - } - else - { - outputSlot.put(i0,null); - } - } - - } - } - } - else if(te instanceof IInventory) - { - IInventory si = (IInventory)te; - for(int i=0;isi.getInventoryStackLimit()) - { - si.getStackInSlot(i).stackSize=si.getInventoryStackLimit(); - outputSlot.get(i0).stackSize-=si.getInventoryStackLimit()-stackSizeBefore; - if(outputSlot.get(i0).stackSize<=0) - { - outputSlot.put(i0,null); - } - } - else - { - outputSlot.put(i0,null); - } - } - } - } - } - else - { - for(int i1=i0;i1=this.energyConsume; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public List[] getInput() - { - return null; - } - - @Override - public boolean canOperate() - { - return !this.outputSlot.isEmpty(); - } - - @Override - @SideOnly(Side.CLIENT) - public GuiScreen getGui(EntityPlayer player, boolean arg1) { - return new HydrotransportPulpRegeneratorGui(new HydrotransportPulpRegeneratorContainer(player, this)); - } - - @Override - public ContainerBase getGuiContainer(EntityPlayer player) { - return new HydrotransportPulpRegeneratorContainer(player, this); - } - - @Override - public boolean canDrain(ForgeDirection arg0, Fluid arg1) { - return false; - } - - @Override - public boolean canFill(ForgeDirection arg0, Fluid arg1) - { - return true; - } - - @Override - public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) { - return null; - } - - @Override - public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2) { - return null; - } - - @Override - public int fill(ForgeDirection arg0, FluidStack resource, boolean doFill) - { - return this.fluidTank.fill(resource, doFill); - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection arg0) - { - return new FluidTankInfo[] {this.fluidTank.getInfo()}; - } - -} \ No newline at end of file diff --git a/ihl/tunneling_shield/IMultiBlock.java b/ihl/tunneling_shield/IMultiBlock.java deleted file mode 100644 index e4d32d7..0000000 --- a/ihl/tunneling_shield/IMultiBlock.java +++ /dev/null @@ -1,7 +0,0 @@ -package ihl.tunneling_shield; - -public interface IMultiBlock -{ - public boolean isAPartOfStructure(int x, int y, int z, boolean onBlockBeak); - public boolean getIsInvalid(); -} diff --git a/ihl/tunneling_shield/MultiBlockSpacerBlock.java b/ihl/tunneling_shield/MultiBlockSpacerBlock.java deleted file mode 100644 index 79e5955..0000000 --- a/ihl/tunneling_shield/MultiBlockSpacerBlock.java +++ /dev/null @@ -1,223 +0,0 @@ -package ihl.tunneling_shield; - -import ic2.core.IC2; -import ic2.core.IHasGui; -import ic2.core.audio.PositionSpec; -import ic2.core.item.tool.ItemToolWrench; -import ihl.utils.IHLUtils; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Random; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.Explosion; -import net.minecraft.world.World; - -public class MultiBlockSpacerBlock extends Block { - - public static Set teList = new HashSet(); - - public MultiBlockSpacerBlock() - { - super(Material.iron); - } - - /** - * The type of render function that is called for this block - */ - @Override - public int getRenderType() - { - return -2; - } - - @Override - public ArrayList getDrops(World world,int x, int y, int z, int meta, int flag) - { - return new ArrayList(); - } - @Override - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) - { - super.onBlockDestroyedByExplosion(world, x, y, z, explosion); - this.checkIfMachinePart(world, x, y, z); - } - - @Override - public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) - { - super.onBlockDestroyedByPlayer(world, x, y, z, meta); - this.checkIfMachinePart(world, x, y, z); - } - - private boolean checkIfMachinePart(World world, int x, int y, int z) - { - if(!teList.isEmpty()) - { - Iterator i = MultiBlockSpacerBlock.teList.iterator(); - while(i.hasNext()) - { - IMultiBlock te = i.next(); - if(te!=null && !te.getIsInvalid()) - { - if(te.isAPartOfStructure(x, y, z, true)) - { - return true; - } - } - else - { - teList.remove(i); - } - } - } - return false; - } - - private IMultiBlock getLinkedTileEntity(World world, int x, int y, int z) - { - if(!teList.isEmpty()) - { - Iterator i = MultiBlockSpacerBlock.teList.iterator(); - while(i.hasNext()) - { - IMultiBlock te = i.next(); - if(te!=null && !te.getIsInvalid()) - { - if(te.isAPartOfStructure(x, y, z, false)) - { - return te; - } - } - else - { - teList.remove(i); - } - } - } - return null; - } - - /** - * Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two - * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. - */ - @Override - public boolean isOpaqueCube() - { - return false; - } - - /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public void onBlockAdded(World world, int x, int y,int z) - { - world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world)); - } - - @Override - public void onNeighborBlockChange(World world, int x, int y,int z, Block block) - { - this.updateTick(world, x, y, z, world.rand); - } - -@Override -public void updateTick(World world, int x, int y,int z, Random rand) -{ - world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world)); - if(!world.isRemote) - { - boolean setToAir=true; - if(teList.size()>0) - { - if(!teList.isEmpty()) - { - Iterator i = MultiBlockSpacerBlock.teList.iterator(); - while(i.hasNext()) - { - IMultiBlock te = i.next(); - if(te!=null && !te.getIsInvalid()) - { - if(te.isAPartOfStructure(x, y, z, false)) - { - setToAir=false; - } - } - else - { - teList.remove(i); - } - } - } - } - if(setToAir) - { - world.setBlockToAir(x, y, z); - } - } -} - - @Override - public int tickRate(World world) - { - return 200; - } - - @Override - public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z) - { - IMultiBlock te = this.getLinkedTileEntity(world, x, y, z); - ItemStack currentIS = entityPlayer.inventory.getCurrentItem(); - if(currentIS!=null) - { - if(currentIS.getItem() instanceof ItemToolWrench) - { - if(((ItemToolWrench)currentIS.getItem()).canTakeDamage(currentIS, 10)) - { - if (IC2.platform.isRendering()) - { - IC2.audioManager.playOnce(entityPlayer, PositionSpec.Hand, "Tools/wrench.ogg", true, 1.0F); - } - else if(IC2.platform.isSimulating()) - { - if(te instanceof DriverTileEntity) - { - DriverTileEntity dte =(DriverTileEntity) te; - if(dte.hasShield) - { - if(dte.advancedShield) - { - world.spawnEntityInWorld(new EntityItem(world, x, y, z, IHLUtils.getThisModItemStack("advancedShieldAssemblyUnitBlock"))); - } - else - { - world.spawnEntityInWorld(new EntityItem(world, x, y, z, IHLUtils.getThisModItemStack("IHLShieldAssemblyUnitBlock"))); - } - } - dte.isAPartOfStructure(x, y, z, true); - world.setBlockToAir(x, y, z); - } - ((ItemToolWrench)currentIS.getItem()).damage(currentIS, 10, entityPlayer); - } - } - return true; - } - } - return te instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(entityPlayer, (IHasGui)te) : true) : false; - } -} \ No newline at end of file diff --git a/ihl/utils/BlockItemRender.java b/ihl/utils/BlockItemRender.java new file mode 100644 index 0000000..5a0c6de --- /dev/null +++ b/ihl/utils/BlockItemRender.java @@ -0,0 +1,206 @@ +package ihl.utils; + +import ic2.core.block.RenderBlockDefault; +import ihl.items_blocks.IHLItemBlock; +import ihl.model.IHLModelRenderer; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; + +public class BlockItemRender implements IItemRenderer{ + private ModelBase model; + private ResourceLocation tex; + private int renderFrom=0; + private int renderTo=0; + private RenderBlockDefault rbd; + private float amendment=0.0F; + private float inventoryOffset=0.0F; + private boolean renderHand; + +public BlockItemRender() +{ + rbd=new RenderBlockDefault(); +} + +public BlockItemRender(ModelBase model1, ResourceLocation texture, int renderFrom1, int renderTo1, float amendment1, float inventoryOffset1) +{ + this.model=model1; + this.tex=texture; + this.renderFrom=renderFrom1; + this.renderTo=renderTo1; + this.amendment=amendment1; + this.inventoryOffset=inventoryOffset1; + this.renderHand=false; +} + +public BlockItemRender(ModelBase model1, ResourceLocation texture, int renderFrom1, int renderTo1, float amendment1, float inventoryOffset1, boolean renderHand1) +{ + this.model=model1; + this.tex=texture; + this.renderFrom=renderFrom1; + this.renderTo=renderTo1; + this.amendment=amendment1; + this.inventoryOffset=inventoryOffset1; + this.renderHand=renderHand1; +} + +@Override +public boolean handleRenderType(ItemStack item, ItemRenderType type) { + switch (type) { + case ENTITY: + return true; + case EQUIPPED: + return true; + case EQUIPPED_FIRST_PERSON: + return true; + case INVENTORY: + return true; + default: + return false; + } +} + +@Override +public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; +} + +@Override +public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + if(tex!=null) + { + Minecraft.getMinecraft().renderEngine.bindTexture(tex); + } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + IHLItemBlock bItem =(IHLItemBlock) item.getItem(); + Block block = bItem.getBlockContained(); + GL11.glScalef(1F, -1F+amendment, -1F); + switch (type) { + case ENTITY: + GL11.glTranslatef(0,-1.5F,0); + if(model!=null) + { + for(int i = this.renderFrom;i ihlItemStackRegistry = new HashMap(); - private static final String Digits = "(\\p{Digit}+)"; - private static final String HexDigits = "(\\p{XDigit}+)"; - private static final String Exp = "[eE][+-]?"+Digits; - private static final String fpRegex = - ("[\\x00-\\x20]*"+ // Optional leading "whitespace" - "[+-]?(" + // Optional sign character - "NaN|" + // "NaN" string - "Infinity|" + // "Infinity" string - "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+ - "(\\.("+Digits+")("+Exp+")?)|"+ - "((" + - "(0[xX]" + HexDigits + "(\\.)?)|" + - "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" + - ")[pP][+-]?" + Digits + "))" + - "[fFdD]?))" + - "[\\x00-\\x20]*");// Optional trailing "whitespace" - - - public static void registerLocally(String name, ItemStack stack) - { +public class IHLUtils { + private static Map ihlItemStackRegistry = new HashMap(); + private static final String Digits = "(\\p{Digit}+)"; + private static final String HexDigits = "(\\p{XDigit}+)"; + private static final String Exp = "[eE][+-]?" + Digits; + private static final String fpRegex = ("[\\x00-\\x20]*" + // Optional + // leading + // "whitespace" + "[+-]?(" + // Optional sign character + "NaN|" + // "NaN" string + "Infinity|" + // "Infinity" string + "(((" + Digits + "(\\.)?(" + Digits + "?)(" + Exp + ")?)|" + "(\\.(" + Digits + ")(" + Exp + ")?)|" + "((" + + "(0[xX]" + HexDigits + "(\\.)?)|" + "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" + ")[pP][+-]?" + + Digits + "))" + "[fFdD]?))" + "[\\x00-\\x20]*");// Optional + // trailing + // "whitespace" + + public static void registerLocally(String name, ItemStack stack) { ihlItemStackRegistry.put(name, stack); } - - public static ItemStack getOreDictItemStack(String name) - { + + public static ItemStack getOreDictItemStack(String name) { ItemStack ore = OreDictionary.getOres(name).get(0); - if(ore==null)return null; + if (ore == null) + return null; ItemStack orecopy = ore.copy(); - orecopy.stackSize=1; + orecopy.stackSize = 1; return orecopy; } - - public static boolean hasOreDictionaryEntry(String name) - { + + public static boolean hasOreDictionaryEntry(String name) { return !OreDictionary.getOres(name).isEmpty(); } - - public static Item getOreDictItem(String name) - { + + public static Item getOreDictItem(String name) { return OreDictionary.getOres(name).get(0).getItem(); } - - public static Block getOreDictBlock(String name) - { + + public static Block getOreDictBlock(String name) { return Block.getBlockFromItem(OreDictionary.getOres(name).get(0).getItem()); } - - public static ItemStack getOreDictItemStackWithSize(String name, int size) - { + + public static ItemStack getOreDictItemStackWithSize(String name, int size) { ItemStack ore = OreDictionary.getOres(name).get(0); - if(ore==null)return null; + if (ore == null) + return null; ItemStack orecopy = ore.copy(); - orecopy.stackSize=size; + orecopy.stackSize = size; return orecopy; } - - public static String getFirstOreDictName(ItemStack stack) - { + + public static String getFirstOreDictName(ItemStack stack) { int[] arrayIDs = OreDictionary.getOreIDs(stack); - if(arrayIDs.length>0) - { + if (arrayIDs.length > 0) { return OreDictionary.getOreName(arrayIDs[0]); } return ""; } - - public static ItemStack getThisModItemStack(String name) - { - if(ihlItemStackRegistry.get(name)!=null) - { + + public static ItemStack getThisModItemStack(String name) { + if (ihlItemStackRegistry.get(name) != null) { return ihlItemStackRegistry.get(name).copy(); } - if(GameRegistry.findItem("ihl", name)!=null) - { + if (GameRegistry.findItem("ihl", name) != null) { return new ItemStack(GameRegistry.findItem("ihl", name)); - } - else if(GameRegistry.findBlock("ihl", name)==null) - { - throw new IllegalArgumentException("No such item in item registry: ihl:"+name); - } - else - { + } else if (GameRegistry.findBlock("ihl", name) == null) { + throw new IllegalArgumentException("No such item in item registry: ihl:" + name); + } else { return new ItemStack(GameRegistry.findBlock("ihl", name)); } } public static ItemStack getThisModItemStackWithSize(String name, int i) { - if(ihlItemStackRegistry.get(name)!=null) - { + if (ihlItemStackRegistry.get(name) != null) { ItemStack stack = ihlItemStackRegistry.get(name).copy(); - stack.stackSize=i; + stack.stackSize = i; return stack; } - if(GameRegistry.findItem("ihl", name)!=null) - { - return new ItemStack(GameRegistry.findItem("ihl", name),i); - } - else if(GameRegistry.findBlock("ihl", name)==null) - { - throw new IllegalArgumentException("No such item in item registry: ihl:"+name); - } - else - { - return new ItemStack(GameRegistry.findBlock("ihl", name),i); + if (GameRegistry.findItem("ihl", name) != null) { + return new ItemStack(GameRegistry.findItem("ihl", name), i); + } else if (GameRegistry.findBlock("ihl", name) == null) { + throw new IllegalArgumentException("No such item in item registry: ihl:" + name); + } else { + return new ItemStack(GameRegistry.findBlock("ihl", name), i); } } - + public static ItemStack getOtherModItemStackWithDamage(String modname, String name, int damage, int quantity) { - if(GameRegistry.findItem(modname, name)!=null) - { - return new ItemStack(GameRegistry.findItem(modname, name),quantity,damage); - } - else if(GameRegistry.findBlock(modname, name)==null) - { + if (GameRegistry.findItem(modname, name) != null) { + return new ItemStack(GameRegistry.findItem(modname, name), quantity, damage); + } else if (GameRegistry.findBlock(modname, name) == null) { return null; - } - else - { - return new ItemStack(GameRegistry.findBlock(modname, name),quantity,damage); + } else { + return new ItemStack(GameRegistry.findBlock(modname, name), quantity, damage); } } - - public static Item getThisModItem(String name) - { - if(GameRegistry.findItem("ihl", name)!=null) - { + + public static Item getThisModItem(String name) { + if (GameRegistry.findItem("ihl", name) != null) { return GameRegistry.findItem("ihl", name); - } - else if(GameRegistry.findBlock("ihl", name)==null) - { - throw new IllegalArgumentException("No such item in item registry: ihl:"+name); - } - else - { + } else if (GameRegistry.findBlock("ihl", name) == null) { + throw new IllegalArgumentException("No such item in item registry: ihl:" + name); + } else { return Item.getItemFromBlock(GameRegistry.findBlock("ihl", name)); } } - + public static FluidStack getFluidStackWithSize(String name, int i) { - if(FluidRegistry.isFluidRegistered(name)) - { + if (FluidRegistry.isFluidRegistered(name)) { return FluidRegistry.getFluidStack(name, i); - } - else - { - throw new IllegalArgumentException("No such fluid: "+name); + } else { + throw new IllegalArgumentException("No such fluid: " + name); } } - public static Block getThisModBlock(String name) - { - if(GameRegistry.findBlock("ihl", name)==null) - { - throw new IllegalArgumentException("No such block in item registry: ihl:"+name); - } - else - { + public static Block getThisModBlock(String name) { + if (GameRegistry.findBlock("ihl", name) == null) { + throw new IllegalArgumentException("No such block in item registry: ihl:" + name); + } else { return GameRegistry.findBlock("ihl", name); } } - public static ItemStack getThisModItemStackWithDamage(String name, - int value) - { + public static ItemStack getThisModItemStackWithDamage(String name, int value) { ItemStack stack = getThisModItemStack(name); stack.setItemDamage(value); return stack; } - public static boolean adjustWireLength(ItemStack stack, int adjustBy) - { + public static boolean adjustWireLength(ItemStack stack, int adjustBy) { int length = getWireLength(stack); - if(length<=0) - { + if (length <= 0) { return true; - } - else - { - int newLength = Math.max(length+adjustBy,0); - stack.stackTagCompound.setInteger(((IWire)stack.getItem()).getTag(),newLength); - stack.stackTagCompound.setInteger(((IWire)stack.getItem()).getTagSecondary(),newLength); - if(newLength==0) - { + } else { + int newLength = Math.max(length + adjustBy, 0); + stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTag(), newLength); + stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTagSecondary(), newLength); + if (newLength == 0) { return true; } return false; } } - public static int getWireLength(ItemStack itemStack) - { - return itemStack.stackTagCompound.getInteger(((IWire)itemStack.getItem()).getTag()); + public static int getWireLength(ItemStack itemStack) { + return itemStack.stackTagCompound.getInteger(((IWire) itemStack.getItem()).getTag()); } - + public static ItemStack getThisModWireItemStackWithLength(String name, int i) { - if(getThisModItemStack(name)!=null) - { + if (getThisModItemStack(name) != null) { ItemStack stack = getThisModItemStack(name); - if(stack.getItem() instanceof IWire) - { + if (stack.getItem() instanceof IWire) { stack.stackTagCompound = new NBTTagCompound(); - stack.stackTagCompound.setInteger(((IWire)stack.getItem()).getTag(),i); - stack.stackTagCompound.setInteger(((IWire)stack.getItem()).getTagSecondary(),i); + stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTag(), i); + stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTagSecondary(), i); return stack; + } else { + throw new IllegalArgumentException("ihl:" + name + " is not an instance of IWire."); } - else - { - throw new IllegalArgumentException("ihl:"+name + " is not an instance of IWire."); - } - } - else - { - throw new IllegalArgumentException("No such item in item registry: ihl:"+name); + } else { + throw new IllegalArgumentException("No such item in item registry: ihl:" + name); } } public static ItemStack getThisModWireItemStackWithLength(ItemStack stack1, int i) { ItemStack stack = stack1.copy(); - if(stack1.getItem() instanceof IWire) - { + if (stack1.getItem() instanceof IWire) { stack.stackTagCompound = new NBTTagCompound(); - stack.stackTagCompound.setInteger(((IWire)stack.getItem()).getTag(),i); - stack.stackTagCompound.setInteger(((IWire)stack.getItem()).getTagSecondary(),i); + stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTag(), i); + stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTagSecondary(), i); return stack; - } - else - { + } else { throw new IllegalArgumentException(stack1.getUnlocalizedName() + " is not an instance of IWire."); } } - - public static boolean isItemsHaveSameOreDictionaryEntry(ItemStack is, ItemStack is1) - { + + public static boolean isItemsHaveSameOreDictionaryEntry(ItemStack is, ItemStack is1) { int[] odids1 = OreDictionary.getOreIDs(is); int[] odids2 = OreDictionary.getOreIDs(is1); - if(odids1!=null && odids1.length>0 && odids2!=null && odids2.length>0) - { - for(int i1=0;i1 0 && odids2 != null && odids2.length > 0) { + for (int i1 = 0; i1 < odids1.length; i1++) { + for (int i2 = 0; i2 < odids2.length; i2++) { + if (!OreDictionary.getOreName(odids1[i1]).contains("Any") && odids1[i1] == odids2[i2]) { return true; } } @@ -310,934 +244,715 @@ public class IHLUtils return false; } - public static List getEntryListForOre(String name) - { + public static List getEntryListForOre(String name) { ArrayList outputList = new ArrayList(); ArrayList oreList = OreDictionary.getOres(name); Iterator oreListIterator = oreList.iterator(); - while(oreListIterator.hasNext()) - { + while (oreListIterator.hasNext()) { outputList.add(oreListIterator.next().copy()); } return outputList; } - public static ItemStack getItemStackIfExist(String name) - { - if(hasOreDictionaryEntry(name)) - { + public static ItemStack getItemStackIfExist(String name) { + if (hasOreDictionaryEntry(name)) { return getOreDictItemStack(name); - } - else - { - if(ihlItemStackRegistry.get(name)!=null) - { + } else { + if (ihlItemStackRegistry.get(name) != null) { return ihlItemStackRegistry.get(name).copy(); } - if(GameRegistry.findItem("ihl", name)!=null) - { + if (GameRegistry.findItem("ihl", name) != null) { return new ItemStack(GameRegistry.findItem("ihl", name)); - } - else if(GameRegistry.findBlock("ihl", name)==null) - { + } else if (GameRegistry.findBlock("ihl", name) == null) { return null; - } - else - { + } else { return new ItemStack(GameRegistry.findBlock("ihl", name)); } } } - public static FluidStack getFluidStackIfExist(String string, int meltingFluidAmount) - { - if(FluidRegistry.isFluidRegistered(string)) - { - return getFluidStackWithSize(string,meltingFluidAmount); + public static FluidStack getFluidStackIfExist(String string, int meltingFluidAmount) { + if (FluidRegistry.isFluidRegistered(string)) { + return getFluidStackWithSize(string, meltingFluidAmount); } return null; } - public static boolean addItemStackToInventory(EntityPlayer player, ItemStack stack) - { - ItemStack[] inv = player.inventory.mainInventory; - for (int i=0;i<=35;i++) - { - if(inv[i]!=null) - { - if(inv[i].getItem()==stack.getItem()) - { - if(inv[i].getItemDamage()==stack.getItemDamage() && inv[i].stackSizeinv[i].getMaxStackSize()) - { - stack.stackSize=inv[i].stackSize-inv[i].getMaxStackSize(); - } - else - { - return true; - } - } - } - } - else - { - inv[i]=stack; + public static boolean addItemStackToInventory(EntityPlayer player, ItemStack stack) { + ItemStack[] inv = player.inventory.mainInventory; + for (int i = 0; i <= 35; i++) { + if (inv[i] != null) { + if (inv[i].getItem() == stack.getItem()) { + if (inv[i].getItemDamage() == stack.getItemDamage() + && inv[i].stackSize < inv[i].getMaxStackSize()) { + inv[i].stackSize += stack.stackSize; + if (inv[i].stackSize > inv[i].getMaxStackSize()) { + stack.stackSize = inv[i].stackSize - inv[i].getMaxStackSize(); + } else { + return true; + } + } + } + } else { + inv[i] = stack; return true; - } - } + } + } return false; } - public static FluidStack getFluidStackWithSizeChemicallyPure(String name, int amount) - { + public static FluidStack getFluidStackWithSizeChemicallyPure(String name, int amount) { FluidStack fstack = getFluidStackWithSize(name, amount); - fstack.tag=new NBTTagCompound(); + fstack.tag = new NBTTagCompound(); fstack.tag.setBoolean("chemicallyPure", true); return fstack; } - public static void removeItemStackFromOreDictionaryEntry(String orename, ItemStack itemStack) - { + public static void removeItemStackFromOreDictionaryEntry(String orename, ItemStack itemStack) { ArrayList orelist = OreDictionary.getOres(orename); Iterator oreListIterator = orelist.iterator(); ItemStack odstack = null; - while(oreListIterator.hasNext()) - { + while (oreListIterator.hasNext()) { odstack = oreListIterator.next(); - if(odstack.getItem()==itemStack.getItem()) - { + if (odstack.getItem() == itemStack.getItem()) { break; - } - else - { + } else { odstack = null; } } - if(odstack != null) - { + if (odstack != null) { orelist.remove(odstack); - IHLMod.log.debug("Stack "+odstack.getDisplayName()+" ("+odstack.toString()+")"+" removed from ore entry '"+orename+"'"); + IHLMod.log.debug("Stack " + odstack.getDisplayName() + " (" + odstack.toString() + ")" + + " removed from ore entry '" + orename + "'"); } } - - public static void addIC2MaceratorRecipe(String input, ItemStack output) - { - if(Recipes.macerator.getOutputFor(getOreDictItemStack(input), false)==null) - { - ((BasicMachineRecipeManager)Recipes.macerator).addRecipe(new RecipeInputOreDict(input), new NBTTagCompound(), true, output); - } - else - { - //IHLMod.log.info("IC2 macerator recipe for "+input+" already exist. Skipped."); + + public static void addIC2MaceratorRecipe(String input, ItemStack output) { + if (Recipes.macerator.getOutputFor(getOreDictItemStack(input), false) == null) { + ((BasicMachineRecipeManager) Recipes.macerator).addRecipe(new RecipeInputOreDict(input), + new NBTTagCompound(), true, output); + } else { + // IHLMod.log.info("IC2 macerator recipe for "+input+" already + // exist. Skipped."); } } - - public static void addIC2MaceratorRecipe(String input, int stacksize, ItemStack output) - { - if(Recipes.macerator.getOutputFor(getOreDictItemStackWithSize(input,stacksize), false)==null) - { - ((BasicMachineRecipeManager)Recipes.macerator).addRecipe(new RecipeInputOreDict(input,stacksize), new NBTTagCompound(), true, output); - } - else - { - //IHLMod.log.info("IC2 macerator recipe for "+input+" already exist. Skipped."); + + public static void addIC2MaceratorRecipe(String input, int stacksize, ItemStack output) { + if (Recipes.macerator.getOutputFor(getOreDictItemStackWithSize(input, stacksize), false) == null) { + ((BasicMachineRecipeManager) Recipes.macerator).addRecipe(new RecipeInputOreDict(input, stacksize), + new NBTTagCompound(), true, output); + } else { + // IHLMod.log.info("IC2 macerator recipe for "+input+" already + // exist. Skipped."); } } - - public static void addIC2MaceratorRecipe(ItemStack input, ItemStack output) - { - if(Recipes.macerator.getOutputFor(input, false)==null) - { + + public static void addIC2MaceratorRecipe(ItemStack input, ItemStack output) { + if (Recipes.macerator.getOutputFor(input, false) == null) { NBTTagCompound tag = new NBTTagCompound(); Recipes.macerator.addRecipe(new RecipeInputItemStack(input), tag, output); - } - else - { - //IHLMod.log.info("IC2 macerator recipe for "+input.getDisplayName()+" already exist. Skipped."); + } else { + // IHLMod.log.info("IC2 macerator recipe for + // "+input.getDisplayName()+" already exist. Skipped."); } } - - public static void addIC2RollingRecipe(ItemStack input, ItemStack output) - { - if(Recipes.metalformerRolling.getOutputFor(input, false)==null) - { + + public static void addIC2RollingRecipe(ItemStack input, ItemStack output) { + if (Recipes.metalformerRolling.getOutputFor(input, false) == null) { NBTTagCompound tag = new NBTTagCompound(); Recipes.metalformerRolling.addRecipe(new RecipeInputItemStack(input), tag, output); - } - else - { - //IHLMod.log.info("IC2 metal former (rolling) recipe for "+input.getDisplayName()+" already exist. Skipped."); + } else { + // IHLMod.log.info("IC2 metal former (rolling) recipe for + // "+input.getDisplayName()+" already exist. Skipped."); } } - - public static void addIC2RollingRecipe(String input, ItemStack output) - { - if(Recipes.metalformerRolling.getOutputFor(getThisModItemStack(input), false)==null) - { + + public static void addIC2RollingRecipe(String input, ItemStack output) { + if (Recipes.metalformerRolling.getOutputFor(getThisModItemStack(input), false) == null) { NBTTagCompound tag = new NBTTagCompound(); Recipes.metalformerRolling.addRecipe(new RecipeInputOreDict(input), tag, output); - } - else - { - //IHLMod.log.info("IC2 metal former (rolling) recipe for "+input+" already exist. Skipped."); + } else { + // IHLMod.log.info("IC2 metal former (rolling) recipe for "+input+" + // already exist. Skipped."); } } - public static void addIC2ExtrudingRecipe(ItemStack input, ItemStack output) - { - if(Recipes.metalformerExtruding.getOutputFor(input, false)==null) - { + public static void addIC2ExtrudingRecipe(ItemStack input, ItemStack output) { + if (Recipes.metalformerExtruding.getOutputFor(input, false) == null) { NBTTagCompound tag = new NBTTagCompound(); Recipes.metalformerExtruding.addRecipe(new RecipeInputItemStack(input), tag, output); - } - else - { - //IHLMod.log.info("IC2 metal former (rolling) recipe for "+input+" already exist. Skipped."); + } else { + // IHLMod.log.info("IC2 metal former (rolling) recipe for "+input+" + // already exist. Skipped."); } } - - public static void addIC2CentrifugeRecipe(String input, ItemStack output, ItemStack output2) - { - if(Recipes.centrifuge.getOutputFor(getOreDictItemStack(input), false)==null) - { + public static void addIC2CentrifugeRecipe(String input, ItemStack output, ItemStack output2) { + if (Recipes.centrifuge.getOutputFor(getOreDictItemStack(input), false) == null) { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("minHeat", 2000); - Recipes.centrifuge.addRecipe(new RecipeInputOreDict(input), tag, new ItemStack[] {output,output2}); - } - else - { - //IHLMod.log.info("IC2 centrifuge recipe for "+input+" already exist. Skipped."); + Recipes.centrifuge.addRecipe(new RecipeInputOreDict(input), tag, new ItemStack[] { output, output2 }); + } else { + // IHLMod.log.info("IC2 centrifuge recipe for "+input+" already + // exist. Skipped."); } } - - public static void damageItemViaNBTTag(ItemStack stack, int amount) - { + + public static void damageItemViaNBTTag(ItemStack stack, int amount) { NBTTagCompound gtTagCompound; - if(stack.stackTagCompound.hasKey("GT.ToolStats")) - { + if (stack.stackTagCompound.hasKey("GT.ToolStats")) { gtTagCompound = stack.stackTagCompound.getCompoundTag("GT.ToolStats"); - } - else - { + } else { stack.stackSize--; return; } int damage = 0; int maxDamage = 0; - if(gtTagCompound.hasKey("MaxDamage")) - { + if (gtTagCompound.hasKey("MaxDamage")) { maxDamage = gtTagCompound.getInteger("MaxDamage"); - } - else - { + } else { stack.stackSize--; return; } - - if(gtTagCompound.hasKey("Damage")) - { + + if (gtTagCompound.hasKey("Damage")) { damage = gtTagCompound.getInteger("Damage"); } - if(damage=input.getAmount(); - } - else - { - return stack.stackSize>=input.getAmount(); + + public static boolean isIRecipeInputMatchesWithAmount(IRecipeInput input, ItemStack stack) { + if (input.matches(stack)) { + if (stack.getItem() instanceof IWire) { + return getWireLength(stack) >= input.getAmount(); + } else { + return stack.stackSize >= input.getAmount(); } } return false; } - public static boolean reduceItemStackAmountUsingIRecipeInput(IRecipeInput input, ItemStack stack) { - if(stack.getItem() instanceof IWire) - { - return adjustWireLength(stack,-input.getAmount()); - } - else - { - stack.stackSize-=input.getAmount(); - return stack.stackSize<=0; + public static boolean reduceItemStackAmountUsingIRecipeInput(IRecipeInput input, ItemStack stack, int multiplier) { + if (stack.getItem() instanceof IWire) { + return adjustWireLength(stack, -input.getAmount()*multiplier); + } else { + stack.stackSize -= input.getAmount()*multiplier; + return stack.stackSize <= 0; } } public static String getFirstOreDictNameExcludingTagAny(ItemStack stack) { - int[] arrayIDs = OreDictionary.getOreIDs(stack); - for(int i=0;i output; + if (drainInputSlot != null && !drainInputSlot.isEmpty()) { + output = new MutableObject(); + if (fluidTank + .fill(drainInputSlot.drain(null, fluidTank.getCapacity() - fluidTank.getFluidAmount(), output, + true), false) > 0 + && (output.getValue() == null || emptyFluidItemsSlot.canAdd(output.getValue()))) { + fluidTank.fill( + drainInputSlot.drain(null, fluidTank.getCapacity() - fluidTank.getFluidAmount(), output, false), + true); + if (output.getValue() != null) { + emptyFluidItemsSlot.add(output.getValue()); + } + } + } + if (fillInputSlot != null && !fillInputSlot.isEmpty()) { + output = new MutableObject(); + if (fillInputSlot.transferFromTank(fluidTank, output, true) + && (output.getValue() == null || emptyFluidItemsSlot.canAdd(output.getValue()))) { + fillInputSlot.transferFromTank(fluidTank, output, false); + if (output.getValue() != null) { + emptyFluidItemsSlot.add(output.getValue()); } } - return ""; - } - - public static void handleFluidSlotsBehaviour(InvSlotConsumableLiquidIHL fillInputSlot, InvSlotConsumableLiquidIHL drainInputSlot, InvSlotOutput emptyFluidItemsSlot, IFluidTank fluidTank) - { - MutableObject output; - if (drainInputSlot!=null && !drainInputSlot.isEmpty()) - { - output = new MutableObject(); - if(fluidTank.fill(drainInputSlot.drain(null, fluidTank.getCapacity()-fluidTank.getFluidAmount(), output, true),false)>0 && (output.getValue() == null || emptyFluidItemsSlot.canAdd(output.getValue()))) - { - fluidTank.fill(drainInputSlot.drain(null, fluidTank.getCapacity()-fluidTank.getFluidAmount(), output, false),true); - if(output.getValue()!=null) - { - emptyFluidItemsSlot.add(output.getValue()); - } - } - } - if (fillInputSlot!=null && !fillInputSlot.isEmpty()) - { - output = new MutableObject(); - if (fillInputSlot.transferFromTank(fluidTank, output, true) && (output.getValue() == null || emptyFluidItemsSlot.canAdd(output.getValue()))) - { - fillInputSlot.transferFromTank(fluidTank, output, false); - if(output.getValue()!=null) - { - emptyFluidItemsSlot.add(output.getValue()); - } - } - } - } - public static double[] tracePlayerView(EntityLivingBase player) - { - float f1 = player.rotationPitch; - float f2 = player.rotationYaw; - double x = player.posX; - double y = player.posY; - double z = player.posZ; - if(IC2.platform.isSimulating()) - { - y += player.getEyeHeight(); - } - float f3 = MathHelper.cos(-f2 * 0.01745329F - (float)Math.PI); - float f4 = MathHelper.sin(-f2 * 0.01745329F - (float)Math.PI); - float f5 = -MathHelper.cos(-f1 * 0.01745329F); - float f6 = MathHelper.sin(-f1 * 0.01745329F); - float f7 = f4 * f5; - float f9 = f3 * f5; - double d3 = 1.0D; - return new double[] {x+f7 * d3, y+f6 * d3, z+f9 * d3}; - } - - public static MovingObjectPosition returnMOPFromPlayer(EntityPlayer entityplayer, World world) - { - float f1 = entityplayer.rotationPitch; - float f2 = entityplayer.rotationYaw; - double x = entityplayer.posX; - double y =entityplayer.posY + entityplayer.getEyeHeight(); - - if (world.isRemote) - { - y -= entityplayer.getDefaultEyeHeight(); - } - - double z = entityplayer.posZ; - Vec3 vec3d = Vec3.createVectorHelper(x, y, z); - float f3 = MathHelper.cos(-f2 * 0.01745329F - (float)Math.PI); - float f4 = MathHelper.sin(-f2 * 0.01745329F - (float)Math.PI); - float f5 = -MathHelper.cos(-f1 * 0.01745329F); - float f6 = MathHelper.sin(-f1 * 0.01745329F); - float f7 = f4 * f5; - float f9 = f3 * f5; - double d3 = 5.0D; - Vec3 vec3d1 = vec3d.addVector(f7 * d3, f6 * d3, f9 * d3); - MovingObjectPosition movingobjectposition = world.rayTraceBlocks(vec3d, vec3d1, true); - - if (movingobjectposition == null) - { - return null; - } - - if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) - { - return movingobjectposition; - } - return null; - } - - public static short getFacingFromPlayerView(EntityLivingBase player, boolean ignoreSneaking) - { + } + } + + public static double[] tracePlayerView(EntityLivingBase player) { + float f1 = player.rotationPitch; + float f2 = player.rotationYaw; + double x = player.posX; + double y = player.posY; + double z = player.posZ; + if (IC2.platform.isSimulating()) { + y += player.getEyeHeight(); + } + float f3 = MathHelper.cos(-f2 * 0.01745329F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.01745329F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.01745329F); + float f6 = MathHelper.sin(-f1 * 0.01745329F); + float f7 = f4 * f5; + float f9 = f3 * f5; + double d3 = 1.0D; + return new double[] { x + f7 * d3, y + f6 * d3, z + f9 * d3 }; + } + + public static MovingObjectPosition returnMOPFromPlayer(EntityPlayer entityplayer, World world) { + float f1 = entityplayer.rotationPitch; + float f2 = entityplayer.rotationYaw; + double x = entityplayer.posX; + double y = entityplayer.posY + entityplayer.getEyeHeight(); + + if (world.isRemote) { + y -= entityplayer.getDefaultEyeHeight(); + } + + double z = entityplayer.posZ; + Vec3 vec3d = Vec3.createVectorHelper(x, y, z); + float f3 = MathHelper.cos(-f2 * 0.01745329F - (float) Math.PI); + float f4 = MathHelper.sin(-f2 * 0.01745329F - (float) Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.01745329F); + float f6 = MathHelper.sin(-f1 * 0.01745329F); + float f7 = f4 * f5; + float f9 = f3 * f5; + double d3 = 5.0D; + Vec3 vec3d1 = vec3d.addVector(f7 * d3, f6 * d3, f9 * d3); + MovingObjectPosition movingobjectposition = world.rayTraceBlocks(vec3d, vec3d1, true); + + if (movingobjectposition == null) { + return null; + } + + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + return movingobjectposition; + } + return null; + } + + public static short getFacingFromPlayerView(EntityLivingBase player, boolean ignoreSneaking) { int var6 = MathHelper.floor_double(player.rotationPitch * 4.0F / 360.0F + 0.5D) & 3; int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - { - if(var6==1) - { - return 1; - } - else if(var6==3) - { - return 0; - } - else - { - if(player.isSneaking() && !ignoreSneaking) - { - switch(var7) - { - case 0: - return 3; + { + if (var6 == 1) { + return 1; + } else if (var6 == 3) { + return 0; + } else { + if (player.isSneaking() && !ignoreSneaking) { + switch (var7) { + case 0: + return 3; + case 1: + return 4; + case 2: + return 2; + case 3: + return 5; + default: + break; + } + } else { + switch (var7) { + case 0: + return 2; case 1: - return 4; - case 2: - return 2; - case 3: - return 5; - default: - break; - } - } - else - { - switch(var7) - { - case 0: - return 2; - case 1: - return 5; - case 2: - return 3; - case 3: - return 4; - default: - break; - } - } - } - } + return 5; + case 2: + return 3; + case 3: + return 4; + default: + break; + } + } + } + } return 3; - } + } - public static int getChainID(ItemStack itemStack) - { - if(itemStack!=null && itemStack.stackTagCompound!=null && itemStack.stackTagCompound.hasKey("chainUID")) - { + public static int getChainID(ItemStack itemStack) { + if (itemStack != null && itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey("chainUID")) { return itemStack.stackTagCompound.getInteger("chainUID"); } return -1; } - - public static List convertRecipeInputToItemStackList(List input) - { - Iterator irii=input.iterator(); + + public static List convertRecipeInputToItemStackList(List input) { + Iterator irii = input.iterator(); List output = new ArrayList(); - while(irii.hasNext()) - { + while (irii.hasNext()) { IRecipeInput iri = irii.next(); ItemStack stack = iri.getInputs().get(0); - stack.stackSize=iri.getAmount(); + stack.stackSize = iri.getAmount(); output.add(stack); } return output; } - + public static List convertRecipeInputToFluidStackList(List input) { - Iterator irii=input.iterator(); + Iterator irii = input.iterator(); List output = new ArrayList(); - while(irii.hasNext()) - { + while (irii.hasNext()) { IRecipeInputFluid iri = irii.next(); FluidStack stack = iri.getInputs().get(0); - stack.amount=iri.getAmount(); + stack.amount = iri.getAmount(); output.add(stack); } return output; } - - public static int[] decodeXYZ(long longNumber) - { - return new int[] {(int) ((longNumber>>30) & 0xfff)-256,(int) ((longNumber>>15) & 0xfff)-256,(int) (longNumber & 0xfff)-256}; - } - - public static long encodeXYZ(int x,int y,int z) - { - return (x+256L)<<30|((y+256L)<<15)|(z+256L); - } - - public static int reduceVariableByAbsoluteValue(int variable) - { - if(variable==0) - { - return 0; + + public static String trim(String str) { + int len = str.length(); + int start; + char c; + for (start = 0; start < len; ++start) { + c = str.charAt(start); + if (c > 32 && c != 65279) { + break; + } } - else if(variable<0) - { - return variable+1; + int end; + for (end = len - 1; end >= start; --end) { + c = str.charAt(end); + if (c > 32 && c != 65279) { + break; + } } - else - { - return variable-1; - } - } - - public static long getXYZHash(int x,int y,int z) - { - int sign_bits = (x & 0x80000000) >> 29 | (y & 0x80000000) >> 30 | (z & 0x80000000) >> 31; - return (long)x<<31 ^ (long)y<<17 ^ (long)z<<3 ^ sign_bits; - } - - public static String trim(String str) - { - int len = str.length(); - int start; - char c; - for (start = 0; start < len; ++start) - { - c = str.charAt(start); - if (c > 32 && c != 65279) - { - break; - } - } - int end; - for (end = len - 1; end >= start; --end) - { - c = str.charAt(end); - if (c > 32 && c != 65279) - { - break; - } - } - return start <= 0 && end >= len - 1 ? str : str.substring(start, end + 1); - } - - public static int getAmountOf(ItemStack is) - { - if(is.getItem() instanceof IWire) - { + return start <= 0 && end >= len - 1 ? str : str.substring(start, end + 1); + } + + public static int getAmountOf(ItemStack is) { + if (is.getItem() instanceof IWire) { return getWireLength(is); - } - else - { + } else { return is.stackSize; } } - public static ItemStack getWireItemStackCopyWithLengthMultiplied(ItemStack stack, int multiplier) - { + public static ItemStack getWireItemStackCopyWithLengthMultiplied(ItemStack stack, int multiplier) { ItemStack out = stack.copy(); - adjustWireLength(out,getWireLength(stack)*(multiplier-1)); + adjustWireLength(out, getWireLength(stack) * (multiplier - 1)); return out; } public static ItemStack getUninsulatedWire(String material, int length, int transverseSection) { ItemStack is = getThisModItemStack("copperWire"); - is.stackTagCompound=new NBTTagCompound(); - is.stackTagCompound.setBoolean("firstConnection",false); - is.stackTagCompound.setInteger("fullLength", length); - is.stackTagCompound.setInteger("length", length); - is.stackTagCompound.setString("material", material); - is.stackTagCompound.setInteger("transverseSection",transverseSection); + is.stackTagCompound = new NBTTagCompound(); + is.stackTagCompound.setBoolean("firstConnection", false); + is.stackTagCompound.setInteger("fullLength", length); + is.stackTagCompound.setInteger("length", length); + is.stackTagCompound.setString("material", material); + is.stackTagCompound.setInteger("transverseSection", transverseSection); return is; } - - public static ItemStack getInsulatedWire(String material, int length, int transverseSection, String insulationMaterial, int insulationThickness) { + + public static ItemStack getInsulatedWire(String material, int length, int transverseSection, + String insulationMaterial, int insulationThickness) { ItemStack is = getUninsulatedWire(material, length, transverseSection); - is.stackTagCompound.setString("insulationMaterial",insulationMaterial); - is.stackTagCompound.setInteger("insulationThickness",insulationThickness); - is.stackTagCompound.setInteger("maxVoltage", getInsulationMaxVoltage(insulationMaterial, insulationThickness)); + is.stackTagCompound.setString("insulationMaterial", insulationMaterial); + is.stackTagCompound.setInteger("insulationThickness", insulationThickness); + is.stackTagCompound.setInteger("maxVoltage", getInsulationMaxVoltage(insulationMaterial, insulationThickness)); return is; } - - public static long getResistance(NBTTagCompound cable) - { + + public static long getResistance(NBTTagCompound cable) { String material = cable.getString("material"); int transverseSection = cable.getInteger("transverseSection"); - return ElectricConductor.getResistivity(material)*100L/transverseSection; + return ElectricConductor.getResistivity(material) * 100L / transverseSection; } - - public static int getInsulationMaxVoltage(String insulationMaterial, int insulationThickness) - { - return Math.min(Insulation.getMaxVoltagePermm(insulationMaterial)*insulationThickness/10,Insulation.getMaxVoltageCap(insulationMaterial)); + + public static int getInsulationMaxVoltage(String insulationMaterial, int insulationThickness) { + return Math.min(Insulation.getMaxVoltagePermm(insulationMaterial) * insulationThickness / 10, + Insulation.getMaxVoltageCap(insulationMaterial)); } public static ItemStack getItemStackWithTag(String unLocalizedName, String tag, int tagValue) { ItemStack stack = IHLUtils.getThisModItemStack(unLocalizedName); - if(stack.stackTagCompound==null) - { - stack.stackTagCompound=new NBTTagCompound(); + if (stack.stackTagCompound == null) { + stack.stackTagCompound = new NBTTagCompound(); } stack.stackTagCompound.setInteger(tag, tagValue); return stack; } - public static boolean isSegmentInsideAABB(AxisAlignedBB collisionBox, double posX, double posY, double posZ, double posX2, double posY2, double posZ2) - { - if(isInsideofBoundingBox(collisionBox,(float)posX,(float)posY,(float)posZ)||isInsideofBoundingBox(collisionBox,(float)posX2,(float)posY2,(float)posZ2)) - { + public static boolean isSegmentInsideAABB(AxisAlignedBB collisionBox, double posX, double posY, double posZ, + double posX2, double posY2, double posZ2) { + if (isInsideofBoundingBox(collisionBox, (float) posX, (float) posY, (float) posZ) + || isInsideofBoundingBox(collisionBox, (float) posX2, (float) posY2, (float) posZ2)) { return true; + } else { + double minX = Math.min(posX, posX2); + double maxX = Math.max(posX, posX2); + double minY = Math.min(posY, posY2); + double maxY = Math.max(posY, posY2); + double minZ = Math.min(posZ, posZ2); + double maxZ = Math.max(posZ, posZ2); + return !(maxX < collisionBox.minX || minX > collisionBox.maxX || maxY < collisionBox.minY + || minY > collisionBox.maxY || maxZ < collisionBox.minZ || minZ > collisionBox.maxZ); } - else - { - double minX=Math.min(posX, posX2); - double maxX=Math.max(posX, posX2); - double minY=Math.min(posY, posY2); - double maxY=Math.max(posY, posY2); - double minZ=Math.min(posZ, posZ2); - double maxZ=Math.max(posZ, posZ2); - return !(maxXcollisionBox.maxX || - maxYcollisionBox.maxY || - maxZcollisionBox.maxZ); - } - } - - public static boolean isInsideofBoundingBox(AxisAlignedBB bb, float xi, float yi, float zi) - { - return bb.maxX>xi && bb.minXyi && bb.minYzi && bb.minZ xi && bb.minX < xi && bb.maxY > yi && bb.minY < yi && bb.maxZ > zi && bb.minZ < zi; + } + + public static boolean isBlockCanBeReplaced(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + if (block == Blocks.air || block.isAir(world, x, y, z) || block == Blocks.vine || block == Blocks.tallgrass + || block == Blocks.deadbush || block == Blocks.snow_layer || block == Blocks.snow) { return true; } return false; } - public static void removeChains(IEnergyNetNode te, World world) - { + public static void removeChains(IEnergyNetNode te, World world) { Set cableList = te.getCableList(); Iterator cli = cableList.iterator(); - while(cli.hasNext()) - { + while (cli.hasNext()) { NBTTagCompound c = cli.next(); cli.remove(); IHLMod.enet.removeCableEntities(c); ItemStack is = IHLUtils.getThisModItemStack("copperWire"); - is.stackTagCompound=c; + is.stackTagCompound = c; double[] pps = te.getPortPos(null); EntityItem eitem = new EntityItem(world, pps[0], pps[1], pps[2], is); world.spawnEntityInWorld(eitem); - removeChain(c,null); + removeChain(c, null); } - if(te.getGridID()!=-1) - { + if (te.getGridID() != -1) { IHLMod.enet.splitGrids(te.getGridID(), te); } cableList.clear(); } - - public static void removeChain(NBTTagCompound c, IEnergyNetNode excludeNode) - { - int x = c.getInteger("connectorX1"); - int y = c.getInteger("connectorY1"); - int z = c.getInteger("connectorZ1"); - int t2DimensionId = c.getInteger("connectorDimensionId1"); - short facing2 = c.getShort("connectorFacing1"); - TileEntity t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x, y, z); - IEnergyNetNode te2; - if(t2 instanceof IMultiPowerCableHolder) - { - te2 = ((IMultiPowerCableHolder)t2).getEnergyNetNode(facing2); - } - else if(t2 instanceof IEnergyNetNode) - { - te2 = (IEnergyNetNode)t2; - } - else - { - return; - } - if(excludeNode!=te2) - { - te2.remove(c); - } - x = c.getInteger("connectorX"); - y = c.getInteger("connectorY"); - z = c.getInteger("connectorZ"); - t2DimensionId = c.getInteger("connectorDimensionId"); - facing2 = c.getShort("connectorFacing"); - t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x, y, z); - if(t2 instanceof IMultiPowerCableHolder) - { - te2 = ((IMultiPowerCableHolder)t2).getEnergyNetNode(facing2); - } - else if(t2 instanceof IEnergyNetNode) - { - te2 = (IEnergyNetNode)t2; - } - else - { - return; - } - if(excludeNode!=te2) - { - te2.remove(c); + + public static void removeChain(NBTTagCompound c, IEnergyNetNode excludeNode) { + int x = c.getInteger("connectorX1"); + int y = c.getInteger("connectorY1"); + int z = c.getInteger("connectorZ1"); + int t2DimensionId = c.getInteger("connectorDimensionId1"); + short facing2 = c.getShort("connectorFacing1"); + TileEntity t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x, y, z); + IEnergyNetNode te2; + if (t2 instanceof IMultiPowerCableHolder) { + te2 = ((IMultiPowerCableHolder) t2).getEnergyNetNode(facing2); + } else if (t2 instanceof IEnergyNetNode) { + te2 = (IEnergyNetNode) t2; + } else { + return; + } + if (excludeNode != te2) { + te2.remove(c); + } + x = c.getInteger("connectorX"); + y = c.getInteger("connectorY"); + z = c.getInteger("connectorZ"); + t2DimensionId = c.getInteger("connectorDimensionId"); + facing2 = c.getShort("connectorFacing"); + t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x, y, z); + if (t2 instanceof IMultiPowerCableHolder) { + te2 = ((IMultiPowerCableHolder) t2).getEnergyNetNode(facing2); + } else if (t2 instanceof IEnergyNetNode) { + te2 = (IEnergyNetNode) t2; + } else { + return; + } + if (excludeNode != te2) { + te2.remove(c); } } - - public static boolean isPlayerLookingAt(EntityLivingBase player, AxisAlignedBB aabb) - { + + public static boolean isPlayerLookingAt(EntityLivingBase player, AxisAlignedBB aabb) { double[] pView = tracePlayerView(player); - double x = player.posX; - double y = player.posY; - double z = player.posZ; - if(IC2.platform.isSimulating()) - { - y += player.getEyeHeight(); - } - if( - isLineSegmentInterseptRectangle(x,y,pView[0],pView[1],aabb.minX,aabb.minY,aabb.maxX,aabb.maxY) && - isLineSegmentInterseptRectangle(x,z,pView[0],pView[2],aabb.minX,aabb.minZ,aabb.maxX,aabb.maxZ) && - isLineSegmentInterseptRectangle(z,y,pView[2],pView[1],aabb.minZ,aabb.minY,aabb.maxZ,aabb.maxY)) - { + double x = player.posX; + double y = player.posY; + double z = player.posZ; + if (IC2.platform.isSimulating()) { + y += player.getEyeHeight(); + } + if (isLineSegmentInterseptRectangle(x, y, pView[0], pView[1], aabb.minX, aabb.minY, aabb.maxX, aabb.maxY) + && isLineSegmentInterseptRectangle(x, z, pView[0], pView[2], aabb.minX, aabb.minZ, aabb.maxX, aabb.maxZ) + && isLineSegmentInterseptRectangle(z, y, pView[2], pView[1], aabb.minZ, aabb.minY, aabb.maxZ, + aabb.maxY)) { return true; } return false; } - public static boolean isLineSegmentInterseptRectangle(double sx0_1,double sy0_1,double sx1_1,double sy1_1,double rx0_1,double ry0_1,double rx1_1,double ry1_1) - { - double sx0=sx0_1; - double sy0=sy0_1; - double sx1=sx1_1; - double sy1=sy1_1; - double rx0=rx0_1; - double ry0=ry0_1; - double rx1=rx1_1; - double ry1=ry1_1; - if(sx1_1=y0)||(ry0<=y1 && ry1>=y1)||(rx0<=x0 && rx1>=x0)||(rx0<=x1 && rx1>=x1); - } + double y0 = ay * maxx0 + by; + double y1 = ay * minx1 + by; - public static float parseFloatSafe(String string, float useSafeValue) - { - if (Pattern.matches(fpRegex, string)) - return Float.valueOf(string); - else { - return useSafeValue; - } + double x0 = ax * maxy0 + bx; + double x1 = ax * miny1 + bx; + return (ry0 <= y0 && ry1 >= y0) || (ry0 <= y1 && ry1 >= y1) || (rx0 <= x0 && rx1 >= x0) + || (rx0 <= x1 && rx1 >= x1); } - - public static int parseIntSafe(String string, int useSafeValue) - { - if (Pattern.matches(fpRegex, string)) - return Integer.valueOf(string); - else { - return useSafeValue; - } + + public static float parseFloatSafe(String string, float useSafeValue) { + if (Pattern.matches(fpRegex, string)) + return Float.valueOf(string); + else { + return useSafeValue; + } } + public static int parseIntSafe(String string, int useSafeValue) { + if (Pattern.matches(fpRegex, string)) + return Integer.valueOf(string); + else { + return useSafeValue; + } + } public static boolean isBlockRegisteredInOreDictionaryAs(Block block, String string) { Iterator isoi = OreDictionary.getOres(string).iterator(); - while(isoi.hasNext()) - { - if(Block.getBlockFromItem(isoi.next().getItem())==block) - { + while (isoi.hasNext()) { + if (Block.getBlockFromItem(isoi.next().getItem()) == block) { return true; } } return false; - } - - public static void setBlockAndTileEntityRaw(World world, int x, int y, int z, Block block, TileEntity te) - { - Chunk chunk = world.getChunkProvider().provideChunk(x>>4, z>>4); + } + + public static void setBlockAndTileEntityRaw(World world, int x, int y, int z, Block block, TileEntity te) { + Chunk chunk = world.getChunkProvider().provideChunk(x >> 4, z >> 4); ExtendedBlockStorage[] ebsA = chunk.getBlockStorageArray(); - ExtendedBlockStorage ebs = ebsA[y>>4]; - if(ebs==null) - { + ExtendedBlockStorage ebs = ebsA[y >> 4]; + if (ebs == null) { ebs = new ExtendedBlockStorage(y, true); - ebsA[y>>4] = ebs; + ebsA[y >> 4] = ebs; } - setBlockRaw(ebs,x & 15,y & 15,z & 15,block); - te.xCoord=x; - te.yCoord=y; - te.zCoord=z; + setBlockRaw(ebs, x & 15, y & 15, z & 15, block); + te.xCoord = x; + te.yCoord = y; + te.zCoord = z; te.setWorldObj(world); chunk.addTileEntity(te); } - - public static void setBlockRaw(ExtendedBlockStorage ebs, int x, int y, int z, Block block) - { - int l = ebs.blockLSBArray[y << 8 | z << 4 | x] & 255; - - if (ebs.blockMSBArray != null) - { - l |= ebs.blockMSBArray.get(x, y, z) << 8; - } - - Block block1 = Block.getBlockById(l); - - if (block1 != Blocks.air) - { - --ebs.blockRefCount; - - if (block1.getTickRandomly()) - { - --ebs.tickRefCount; - } - } - - if (block != Blocks.air) - { - ++ebs.blockRefCount; - - if (block.getTickRandomly()) - { - ++ebs.tickRefCount; - } - } - - int i1 = Block.getIdFromBlock(block); - ebs.blockLSBArray[y << 8 | z << 4 | x] = (byte)(i1 & 255); - - if (i1 > 255) - { - if (ebs.blockMSBArray == null) - { - ebs.blockMSBArray = new NibbleArray(ebs.blockLSBArray.length, 4); - } - - ebs.blockMSBArray.set(x, y, z, (i1 & 3840) >> 8); - } - else if (ebs.blockMSBArray != null) - { - ebs.blockMSBArray.set(x, y, z, 0); - } - } - - public static void dumpToFile(Set unlocalisedNames, String filename) { - try { - OutputStreamWriter osWriter = new OutputStreamWriter(new FileOutputStream(getFile(filename)), "UTF-8"); - BufferedWriter writer = new BufferedWriter(osWriter); - for(String string:unlocalisedNames) - { - writer.append(string); - writer.newLine(); + + public static void setBlockRaw(ExtendedBlockStorage ebs, int x, int y, int z, Block block) { + int l = ebs.blockLSBArray[y << 8 | z << 4 | x] & 255; + + if (ebs.blockMSBArray != null) { + l |= ebs.blockMSBArray.get(x, y, z) << 8; + } + + Block block1 = Block.getBlockById(l); + + if (block1 != Blocks.air) { + --ebs.blockRefCount; + + if (block1.getTickRandomly()) { + --ebs.tickRefCount; + } + } + + if (block != Blocks.air) { + ++ebs.blockRefCount; + + if (block.getTickRandomly()) { + ++ebs.tickRefCount; + } + } + + int i1 = Block.getIdFromBlock(block); + ebs.blockLSBArray[y << 8 | z << 4 | x] = (byte) (i1 & 255); + + if (i1 > 255) { + if (ebs.blockMSBArray == null) { + ebs.blockMSBArray = new NibbleArray(ebs.blockLSBArray.length, 4); } - writer.close(); - osWriter.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static File getFile(String filename) - { - File folder = new File(IHLMod.proxy.getMinecraftDir(), "logs"); - folder.mkdirs(); - return new File(folder, filename); - } + + ebs.blockMSBArray.set(x, y, z, (i1 & 3840) >> 8); + } else if (ebs.blockMSBArray != null) { + ebs.blockMSBArray.set(x, y, z, 0); + } + } + } diff --git a/ihl/utils/IHLXMLParser.java b/ihl/utils/IHLXMLParser.java deleted file mode 100644 index 8073542..0000000 --- a/ihl/utils/IHLXMLParser.java +++ /dev/null @@ -1,92 +0,0 @@ -package ihl.utils; - -import ihl.IHLMod; -import ihl.guidebook.IHLGuidebookGui; - -import java.io.IOException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.w3c.dom.*; -import org.xml.sax.SAXException; - -public class IHLXMLParser { - - public DocumentBuilderFactory dbf; - public DocumentBuilder db; - - public IHLXMLParser() throws ParserConfigurationException - { - dbf = DocumentBuilderFactory.newInstance(); - db = dbf.newDocumentBuilder(); - } - - public void visit(Node node, int level, int sectionNumber1, IHLGuidebookGui ihlGuidebookGui) - { - IHLMod.log.debug("Visiting node."); - IHLMod.log.debug("Current section="+sectionNumber1); - IHLMod.log.debug("Node name="+node.getNodeName()); - int sectionNumber = sectionNumber1; - NodeList list = node.getChildNodes(); - IHLMod.log.debug("child size="+list.getLength()); - if (node instanceof Element) - { - IHLMod.log.debug("node instance of Element."); - Element e = (Element) node; - IHLMod.log.debug("Node tagname="+e.getTagName()); - IHLMod.log.debug("Node text content="+e.getTextContent()); - if(e.getTagName().equals("title")) - { - ihlGuidebookGui.setTitle(IHLUtils.trim(e.getTextContent())); - } - else if(e.getTagName().equals("itemstack")) - { - String[] innername = IHLUtils.trim(e.getTextContent()).split(":"); - ihlGuidebookGui.addItemStack(IHLUtils.getOtherModItemStackWithDamage(innername[0], innername[1], Integer.parseInt(e.getAttribute("damage")),1)); - } - else if(e.getTagName().equals("text")) - { - ihlGuidebookGui.addTextBlock(IHLUtils.trim(e.getTextContent())); - } - else if(e.getTagName().equals("image")) - { - ihlGuidebookGui.setPicture(IHLUtils.trim(e.getTextContent()).replace(" ", ""), Integer.parseInt(e.getAttribute("width")),Integer.parseInt(e.getAttribute("height"))); - } - } - for (int i = 0; i < list.getLength(); i++) - { - Node childNode = list.item(i); - if(childNode instanceof Element && ((Element) childNode).getTagName().equals("section")) - { - Element e = (Element) childNode; - int id = Integer.parseInt(e.getAttribute("id")); - ihlGuidebookGui.setMaxSectionNumber(id); - if(sectionNumber==id) - { - visit(childNode, level + 1, sectionNumber, ihlGuidebookGui); - } - else - { - if(sectionNumber > ihlGuidebookGui.getMaxSectionNumber()) - { - sectionNumber=0; - ihlGuidebookGui.setSectionNumber(0); - visit(childNode, level + 1, sectionNumber, ihlGuidebookGui); - } - } - } - else - { - visit(childNode, level + 1, sectionNumber, ihlGuidebookGui); - } - } - } - - public void setupGuidebookGUI(IHLGuidebookGui ihlGuidebookGui, int sectionNumber) throws SAXException, IOException - { - Document doc = db.parse(IHLMod.class.getResourceAsStream("/assets/ihl/config/ihl-guidebook.xml")); - visit(doc, 0, sectionNumber, ihlGuidebookGui); - } -} diff --git a/ihl/utils/PlayerWakeUpEventHandler.java b/ihl/utils/PlayerWakeUpEventHandler.java deleted file mode 100644 index 5b6751f..0000000 --- a/ihl/utils/PlayerWakeUpEventHandler.java +++ /dev/null @@ -1,17 +0,0 @@ -package ihl.utils; - -import net.minecraft.entity.player.EntityPlayer; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class PlayerWakeUpEventHandler -{ - @SubscribeEvent - public void onPlayerWakeUpEvent(net.minecraftforge.event.entity.player.PlayerWakeUpEvent event) - { - if(event.entityPlayer instanceof EntityPlayer && !event.entityPlayer.worldObj.isRemote && !event.entityLiving.getEntityData().hasKey("ihlGuidebookRecieved")) - { - event.entityPlayer.entityDropItem(IHLUtils.getThisModItemStack("guidebook"), 1f); - event.entityPlayer.getEntityData().setBoolean("ihlGuidebookRecieved", true); - } - } -} diff --git a/ihl/worldgen/ores/IHLFluid.java b/ihl/worldgen/ores/IHLFluid.java index 11f1414..ce98b86 100644 --- a/ihl/worldgen/ores/IHLFluid.java +++ b/ihl/worldgen/ores/IHLFluid.java @@ -134,6 +134,7 @@ public class IHLFluid extends Fluid { public enum IHLFluidType { // Methane("Methane","fluidAcetylene",10047, 293, 249, 373, 1150, // "methane", Material.water, false, false, false, false), + NitroGlyceryl("NitroGlycerin", 10052, 293, 291, 583, 1595, "nitroglycerin", Material.water, true, false, true), Ammonia("Ammonia", 10051, 273, 273 - 78, 273 - 33, 0.772F, "ammonia", new MaterialLiquid(MapColor.airColor), false, false, true), Acetaldehyde("Acetaldehyde", 10050, 273, 273 @@ -178,7 +179,7 @@ public class IHLFluid extends Fluid { NatriumHydroxide("NatriumHydroxideDissolvedInWater", 10021, 293, 249, 373, 1525, "solution.natriumhydroxide", Material.water, true, false, false), LiquidGlass("LiquidGlass", 10020, 293, 253, 373, 2400), fluidRubberTreeSap("fluidRubberTreeSap", "fluidRubberTreeSap", 10019, 293, 273, 393, 1200f, "fluidrubbertreesap", Material.water, true, true, false, false), - SpruceResin("SpruceResin", 10018, 293, 273, 533, 1080, "spruceresin", Material.water, true, true, true), + SpruceResin("SpruceResin","fluidSpruceResin", 10018, 293, 273, 533, 1080, "spruceresin", Material.water, true, true, true, false), CablingColophony("CablingColophony", 10017, 363, 363, 533, 1070, "cablingcolophony", Material.water, true, false, true), Glyceryl("Glyceryl", 10016, 293, 291, 583, 1261, "glyceryl", Material.water, true, false, true), SeedOil("SeedOil", 10015, 293, 256, 583, 920, "seedoil", Material.water, true, false, true), -- cgit v1.2.3