From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/ClientProxy.java | 401 ++++++ ihl/IHL3dPathFinder.java | 119 ++ ihl/IHLCreativeTab.java | 35 + ihl/IHLMod.java | 1455 ++++++++++++++++++++ ihl/IHLModConfig.java | 585 ++++++++ ihl/IHLModInfo.java | 7 + ihl/ServerProxy.java | 222 +++ ihl/collector/ChargerEjectorBlock.java | 90 ++ ihl/collector/ChargerEjectorContainer.java | 93 ++ ihl/collector/ChargerEjectorGui.java | 128 ++ ihl/collector/ChargerEjectorModel.java | 150 ++ ihl/collector/ChargerEjectorRender.java | 92 ++ ihl/collector/ChargerEjectorTileEntity.java | 521 +++++++ ihl/collector/CollectorEntity.java | 998 ++++++++++++++ ihl/collector/CollectorHeavyEntity.java | 305 ++++ ihl/collector/CollectorHeavyItem.java | 35 + ihl/collector/CollectorItem.java | 201 +++ ihl/collector/CollectorItemRender.java | 112 ++ ihl/collector/CollectorModel.java | 110 ++ ihl/collector/CollectorRender.java | 112 ++ ihl/collector/GlassBoxContainer.java | 45 + ihl/collector/GlassBoxGui.java | 55 + ihl/collector/GlassBoxRender.java | 49 + ihl/collector/GlassBoxTileEntity.java | 194 +++ ihl/collector/GuiMultiTextureButton.java | 44 + ihl/collector/InvSlotMultiCharge.java | 96 ++ ihl/crop_harvestors/BlobEntityFX.java | 84 ++ ihl/crop_harvestors/BlobRenderFX.java | 63 + ihl/crop_harvestors/BlowerBlock.java | 170 +++ ihl/crop_harvestors/BlowerContainer.java | 89 ++ ihl/crop_harvestors/BlowerGui.java | 66 + ihl/crop_harvestors/BlowerTileEntity.java | 1074 +++++++++++++++ ihl/crop_harvestors/RubberTreeBlock.java | 167 +++ ihl/crop_harvestors/SackBlock.java | 167 +++ ihl/crop_harvestors/SackModel.java | 103 ++ ihl/crop_harvestors/SackRender.java | 95 ++ ihl/crop_harvestors/SackTileEntity.java | 569 ++++++++ ihl/datanet/Contact.java | 254 ++++ ihl/datanet/DataCableItem.java | 187 +++ ihl/datanet/DataGrid.java | 67 + ihl/datanet/DataNet.java | 127 ++ ihl/datanet/GuiInvisibleButton.java | 21 + ihl/datanet/RedstoneSignalConverterContainer.java | 101 ++ ihl/datanet/RedstoneSignalConverterGui.java | 141 ++ ihl/datanet/RedstoneSignalConverterTileEntity.java | 511 +++++++ ihl/enviroment/GlowningAirBlock.java | 34 + ihl/enviroment/LaserHitMirrorEventHandler.java | 48 + ihl/enviroment/LightBulbBlock.java | 133 ++ ihl/enviroment/LightBulbModel.java | 59 + ihl/enviroment/LightBulbRender.java | 77 ++ ihl/enviroment/LightBulbTileEntity.java | 308 +++++ ihl/enviroment/MirrorBlock.java | 222 +++ ihl/enviroment/MirrorRender.java | 427 ++++++ ihl/enviroment/MirrorTileEntity.java | 451 ++++++ ihl/enviroment/SpotlightBlock.java | 108 ++ ihl/enviroment/SpotlightModel.java | 71 + ihl/enviroment/SpotlightRender.java | 109 ++ ihl/enviroment/SpotlightTileEntity.java | 334 +++++ ihl/flexible_cable/AnchorBlock.java | 215 +++ ihl/flexible_cable/AnchorTileEntity.java | 446 ++++++ ihl/flexible_cable/BatterySwitchUnitModel.java | 48 + .../BatterySwitchUnitTileEntity.java | 302 ++++ ihl/flexible_cable/BlastEntityFX.java | 68 + .../FlexibleCableHolderBaseTileEntity.java | 236 ++++ ihl/flexible_cable/IHLENet.java | 164 +++ ihl/flexible_cable/IHLGrid.java | 300 ++++ ihl/flexible_cable/InvSlotOutputInProgress.java | 93 ++ .../InvSlotProcessableIronWorkbench.java | 106 ++ ihl/flexible_cable/InvSlotTool.java | 88 ++ ihl/flexible_cable/InvSlotWorkspaceElement.java | 198 +++ ihl/flexible_cable/IronWorkbenchContainer.java | 131 ++ ihl/flexible_cable/IronWorkbenchGui.java | 197 +++ ihl/flexible_cable/IronWorkbenchInvSlot.java | 30 + ihl/flexible_cable/IronWorkbenchModel.java | 48 + ihl/flexible_cable/IronWorkbenchTileEntity.java | 367 +++++ ihl/flexible_cable/NodeEntity.java | 617 +++++++++ ihl/flexible_cable/NodeRender.java | 85 ++ ihl/flexible_cable/PowerCableNodeEntity.java | 248 ++++ .../RectifierTransformerUnitTileEntity.java | 333 +++++ ihl/flexible_cable/SetOfDiesMiniGUI.java | 87 ++ ihl/flexible_cable/SubAnchorEnergyNetNode.java | 337 +++++ ihl/flexible_cable/SubRTUEnergyNetNode.java | 309 +++++ ihl/guidebook/IHLGuidebookContainer.java | 30 + ihl/guidebook/IHLGuidebookGui.java | 288 ++++ ihl/guidebook/IHLGuidebookInventory.java | 123 ++ ihl/guidebook/IHLGuidebookItem.java | 63 + ihl/guidebook/IHLGuidebookSlot.java | 20 + ihl/handpump/AdvancedHandPump.java | 354 +++++ ihl/handpump/BlockWithCoordinates.java | 115 ++ ihl/handpump/IHLHandPump.java | 350 +++++ ihl/i_hate_liquids/BlockDynamicLiquidPlus.java | 81 ++ ihl/i_hate_liquids/IHLBucketHandler.java | 21 + ihl/i_hate_liquids/IHLEventHandler.java | 59 + ihl/i_hate_liquids/InvisibleMagicanEntity.java | 570 ++++++++ ihl/i_hate_liquids/XYZ.java | 26 + ihl/interfaces/ICableHolder.java | 10 + ihl/interfaces/IDataCableHolder.java | 18 + ihl/interfaces/IDataNode.java | 21 + ihl/interfaces/IEnergyNetNode.java | 19 + ihl/interfaces/IHasTemperature.java | 4 + ihl/interfaces/IItemHasMiniGUI.java | 13 + ihl/interfaces/IMultiPowerCableHolder.java | 11 + ihl/interfaces/INetworkListener.java | 13 + ihl/interfaces/ISelectionBoxSpecialRenderer.java | 10 + ihl/interfaces/IWire.java | 9 + ihl/interfaces/IWorkspaceElement.java | 10 + ihl/interfaces/ItemMiniGUI.java | 24 + ihl/items_blocks/ExplosiveBlock.java | 255 ++++ ihl/items_blocks/FiberItem.java | 107 ++ ihl/items_blocks/FlexibleCableItem.java | 573 ++++++++ ihl/items_blocks/FlexiblePipeItem.java | 128 ++ ihl/items_blocks/GroundRemoverItem.java | 92 ++ ihl/items_blocks/IHLFluidBlock.java | 120 ++ ihl/items_blocks/IHLItemBlock.java | 280 ++++ ihl/items_blocks/IHLTool.java | 431 ++++++ ihl/items_blocks/ItemSubstance.java | 392 ++++++ ihl/items_blocks/MachineBaseBlock.java | 880 ++++++++++++ ihl/items_blocks/RecipeInputs.java | 25 + ihl/metallurgy/constants/Details.java | 53 + ihl/metallurgy/constants/ElectricConductor.java | 49 + ihl/metallurgy/constants/Insulation.java | 40 + .../CableHolderSelectionBoxSpecialRenderer.java | 38 + ihl/model/FlexibleCableItemRender.java | 226 +++ ihl/model/FluidRenderer.java | 154 +++ ihl/model/IHLBlockRenderer.java | 75 + ihl/model/IHLModelRenderer.java | 366 +++++ ihl/model/IHLToolRenderer.java | 83 ++ ihl/model/ImpregnatingMachineBlockRender.java | 131 ++ ihl/model/IronWorkbenchBlockRender.java | 111 ++ ihl/model/ModelKnee.java | 225 +++ ihl/model/ModelToplessBox.java | 204 +++ ihl/model/ModelTube.java | 275 ++++ ihl/model/MultiMetaBlockRender.java | 77 ++ ihl/model/RectifierTransformerUnitBlockRender.java | 414 ++++++ ...TransformerUnitSelectionBoxSpecialRenderer.java | 54 + ihl/model/RefluxCondenserBlockRender.java | 123 ++ ihl/model/RenderGameOverlayEventHandler.java | 39 + ihl/model/RenderInfo.java | 68 + ihl/model/SwitchBoxBlockRender.java | 129 ++ ihl/model/UniversalTileRender.java | 73 + .../AchesonFurnaceRecipeHandler.java | 98 ++ .../ChemicalReactorRecipeHandler.java | 140 ++ ihl/nei_integration/ChimneyKneeRecipeHandler.java | 73 + ihl/nei_integration/CrucibleRecipeHandler.java | 86 ++ .../CryogenicDistillerRecipeHandler.java | 111 ++ .../DetonationSprayingMachineRecipeHandler.java | 88 ++ .../ElectricEvaporatorRecipeHandler.java | 81 ++ .../ElectrolysisBathRecipeHandler.java | 74 + ihl/nei_integration/EvaporatorRecipeHandler.java | 80 ++ ihl/nei_integration/ExtruderRecipeHandler.java | 73 + .../FluidizedBedReactorRecipeHandler.java | 112 ++ .../FractionationColumnRecipeHandler.java | 73 + .../GasWeldingStationGasRecipeHandler.java | 81 ++ ihl/nei_integration/IHLBlockHighlightHandler.java | 51 + ihl/nei_integration/IHLPositionedStack.java | 15 + ihl/nei_integration/IHLRecipeHandler.java | 240 ++++ .../ImpregnatingMachineRecipeHandler.java | 112 ++ .../InjectionMoldRecipeHandler.java | 73 + .../IronWorkbenchRecipeHandler.java | 297 ++++ .../LabElectrolyzerRecipeHandler.java | 74 + ihl/nei_integration/LeadOvenRecipeHandler.java | 100 ++ ihl/nei_integration/LoomRecipeHandler.java | 81 ++ ihl/nei_integration/MachineRecipeHandler.java | 514 +++++++ .../MuffleFurnaceRecipeHandler.java | 89 ++ ihl/nei_integration/NEIIHLConfig.java | 121 ++ ihl/nei_integration/PaperMachineRecipeHandler.java | 74 + .../PrecipitatorCondenserRecipeHandler.java | 73 + .../RollingMachineRecipeHandler.java | 73 + .../VulcanizationExtrudingMoldRecipeHandler.java | 73 + ihl/nei_integration/WireMillRecipeHandler.java | 109 ++ .../WoodenRollingMachineRecipeHandler.java | 80 ++ ihl/processing/chemistry/AbsorberCoolerModel.java | 78 ++ .../chemistry/ApparatusProcessableInvSlot.java | 67 + ihl/processing/chemistry/BatteryItem.java | 197 +++ .../chemistry/ChemicalReactorContainer.java | 109 ++ ihl/processing/chemistry/ChemicalReactorGui.java | 84 ++ .../chemistry/ChemicalReactorTileEntity.java | 363 +++++ .../chemistry/CryogenicDistillerContainer.java | 90 ++ .../chemistry/CryogenicDistillerGui.java | 62 + .../chemistry/CryogenicDistillerTileEntity.java | 252 ++++ .../chemistry/ElectricEvaporatorBlock.java | 221 +++ .../chemistry/ElectricEvaporatorContainer.java | 113 ++ .../chemistry/ElectricEvaporatorGui.java | 86 ++ .../chemistry/ElectricEvaporatorTileEntity.java | 444 ++++++ .../chemistry/ElectrolysisBathContainer.java | 94 ++ ihl/processing/chemistry/ElectrolysisBathGui.java | 100 ++ .../chemistry/ElectrolysisBathModel.java | 86 ++ .../chemistry/ElectrolysisBathTileEntity.java | 312 +++++ ihl/processing/chemistry/EvaporatorBlock.java | 222 +++ ihl/processing/chemistry/EvaporatorContainer.java | 100 ++ ihl/processing/chemistry/EvaporatorGui.java | 85 ++ ihl/processing/chemistry/EvaporatorTileEntity.java | 299 ++++ ihl/processing/chemistry/ExplosiveTileEntity.java | 49 + ihl/processing/chemistry/ExtruderModel.java | 100 ++ .../chemistry/FluidizedBedReactorContainer.java | 103 ++ .../chemistry/FluidizedBedReactorGui.java | 66 + .../chemistry/FluidizedBedReactorTileEntity.java | 358 +++++ .../chemistry/FractionatorBottomModel.java | 48 + .../chemistry/FractionatorBottomTileEntity.java | 389 ++++++ .../chemistry/FractionatorCoverModel.java | 52 + .../chemistry/FractionatorCoverTileEntity.java | 105 ++ .../chemistry/FractionatorSectionModel.java | 47 + .../chemistry/FractionatorSectionTileEntity.java | 146 ++ .../GaedesMercuryRotaryPumpContainer.java | 76 + .../chemistry/GaedesMercuryRotaryPumpGui.java | 69 + .../chemistry/GaedesMercuryRotaryPumpModel.java | 64 + .../GaedesMercuryRotaryPumpTileEntity.java | 83 ++ ihl/processing/chemistry/GoldChimneyKneeModel.java | 45 + .../chemistry/GoldChimneyKneeRender.java | 50 + .../chemistry/GoldChimneyKneeTileEntity.java | 293 ++++ .../chemistry/LabElectrolyzerContainer.java | 133 ++ ihl/processing/chemistry/LabElectrolyzerGui.java | 83 ++ .../chemistry/LabElectrolyzerTileEntity.java | 298 ++++ ihl/processing/chemistry/LeadOvenContainer.java | 80 ++ ihl/processing/chemistry/LeadOvenGui.java | 51 + ihl/processing/chemistry/LeadOvenTileEntity.java | 343 +++++ ihl/processing/chemistry/LoomContainer.java | 66 + ihl/processing/chemistry/LoomGui.java | 61 + ihl/processing/chemistry/LoomModel.java | 66 + ihl/processing/chemistry/LoomTileEntity.java | 173 +++ .../chemistry/PaperMachineContainer.java | 106 ++ ihl/processing/chemistry/PaperMachineGui.java | 84 ++ .../chemistry/PaperMachineTileEntity.java | 320 +++++ .../chemistry/PrecipitatorCondenserModel.java | 110 ++ .../chemistry/PrecipitatorCondenserRender.java | 50 + .../chemistry/PrecipitatorCondenserTileEntity.java | 380 +++++ ihl/processing/chemistry/RefluxCondenserModel.java | 70 + .../chemistry/RefluxCondenserTileEntity.java | 146 ++ ihl/processing/invslots/IHLInvSlotOutput.java | 211 +++ .../invslots/InvSlotConsumableLiquidIHL.java | 271 ++++ .../invslots/InvSlotSignalProcessor.java | 125 ++ .../invslots/SlotInvSlotOutputInProgress.java | 23 + .../SlotRedstoneConverterCableInvSlot.java | 23 + ihl/processing/metallurgy/AchesonFurnaceGui.java | 48 + .../metallurgy/AchesonFurnanceContainer.java | 17 + .../metallurgy/AchesonFurnanceTileEntity.java | 150 ++ .../metallurgy/BasicElectricMotorTileEntity.java | 302 ++++ .../metallurgy/BigMachineFrameTileEntity.java | 109 ++ ihl/processing/metallurgy/CoilerContainer.java | 65 + ihl/processing/metallurgy/CoilerGui.java | 52 + ihl/processing/metallurgy/CoilerModel.java | 103 ++ ihl/processing/metallurgy/CoilerRender.java | 83 ++ ihl/processing/metallurgy/CoilerTileEntity.java | 171 +++ ihl/processing/metallurgy/Crucible.java | 389 ++++++ ihl/processing/metallurgy/CrucibleContainer.java | 67 + ihl/processing/metallurgy/CrucibleGui.java | 86 ++ ihl/processing/metallurgy/CrucibleInventory.java | 155 +++ ihl/processing/metallurgy/CrucibleSlot.java | 20 + .../DetonationSprayingMachineContainer.java | 39 + .../metallurgy/DetonationSprayingMachineGui.java | 54 + .../metallurgy/DetonationSprayingMachineModel.java | 65 + .../DetonationSprayingMachineRender.java | 61 + .../DetonationSprayingMachineTileEntity.java | 251 ++++ .../metallurgy/DrawingDeskContainer.java | 36 + ihl/processing/metallurgy/DrawingDeskGui.java | 59 + ihl/processing/metallurgy/DrawingDeskModel.java | 66 + .../metallurgy/DrawingDeskTileEntity.java | 173 +++ .../metallurgy/ElectricEngineInvSlot.java | 54 + ihl/processing/metallurgy/ElectricEngineItem.java | 84 ++ ihl/processing/metallurgy/ExtruderContainer.java | 75 + ihl/processing/metallurgy/ExtruderGui.java | 58 + ihl/processing/metallurgy/ExtruderModel.java | 100 ++ ihl/processing/metallurgy/ExtruderTileEntity.java | 170 +++ .../metallurgy/GasWeldingStationContainer.java | 99 ++ .../metallurgy/GasWeldingStationGui.java | 79 ++ .../metallurgy/GasWeldingStationModel.java | 108 ++ .../metallurgy/GasWeldingStationTileEntity.java | 337 +++++ ihl/processing/metallurgy/IProductionLine.java | 12 + .../metallurgy/ImpregnatingMachineContainer.java | 114 ++ .../metallurgy/ImpregnatingMachineGui.java | 63 + .../metallurgy/ImpregnatingMachineRender.java | 53 + .../metallurgy/ImpregnatingMachineTileEntity.java | 393 ++++++ ihl/processing/metallurgy/InjectionMoldBlock.java | 254 ++++ .../metallurgy/InjectionMoldTileEntity.java | 194 +++ ihl/processing/metallurgy/LatheContainer.java | 72 + ihl/processing/metallurgy/LatheGui.java | 60 + ihl/processing/metallurgy/LathePart1Model.java | 93 ++ .../metallurgy/LathePart1TileEntity.java | 98 ++ ihl/processing/metallurgy/LathePart2Model.java | 87 ++ .../metallurgy/LathePart2TileEntity.java | 105 ++ .../metallurgy/MachineBaseContainer.java | 74 + .../metallurgy/MachineBaseTileEntity.java | 282 ++++ ihl/processing/metallurgy/MuffleFurnaceGui.java | 51 + .../metallurgy/MuffleFurnanceContainer.java | 15 + .../metallurgy/MuffleFurnanceTileEntity.java | 135 ++ ihl/processing/metallurgy/PassiveBlock.java | 99 ++ .../metallurgy/RollingMachineContainer.java | 75 + ihl/processing/metallurgy/RollingMachineGui.java | 59 + .../metallurgy/RollingMachinePart1Model.java | 97 ++ .../metallurgy/RollingMachinePart1TileEntity.java | 161 +++ .../metallurgy/RollingMachinePart2Model.java | 42 + .../metallurgy/RollingMachinePart2TileEntity.java | 105 ++ .../metallurgy/RollingMachineRender.java | 84 ++ .../VacuumInductionMeltingFurnaceContainer.java | 77 ++ .../VacuumInductionMeltingFurnaceGui.java | 87 ++ .../VacuumInductionMeltingFurnaceTileEntity.java | 260 ++++ .../VulcanizationExtrudingMoldModel.java | 54 + .../VulcanizationExtrudingMoldTileEntity.java | 280 ++++ ihl/processing/metallurgy/WireMillContainer.java | 113 ++ ihl/processing/metallurgy/WireMillGui.java | 72 + ihl/processing/metallurgy/WireMillTileEntity.java | 385 ++++++ .../metallurgy/WoodenRollingMachineContainer.java | 77 ++ .../metallurgy/WoodenRollingMachineGui.java | 69 + .../metallurgy/WoodenRollingMachinePart1Model.java | 122 ++ .../WoodenRollingMachinePart1TileEntity.java | 171 +++ .../metallurgy/WoodenRollingMachinePart2Model.java | 44 + .../WoodenRollingMachinePart2TileEntity.java | 105 ++ .../metallurgy/WoodenRollingMachineRender.java | 94 ++ ihl/recipes/IRecipeInputFluid.java | 12 + ihl/recipes/IronWorkbenchRecipe.java | 182 +++ ihl/recipes/RecipeInputDie.java | 98 ++ ihl/recipes/RecipeInputFluidDictionary.java | 43 + ihl/recipes/RecipeInputFluidStack.java | 41 + ihl/recipes/RecipeInputObjectInstance.java | 46 + ihl/recipes/RecipeInputOreDictionaryList.java | 149 ++ ihl/recipes/RecipeInputWire.java | 87 ++ ihl/recipes/RecipeOutputItemStack.java | 65 + ihl/recipes/UniversalRecipeInput.java | 305 ++++ ihl/recipes/UniversalRecipeManager.java | 229 +++ ihl/recipes/UniversalRecipeOutput.java | 145 ++ ihl/servitor/BoneBlock.java | 107 ++ ihl/servitor/FlameEntityFX.java | 87 ++ ihl/servitor/FlameRenderFX.java | 55 + ihl/servitor/LostHeadEntity.java | 478 +++++++ ihl/servitor/LostHeadRender.java | 39 + ihl/servitor/SkullItemRender.java | 77 ++ ihl/servitor/SkullModel.java | 153 ++ ihl/servitor/SkullModel.txt | 165 +++ .../TDITBlock.java | 132 ++ .../TDITContainer.java | 93 ++ .../TDITFrequencyTransmitter.java | 173 +++ ihl/trans_dimensional_item_teleporter/TDITGui.java | 57 + .../TDITTileEntity.java | 501 +++++++ 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 | 150 ++ ihl/tunneling_shield/DriverTileEntity.java | 1138 +++++++++++++++ ihl/tunneling_shield/HorizontalMiningPipe.java | 276 ++++ .../HydrotransportPulpRegeneratorContainer.java | 99 ++ .../HydrotransportPulpRegeneratorGui.java | 63 + .../HydrotransportPulpRegeneratorTileEntity.java | 273 ++++ ihl/tunneling_shield/IMultiBlock.java | 7 + ihl/tunneling_shield/MultiBlockSpacerBlock.java | 226 +++ ihl/utils/ChunkAndWorldLoadEventHandler.java | 63 + ihl/utils/EntityDropEventHandler.java | 16 + ihl/utils/EntityIHLExplosion.java | 187 +++ ihl/utils/ExplosionVector.java | 453 ++++++ ihl/utils/FluidDictionary.java | 42 + ihl/utils/IHLFluidTank.java | 439 ++++++ ihl/utils/IHLInvSlotDischarge.java | 83 ++ ihl/utils/IHLItemRenderer.java | 294 ++++ ihl/utils/IHLMathUtils.java | 48 + ihl/utils/IHLRenderUtils.java | 820 +++++++++++ ihl/utils/IHLUtils.java | 1110 +++++++++++++++ ihl/utils/IHLXMLParser.java | 141 ++ ihl/utils/PlayerWakeUpEventHandler.java | 17 + ihl/utils/WorldSavedDataBlastWave.java | 92 ++ ihl/worldgen/IHLWorldGenerator.java | 255 ++++ ihl/worldgen/WorldGenLiquidOre.java | 86 ++ ihl/worldgen/WorldGenMinableMeta.java | 128 ++ ihl/worldgen/ores/BlockOre.java | 137 ++ ihl/worldgen/ores/DebugScannerBlock.java | 46 + ihl/worldgen/ores/DebugScannerContainer.java | 49 + ihl/worldgen/ores/DebugScannerGui.java | 71 + ihl/worldgen/ores/DebugScannerTileEntity.java | 161 +++ ihl/worldgen/ores/IHLFluid.java | 363 +++++ 371 files changed, 58895 insertions(+) create mode 100644 ihl/ClientProxy.java create mode 100644 ihl/IHL3dPathFinder.java create mode 100644 ihl/IHLCreativeTab.java create mode 100644 ihl/IHLMod.java create mode 100644 ihl/IHLModConfig.java create mode 100644 ihl/IHLModInfo.java create mode 100644 ihl/ServerProxy.java create mode 100644 ihl/collector/ChargerEjectorBlock.java create mode 100644 ihl/collector/ChargerEjectorContainer.java create mode 100644 ihl/collector/ChargerEjectorGui.java create mode 100644 ihl/collector/ChargerEjectorModel.java create mode 100644 ihl/collector/ChargerEjectorRender.java create mode 100644 ihl/collector/ChargerEjectorTileEntity.java create mode 100644 ihl/collector/CollectorEntity.java create mode 100644 ihl/collector/CollectorHeavyEntity.java create mode 100644 ihl/collector/CollectorHeavyItem.java create mode 100644 ihl/collector/CollectorItem.java create mode 100644 ihl/collector/CollectorItemRender.java create mode 100644 ihl/collector/CollectorModel.java create mode 100644 ihl/collector/CollectorRender.java create mode 100644 ihl/collector/GlassBoxContainer.java create mode 100644 ihl/collector/GlassBoxGui.java create mode 100644 ihl/collector/GlassBoxRender.java create mode 100644 ihl/collector/GlassBoxTileEntity.java create mode 100644 ihl/collector/GuiMultiTextureButton.java create mode 100644 ihl/collector/InvSlotMultiCharge.java create mode 100644 ihl/crop_harvestors/BlobEntityFX.java create mode 100644 ihl/crop_harvestors/BlobRenderFX.java create mode 100644 ihl/crop_harvestors/BlowerBlock.java create mode 100644 ihl/crop_harvestors/BlowerContainer.java create mode 100644 ihl/crop_harvestors/BlowerGui.java create mode 100644 ihl/crop_harvestors/BlowerTileEntity.java create mode 100644 ihl/crop_harvestors/RubberTreeBlock.java create mode 100644 ihl/crop_harvestors/SackBlock.java create mode 100644 ihl/crop_harvestors/SackModel.java create mode 100644 ihl/crop_harvestors/SackRender.java create mode 100644 ihl/crop_harvestors/SackTileEntity.java create mode 100644 ihl/datanet/Contact.java create mode 100644 ihl/datanet/DataCableItem.java create mode 100644 ihl/datanet/DataGrid.java create mode 100644 ihl/datanet/DataNet.java create mode 100644 ihl/datanet/GuiInvisibleButton.java create mode 100644 ihl/datanet/RedstoneSignalConverterContainer.java create mode 100644 ihl/datanet/RedstoneSignalConverterGui.java create mode 100644 ihl/datanet/RedstoneSignalConverterTileEntity.java create mode 100644 ihl/enviroment/GlowningAirBlock.java create mode 100644 ihl/enviroment/LaserHitMirrorEventHandler.java create mode 100644 ihl/enviroment/LightBulbBlock.java create mode 100644 ihl/enviroment/LightBulbModel.java create mode 100644 ihl/enviroment/LightBulbRender.java create mode 100644 ihl/enviroment/LightBulbTileEntity.java create mode 100644 ihl/enviroment/MirrorBlock.java create mode 100644 ihl/enviroment/MirrorRender.java create mode 100644 ihl/enviroment/MirrorTileEntity.java create mode 100644 ihl/enviroment/SpotlightBlock.java create mode 100644 ihl/enviroment/SpotlightModel.java create mode 100644 ihl/enviroment/SpotlightRender.java create mode 100644 ihl/enviroment/SpotlightTileEntity.java create mode 100644 ihl/flexible_cable/AnchorBlock.java create mode 100644 ihl/flexible_cable/AnchorTileEntity.java create mode 100644 ihl/flexible_cable/BatterySwitchUnitModel.java create mode 100644 ihl/flexible_cable/BatterySwitchUnitTileEntity.java create mode 100644 ihl/flexible_cable/BlastEntityFX.java create mode 100644 ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java create mode 100644 ihl/flexible_cable/IHLENet.java create mode 100644 ihl/flexible_cable/IHLGrid.java create mode 100644 ihl/flexible_cable/InvSlotOutputInProgress.java create mode 100644 ihl/flexible_cable/InvSlotProcessableIronWorkbench.java create mode 100644 ihl/flexible_cable/InvSlotTool.java create mode 100644 ihl/flexible_cable/InvSlotWorkspaceElement.java create mode 100644 ihl/flexible_cable/IronWorkbenchContainer.java create mode 100644 ihl/flexible_cable/IronWorkbenchGui.java create mode 100644 ihl/flexible_cable/IronWorkbenchInvSlot.java create mode 100644 ihl/flexible_cable/IronWorkbenchModel.java create mode 100644 ihl/flexible_cable/IronWorkbenchTileEntity.java create mode 100644 ihl/flexible_cable/NodeEntity.java create mode 100644 ihl/flexible_cable/NodeRender.java create mode 100644 ihl/flexible_cable/PowerCableNodeEntity.java create mode 100644 ihl/flexible_cable/RectifierTransformerUnitTileEntity.java create mode 100644 ihl/flexible_cable/SetOfDiesMiniGUI.java create mode 100644 ihl/flexible_cable/SubAnchorEnergyNetNode.java create mode 100644 ihl/flexible_cable/SubRTUEnergyNetNode.java create mode 100644 ihl/guidebook/IHLGuidebookContainer.java create mode 100644 ihl/guidebook/IHLGuidebookGui.java create mode 100644 ihl/guidebook/IHLGuidebookInventory.java create mode 100644 ihl/guidebook/IHLGuidebookItem.java create mode 100644 ihl/guidebook/IHLGuidebookSlot.java create mode 100644 ihl/handpump/AdvancedHandPump.java create mode 100644 ihl/handpump/BlockWithCoordinates.java create mode 100644 ihl/handpump/IHLHandPump.java create mode 100644 ihl/i_hate_liquids/BlockDynamicLiquidPlus.java create mode 100644 ihl/i_hate_liquids/IHLBucketHandler.java create mode 100644 ihl/i_hate_liquids/IHLEventHandler.java create mode 100644 ihl/i_hate_liquids/InvisibleMagicanEntity.java create mode 100644 ihl/i_hate_liquids/XYZ.java create mode 100644 ihl/interfaces/ICableHolder.java create mode 100644 ihl/interfaces/IDataCableHolder.java create mode 100644 ihl/interfaces/IDataNode.java create mode 100644 ihl/interfaces/IEnergyNetNode.java create mode 100644 ihl/interfaces/IHasTemperature.java create mode 100644 ihl/interfaces/IItemHasMiniGUI.java create mode 100644 ihl/interfaces/IMultiPowerCableHolder.java create mode 100644 ihl/interfaces/INetworkListener.java create mode 100644 ihl/interfaces/ISelectionBoxSpecialRenderer.java create mode 100644 ihl/interfaces/IWire.java create mode 100644 ihl/interfaces/IWorkspaceElement.java create mode 100644 ihl/interfaces/ItemMiniGUI.java create mode 100644 ihl/items_blocks/ExplosiveBlock.java create mode 100644 ihl/items_blocks/FiberItem.java create mode 100644 ihl/items_blocks/FlexibleCableItem.java create mode 100644 ihl/items_blocks/FlexiblePipeItem.java create mode 100644 ihl/items_blocks/GroundRemoverItem.java create mode 100644 ihl/items_blocks/IHLFluidBlock.java create mode 100644 ihl/items_blocks/IHLItemBlock.java create mode 100644 ihl/items_blocks/IHLTool.java create mode 100644 ihl/items_blocks/ItemSubstance.java create mode 100644 ihl/items_blocks/MachineBaseBlock.java create mode 100644 ihl/items_blocks/RecipeInputs.java create mode 100644 ihl/metallurgy/constants/Details.java create mode 100644 ihl/metallurgy/constants/ElectricConductor.java create mode 100644 ihl/metallurgy/constants/Insulation.java create mode 100644 ihl/model/CableHolderSelectionBoxSpecialRenderer.java create mode 100644 ihl/model/FlexibleCableItemRender.java create mode 100644 ihl/model/FluidRenderer.java create mode 100644 ihl/model/IHLBlockRenderer.java create mode 100644 ihl/model/IHLModelRenderer.java create mode 100644 ihl/model/IHLToolRenderer.java create mode 100644 ihl/model/ImpregnatingMachineBlockRender.java create mode 100644 ihl/model/IronWorkbenchBlockRender.java create mode 100644 ihl/model/ModelKnee.java create mode 100644 ihl/model/ModelToplessBox.java create mode 100644 ihl/model/ModelTube.java create mode 100644 ihl/model/MultiMetaBlockRender.java create mode 100644 ihl/model/RectifierTransformerUnitBlockRender.java create mode 100644 ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java create mode 100644 ihl/model/RefluxCondenserBlockRender.java create mode 100644 ihl/model/RenderGameOverlayEventHandler.java create mode 100644 ihl/model/RenderInfo.java create mode 100644 ihl/model/SwitchBoxBlockRender.java create mode 100644 ihl/model/UniversalTileRender.java create mode 100644 ihl/nei_integration/AchesonFurnaceRecipeHandler.java create mode 100644 ihl/nei_integration/ChemicalReactorRecipeHandler.java create mode 100644 ihl/nei_integration/ChimneyKneeRecipeHandler.java create mode 100644 ihl/nei_integration/CrucibleRecipeHandler.java create mode 100644 ihl/nei_integration/CryogenicDistillerRecipeHandler.java create mode 100644 ihl/nei_integration/DetonationSprayingMachineRecipeHandler.java create mode 100644 ihl/nei_integration/ElectricEvaporatorRecipeHandler.java create mode 100644 ihl/nei_integration/ElectrolysisBathRecipeHandler.java create mode 100644 ihl/nei_integration/EvaporatorRecipeHandler.java create mode 100644 ihl/nei_integration/ExtruderRecipeHandler.java create mode 100644 ihl/nei_integration/FluidizedBedReactorRecipeHandler.java create mode 100644 ihl/nei_integration/FractionationColumnRecipeHandler.java create mode 100644 ihl/nei_integration/GasWeldingStationGasRecipeHandler.java create mode 100644 ihl/nei_integration/IHLBlockHighlightHandler.java create mode 100644 ihl/nei_integration/IHLPositionedStack.java create mode 100644 ihl/nei_integration/IHLRecipeHandler.java create mode 100644 ihl/nei_integration/ImpregnatingMachineRecipeHandler.java create mode 100644 ihl/nei_integration/InjectionMoldRecipeHandler.java create mode 100644 ihl/nei_integration/IronWorkbenchRecipeHandler.java create mode 100644 ihl/nei_integration/LabElectrolyzerRecipeHandler.java create mode 100644 ihl/nei_integration/LeadOvenRecipeHandler.java create mode 100644 ihl/nei_integration/LoomRecipeHandler.java create mode 100644 ihl/nei_integration/MachineRecipeHandler.java create mode 100644 ihl/nei_integration/MuffleFurnaceRecipeHandler.java create mode 100644 ihl/nei_integration/NEIIHLConfig.java create mode 100644 ihl/nei_integration/PaperMachineRecipeHandler.java create mode 100644 ihl/nei_integration/PrecipitatorCondenserRecipeHandler.java create mode 100644 ihl/nei_integration/RollingMachineRecipeHandler.java create mode 100644 ihl/nei_integration/VulcanizationExtrudingMoldRecipeHandler.java create mode 100644 ihl/nei_integration/WireMillRecipeHandler.java create mode 100644 ihl/nei_integration/WoodenRollingMachineRecipeHandler.java create mode 100644 ihl/processing/chemistry/AbsorberCoolerModel.java create mode 100644 ihl/processing/chemistry/ApparatusProcessableInvSlot.java create mode 100644 ihl/processing/chemistry/BatteryItem.java create mode 100644 ihl/processing/chemistry/ChemicalReactorContainer.java create mode 100644 ihl/processing/chemistry/ChemicalReactorGui.java create mode 100644 ihl/processing/chemistry/ChemicalReactorTileEntity.java create mode 100644 ihl/processing/chemistry/CryogenicDistillerContainer.java create mode 100644 ihl/processing/chemistry/CryogenicDistillerGui.java create mode 100644 ihl/processing/chemistry/CryogenicDistillerTileEntity.java create mode 100644 ihl/processing/chemistry/ElectricEvaporatorBlock.java create mode 100644 ihl/processing/chemistry/ElectricEvaporatorContainer.java create mode 100644 ihl/processing/chemistry/ElectricEvaporatorGui.java create mode 100644 ihl/processing/chemistry/ElectricEvaporatorTileEntity.java create mode 100644 ihl/processing/chemistry/ElectrolysisBathContainer.java create mode 100644 ihl/processing/chemistry/ElectrolysisBathGui.java create mode 100644 ihl/processing/chemistry/ElectrolysisBathModel.java create mode 100644 ihl/processing/chemistry/ElectrolysisBathTileEntity.java create mode 100644 ihl/processing/chemistry/EvaporatorBlock.java create mode 100644 ihl/processing/chemistry/EvaporatorContainer.java create mode 100644 ihl/processing/chemistry/EvaporatorGui.java create mode 100644 ihl/processing/chemistry/EvaporatorTileEntity.java create mode 100644 ihl/processing/chemistry/ExplosiveTileEntity.java create mode 100644 ihl/processing/chemistry/ExtruderModel.java create mode 100644 ihl/processing/chemistry/FluidizedBedReactorContainer.java create mode 100644 ihl/processing/chemistry/FluidizedBedReactorGui.java create mode 100644 ihl/processing/chemistry/FluidizedBedReactorTileEntity.java create mode 100644 ihl/processing/chemistry/FractionatorBottomModel.java create mode 100644 ihl/processing/chemistry/FractionatorBottomTileEntity.java create mode 100644 ihl/processing/chemistry/FractionatorCoverModel.java create mode 100644 ihl/processing/chemistry/FractionatorCoverTileEntity.java create mode 100644 ihl/processing/chemistry/FractionatorSectionModel.java create mode 100644 ihl/processing/chemistry/FractionatorSectionTileEntity.java create mode 100644 ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java create mode 100644 ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java create mode 100644 ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java create mode 100644 ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java create mode 100644 ihl/processing/chemistry/GoldChimneyKneeModel.java create mode 100644 ihl/processing/chemistry/GoldChimneyKneeRender.java create mode 100644 ihl/processing/chemistry/GoldChimneyKneeTileEntity.java create mode 100644 ihl/processing/chemistry/LabElectrolyzerContainer.java create mode 100644 ihl/processing/chemistry/LabElectrolyzerGui.java create mode 100644 ihl/processing/chemistry/LabElectrolyzerTileEntity.java create mode 100644 ihl/processing/chemistry/LeadOvenContainer.java create mode 100644 ihl/processing/chemistry/LeadOvenGui.java create mode 100644 ihl/processing/chemistry/LeadOvenTileEntity.java create mode 100644 ihl/processing/chemistry/LoomContainer.java create mode 100644 ihl/processing/chemistry/LoomGui.java create mode 100644 ihl/processing/chemistry/LoomModel.java create mode 100644 ihl/processing/chemistry/LoomTileEntity.java create mode 100644 ihl/processing/chemistry/PaperMachineContainer.java create mode 100644 ihl/processing/chemistry/PaperMachineGui.java create mode 100644 ihl/processing/chemistry/PaperMachineTileEntity.java create mode 100644 ihl/processing/chemistry/PrecipitatorCondenserModel.java create mode 100644 ihl/processing/chemistry/PrecipitatorCondenserRender.java create mode 100644 ihl/processing/chemistry/PrecipitatorCondenserTileEntity.java create mode 100644 ihl/processing/chemistry/RefluxCondenserModel.java create mode 100644 ihl/processing/chemistry/RefluxCondenserTileEntity.java create mode 100644 ihl/processing/invslots/IHLInvSlotOutput.java create mode 100644 ihl/processing/invslots/InvSlotConsumableLiquidIHL.java create mode 100644 ihl/processing/invslots/InvSlotSignalProcessor.java create mode 100644 ihl/processing/invslots/SlotInvSlotOutputInProgress.java create mode 100644 ihl/processing/invslots/SlotRedstoneConverterCableInvSlot.java create mode 100644 ihl/processing/metallurgy/AchesonFurnaceGui.java create mode 100644 ihl/processing/metallurgy/AchesonFurnanceContainer.java create mode 100644 ihl/processing/metallurgy/AchesonFurnanceTileEntity.java create mode 100644 ihl/processing/metallurgy/BasicElectricMotorTileEntity.java create mode 100644 ihl/processing/metallurgy/BigMachineFrameTileEntity.java create mode 100644 ihl/processing/metallurgy/CoilerContainer.java create mode 100644 ihl/processing/metallurgy/CoilerGui.java create mode 100644 ihl/processing/metallurgy/CoilerModel.java create mode 100644 ihl/processing/metallurgy/CoilerRender.java create mode 100644 ihl/processing/metallurgy/CoilerTileEntity.java create mode 100644 ihl/processing/metallurgy/Crucible.java create mode 100644 ihl/processing/metallurgy/CrucibleContainer.java create mode 100644 ihl/processing/metallurgy/CrucibleGui.java create mode 100644 ihl/processing/metallurgy/CrucibleInventory.java create mode 100644 ihl/processing/metallurgy/CrucibleSlot.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineContainer.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineGui.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineModel.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineRender.java create mode 100644 ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java create mode 100644 ihl/processing/metallurgy/DrawingDeskContainer.java create mode 100644 ihl/processing/metallurgy/DrawingDeskGui.java create mode 100644 ihl/processing/metallurgy/DrawingDeskModel.java create mode 100644 ihl/processing/metallurgy/DrawingDeskTileEntity.java create mode 100644 ihl/processing/metallurgy/ElectricEngineInvSlot.java create mode 100644 ihl/processing/metallurgy/ElectricEngineItem.java create mode 100644 ihl/processing/metallurgy/ExtruderContainer.java create mode 100644 ihl/processing/metallurgy/ExtruderGui.java create mode 100644 ihl/processing/metallurgy/ExtruderModel.java create mode 100644 ihl/processing/metallurgy/ExtruderTileEntity.java create mode 100644 ihl/processing/metallurgy/GasWeldingStationContainer.java create mode 100644 ihl/processing/metallurgy/GasWeldingStationGui.java create mode 100644 ihl/processing/metallurgy/GasWeldingStationModel.java create mode 100644 ihl/processing/metallurgy/GasWeldingStationTileEntity.java create mode 100644 ihl/processing/metallurgy/IProductionLine.java create mode 100644 ihl/processing/metallurgy/ImpregnatingMachineContainer.java create mode 100644 ihl/processing/metallurgy/ImpregnatingMachineGui.java create mode 100644 ihl/processing/metallurgy/ImpregnatingMachineRender.java create mode 100644 ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java create mode 100644 ihl/processing/metallurgy/InjectionMoldBlock.java create mode 100644 ihl/processing/metallurgy/InjectionMoldTileEntity.java create mode 100644 ihl/processing/metallurgy/LatheContainer.java create mode 100644 ihl/processing/metallurgy/LatheGui.java create mode 100644 ihl/processing/metallurgy/LathePart1Model.java create mode 100644 ihl/processing/metallurgy/LathePart1TileEntity.java create mode 100644 ihl/processing/metallurgy/LathePart2Model.java create mode 100644 ihl/processing/metallurgy/LathePart2TileEntity.java create mode 100644 ihl/processing/metallurgy/MachineBaseContainer.java create mode 100644 ihl/processing/metallurgy/MachineBaseTileEntity.java create mode 100644 ihl/processing/metallurgy/MuffleFurnaceGui.java create mode 100644 ihl/processing/metallurgy/MuffleFurnanceContainer.java create mode 100644 ihl/processing/metallurgy/MuffleFurnanceTileEntity.java create mode 100644 ihl/processing/metallurgy/PassiveBlock.java create mode 100644 ihl/processing/metallurgy/RollingMachineContainer.java create mode 100644 ihl/processing/metallurgy/RollingMachineGui.java create mode 100644 ihl/processing/metallurgy/RollingMachinePart1Model.java create mode 100644 ihl/processing/metallurgy/RollingMachinePart1TileEntity.java create mode 100644 ihl/processing/metallurgy/RollingMachinePart2Model.java create mode 100644 ihl/processing/metallurgy/RollingMachinePart2TileEntity.java create mode 100644 ihl/processing/metallurgy/RollingMachineRender.java create mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java create mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java create mode 100644 ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java create mode 100644 ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java create mode 100644 ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java create mode 100644 ihl/processing/metallurgy/WireMillContainer.java create mode 100644 ihl/processing/metallurgy/WireMillGui.java create mode 100644 ihl/processing/metallurgy/WireMillTileEntity.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachineContainer.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachineGui.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java create mode 100644 ihl/processing/metallurgy/WoodenRollingMachineRender.java create mode 100644 ihl/recipes/IRecipeInputFluid.java create mode 100644 ihl/recipes/IronWorkbenchRecipe.java create mode 100644 ihl/recipes/RecipeInputDie.java create mode 100644 ihl/recipes/RecipeInputFluidDictionary.java create mode 100644 ihl/recipes/RecipeInputFluidStack.java create mode 100644 ihl/recipes/RecipeInputObjectInstance.java create mode 100644 ihl/recipes/RecipeInputOreDictionaryList.java create mode 100644 ihl/recipes/RecipeInputWire.java create mode 100644 ihl/recipes/RecipeOutputItemStack.java create mode 100644 ihl/recipes/UniversalRecipeInput.java create mode 100644 ihl/recipes/UniversalRecipeManager.java create mode 100644 ihl/recipes/UniversalRecipeOutput.java create mode 100644 ihl/servitor/BoneBlock.java create mode 100644 ihl/servitor/FlameEntityFX.java create mode 100644 ihl/servitor/FlameRenderFX.java create mode 100644 ihl/servitor/LostHeadEntity.java create mode 100644 ihl/servitor/LostHeadRender.java create mode 100644 ihl/servitor/SkullItemRender.java create mode 100644 ihl/servitor/SkullModel.java create mode 100644 ihl/servitor/SkullModel.txt create mode 100644 ihl/trans_dimensional_item_teleporter/TDITBlock.java create mode 100644 ihl/trans_dimensional_item_teleporter/TDITContainer.java create mode 100644 ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java create mode 100644 ihl/trans_dimensional_item_teleporter/TDITGui.java create mode 100644 ihl/trans_dimensional_item_teleporter/TDITTileEntity.java create mode 100644 ihl/tunneling_shield/BlockItemRender.java create mode 100644 ihl/tunneling_shield/DriverBlock.java create mode 100644 ihl/tunneling_shield/DriverContainer.java create mode 100644 ihl/tunneling_shield/DriverEntity.java create mode 100644 ihl/tunneling_shield/DriverGui.java create mode 100644 ihl/tunneling_shield/DriverModel.java create mode 100644 ihl/tunneling_shield/DriverRender.java create mode 100644 ihl/tunneling_shield/DriverRenderEntity.java create mode 100644 ihl/tunneling_shield/DriverTileEntity.java create mode 100644 ihl/tunneling_shield/HorizontalMiningPipe.java create mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorContainer.java create mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java create mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java create mode 100644 ihl/tunneling_shield/IMultiBlock.java create mode 100644 ihl/tunneling_shield/MultiBlockSpacerBlock.java create mode 100644 ihl/utils/ChunkAndWorldLoadEventHandler.java create mode 100644 ihl/utils/EntityDropEventHandler.java create mode 100644 ihl/utils/EntityIHLExplosion.java create mode 100644 ihl/utils/ExplosionVector.java create mode 100644 ihl/utils/FluidDictionary.java create mode 100644 ihl/utils/IHLFluidTank.java create mode 100644 ihl/utils/IHLInvSlotDischarge.java create mode 100644 ihl/utils/IHLItemRenderer.java create mode 100644 ihl/utils/IHLMathUtils.java create mode 100644 ihl/utils/IHLRenderUtils.java create mode 100644 ihl/utils/IHLUtils.java create mode 100644 ihl/utils/IHLXMLParser.java create mode 100644 ihl/utils/PlayerWakeUpEventHandler.java create mode 100644 ihl/utils/WorldSavedDataBlastWave.java create mode 100644 ihl/worldgen/IHLWorldGenerator.java create mode 100644 ihl/worldgen/WorldGenLiquidOre.java create mode 100644 ihl/worldgen/WorldGenMinableMeta.java create mode 100644 ihl/worldgen/ores/BlockOre.java create mode 100644 ihl/worldgen/ores/DebugScannerBlock.java create mode 100644 ihl/worldgen/ores/DebugScannerContainer.java create mode 100644 ihl/worldgen/ores/DebugScannerGui.java create mode 100644 ihl/worldgen/ores/DebugScannerTileEntity.java create mode 100644 ihl/worldgen/ores/IHLFluid.java (limited to 'ihl') diff --git a/ihl/ClientProxy.java b/ihl/ClientProxy.java new file mode 100644 index 0000000..2f8d2e0 --- /dev/null +++ b/ihl/ClientProxy.java @@ -0,0 +1,401 @@ +package ihl; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.parsers.ParserConfigurationException; + +import org.lwjgl.opengl.ARBFramebufferObject; +import org.lwjgl.opengl.EXTFramebufferObject; +import org.lwjgl.opengl.GL30; + +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; +import ihl.enviroment.MirrorRender; +import ihl.enviroment.MirrorTileEntity; +import ihl.enviroment.SpotlightModel; +import ihl.enviroment.SpotlightRender; +import ihl.enviroment.SpotlightTileEntity; +import ihl.flexible_cable.AnchorTileEntity; +import ihl.flexible_cable.BatterySwitchUnitModel; +import ihl.flexible_cable.BatterySwitchUnitTileEntity; +import ihl.flexible_cable.BlastEntityFX; +import ihl.flexible_cable.IronWorkbenchModel; +import ihl.flexible_cable.IronWorkbenchTileEntity; +import ihl.flexible_cable.NodeEntity; +import ihl.flexible_cable.NodeRender; +import ihl.flexible_cable.RectifierTransformerUnitTileEntity; +import ihl.interfaces.INetworkListener; +import ihl.interfaces.ISelectionBoxSpecialRenderer; +import ihl.items_blocks.FlexibleCableItem; +import ihl.items_blocks.IHLTool; +import ihl.items_blocks.MachineBaseBlock.MachineType; +import ihl.model.*; +import ihl.processing.chemistry.ElectrolysisBathModel; +import ihl.processing.chemistry.ElectrolysisBathTileEntity; +import ihl.processing.chemistry.FractionatorBottomModel; +import ihl.processing.chemistry.FractionatorBottomTileEntity; +import ihl.processing.chemistry.FractionatorCoverModel; +import ihl.processing.chemistry.FractionatorCoverTileEntity; +import ihl.processing.chemistry.FractionatorSectionModel; +import ihl.processing.chemistry.FractionatorSectionTileEntity; +import ihl.processing.chemistry.GaedesMercuryRotaryPumpModel; +import ihl.processing.chemistry.GaedesMercuryRotaryPumpTileEntity; +import ihl.processing.chemistry.GoldChimneyKneeModel; +import ihl.processing.chemistry.GoldChimneyKneeRender; +import ihl.processing.chemistry.GoldChimneyKneeTileEntity; +import ihl.processing.chemistry.LoomModel; +import ihl.processing.chemistry.LoomTileEntity; +import ihl.processing.chemistry.PrecipitatorCondenserModel; +import ihl.processing.chemistry.PrecipitatorCondenserRender; +import ihl.processing.chemistry.PrecipitatorCondenserTileEntity; +import ihl.processing.chemistry.RefluxCondenserModel; +import ihl.processing.chemistry.RefluxCondenserTileEntity; +import ihl.processing.metallurgy.CoilerModel; +import ihl.processing.metallurgy.CoilerRender; +import ihl.processing.metallurgy.CoilerTileEntity; +import ihl.processing.metallurgy.DetonationSprayingMachineModel; +import ihl.processing.metallurgy.DetonationSprayingMachineRender; +import ihl.processing.metallurgy.DetonationSprayingMachineTileEntity; +import ihl.processing.metallurgy.ExtruderModel; +import ihl.processing.metallurgy.ExtruderTileEntity; +import ihl.processing.metallurgy.GasWeldingStationModel; +import ihl.processing.metallurgy.GasWeldingStationTileEntity; +import ihl.processing.metallurgy.ImpregnatingMachineRender; +import ihl.processing.metallurgy.ImpregnatingMachineTileEntity; +import ihl.processing.metallurgy.LathePart1Model; +import ihl.processing.metallurgy.LathePart1TileEntity; +import ihl.processing.metallurgy.LathePart2Model; +import ihl.processing.metallurgy.LathePart2TileEntity; +import ihl.processing.metallurgy.RollingMachinePart1Model; +import ihl.processing.metallurgy.RollingMachinePart1TileEntity; +import ihl.processing.metallurgy.RollingMachinePart2Model; +import ihl.processing.metallurgy.RollingMachinePart2TileEntity; +import ihl.processing.metallurgy.RollingMachineRender; +import ihl.processing.metallurgy.VulcanizationExtrudingMoldModel; +import ihl.processing.metallurgy.VulcanizationExtrudingMoldTileEntity; +import ihl.processing.metallurgy.WoodenRollingMachinePart1TileEntity; +import ihl.processing.metallurgy.WoodenRollingMachinePart2Model; +import ihl.processing.metallurgy.WoodenRollingMachinePart2TileEntity; +import ihl.processing.metallurgy.WoodenRollingMachineRender; +import ihl.servitor.FlameEntityFX; +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.EntityDropEventHandler; +import ihl.utils.IHLRenderUtils; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; +import io.netty.buffer.ByteBufOutputStream; +import io.netty.buffer.Unpooled; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GLAllocation; +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.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.FMLEventChannel; +import cpw.mods.fml.common.network.FMLNetworkEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ClientProxy extends ServerProxy { + + public boolean loadMirrorRender=true; + public IHLRenderUtils renderUtils; + public Map sharedBlockRenders = new HashMap(); + public Map,ISelectionBoxSpecialRenderer> selectionBoxSpecialRendererRegistry = new HashMap(); + + public ClientProxy() {} + + @Override + public void load() throws ParserConfigurationException + { + if(this.channel==null) + { + this.channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(IHLModInfo.MODID); + this.channel.register(this); + } + this.renderUtils=new IHLRenderUtils(); + MinecraftForge.EVENT_BUS.register(this.renderUtils); + + registerBlockHandler(new ImpregnatingMachineBlockRender(), MachineType.BronzeTub, MachineType.GlassBox); + registerBlockHandler(new RefluxCondenserBlockRender(), MachineType.RefluxCondenser); + registerBlockHandler(new SwitchBoxBlockRender(), MachineType.RedstoneSignalConverter); + registerBlockHandler(new RectifierTransformerUnitBlockRender(), MachineType.RectifierTransformerUnit); + registerBlockHandler(new IronWorkbenchBlockRender(), MachineType.IronWorkbench); + + 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()); + 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"))); + ClientRegistry.bindTileEntitySpecialRenderer(ImpregnatingMachineTileEntity.class, new ImpregnatingMachineRender()); + ClientRegistry.bindTileEntitySpecialRenderer(DetonationSprayingMachineTileEntity.class, new DetonationSprayingMachineRender()); + ClientRegistry.bindTileEntitySpecialRenderer(GoldChimneyKneeTileEntity.class, new GoldChimneyKneeRender()); + ClientRegistry.bindTileEntitySpecialRenderer(PrecipitatorCondenserTileEntity.class, new PrecipitatorCondenserRender()); + ClientRegistry.bindTileEntitySpecialRenderer(CoilerTileEntity.class, new CoilerRender()); + ClientRegistry.bindTileEntitySpecialRenderer(RollingMachinePart1TileEntity.class, new RollingMachineRender()); + ClientRegistry.bindTileEntitySpecialRenderer(RollingMachinePart2TileEntity.class, new UniversalTileRender(new RollingMachinePart2Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(VulcanizationExtrudingMoldTileEntity.class, new UniversalTileRender(new VulcanizationExtrudingMoldModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(ExtruderTileEntity.class, new UniversalTileRender(new ExtruderModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(WoodenRollingMachinePart1TileEntity.class, new WoodenRollingMachineRender()); + ClientRegistry.bindTileEntitySpecialRenderer(WoodenRollingMachinePart2TileEntity.class, new UniversalTileRender(new WoodenRollingMachinePart2Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/woodenRollingMachine.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(GasWeldingStationTileEntity.class, new UniversalTileRender(new GasWeldingStationModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/gasWeldingStation.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(GaedesMercuryRotaryPumpTileEntity.class, new UniversalTileRender(new GaedesMercuryRotaryPumpModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/extruder.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(FractionatorBottomTileEntity.class, new UniversalTileRender(new FractionatorBottomModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/splitInjectionMold.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(FractionatorSectionTileEntity.class, new UniversalTileRender(new FractionatorSectionModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/splitInjectionMold.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(FractionatorCoverTileEntity.class, new UniversalTileRender(new FractionatorCoverModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/splitInjectionMold.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(RefluxCondenserTileEntity.class, new UniversalTileRender(new RefluxCondenserModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/splitInjectionMold.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(BatterySwitchUnitTileEntity.class, new UniversalTileRender(new BatterySwitchUnitModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/batterySwitchUnit.png"))); + ClientRegistry.bindTileEntitySpecialRenderer(ElectrolysisBathTileEntity.class, new UniversalTileRender(new ElectrolysisBathModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/electrolysisBath.png"))); + if(loadMirrorRender && IHLMod.config.mirrorReflectionRange>0) + { + ClientRegistry.bindTileEntitySpecialRenderer(MirrorTileEntity.class, new MirrorRender()); + } + ClientRegistry.bindTileEntitySpecialRenderer(LightBulbTileEntity.class, new LightBulbRender()); + 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)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("lathePart1"), new BlockItemRender(new LathePart1Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("lathePart2"), new BlockItemRender(new LathePart2Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("rollingMachinePart1"), new BlockItemRender(new RollingMachinePart1Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"), 0, 5, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("rollingMachinePart2"), new BlockItemRender(new RollingMachinePart2Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("coiler"), new BlockItemRender(new CoilerModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"), 0, 6, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("loom"), new BlockItemRender(new LoomModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/detonationSprayingMachine.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("vulcanizationExtrudingMold"), new BlockItemRender(new VulcanizationExtrudingMoldModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("extruder"), new BlockItemRender(new ExtruderModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("woodenRollingMachinePart1"), new BlockItemRender(new WoodenRollingMachinePart2Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/woodenRollingMachine.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("woodenRollingMachinePart2"), new BlockItemRender(new WoodenRollingMachinePart2Model(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/woodenRollingMachine.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("gasWeldingStation"), new BlockItemRender(new GasWeldingStationModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/gasWeldingStation.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("gaedesMercuryRotaryPump"), new BlockItemRender(new GaedesMercuryRotaryPumpModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/extruder.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLMod.ihlSkull, new SkullItemRender()); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("fractionatorBottom"), new BlockItemRender(new FractionatorBottomModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/splitInjectionMold.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("fractionatorSection"), new BlockItemRender(new FractionatorSectionModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/splitInjectionMold.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("fractionatorCover"), new BlockItemRender(new FractionatorCoverModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/splitInjectionMold.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("refluxCondenser"), new BlockItemRender(new RefluxCondenserModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/splitInjectionMold.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("batterySwitchUnit"), new BlockItemRender(new BatterySwitchUnitModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/batterySwitchUnit.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("electrolysisBath"), new BlockItemRender(new ElectrolysisBathModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/electrolysisBath.png"), 0, 0, 0.0F, 0.0F)); + MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("lightBulb"), new BlockItemRender(new LightBulbModel(), new ResourceLocation(IHLModInfo.MODID+":textures/blocks/lightBulb.png"), 0, 1, 0.0F, 0.0F, true)); + 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(NodeEntity.class, new NodeRender()); + MinecraftForge.EVENT_BUS.register(new RenderGameOverlayEventHandler()); + + } + + @Override + public void spawnParticle(int particle, World world, double x, double y, double z, double mx, double my, double mz, float particleScale) + { + switch(particle) + { + case 0: + FlameEntityFX flamePEFX1 = new FlameEntityFX(world,x,y,z,mx,my,mz,particleScale); + world.spawnEntityInWorld(flamePEFX1); + break; + case 1: + BlobEntityFX blob = new BlobEntityFX(world,x,y,z,mx,my,mz,particleScale, FluidType.RESIN); + world.spawnEntityInWorld(blob); + break; + case 2: + BlobEntityFX blob2 = new BlobEntityFX(world,x,y,z,mx,my,mz,particleScale, FluidType.SAP); + world.spawnEntityInWorld(blob2); + break; + case 3: + BlastEntityFX blast = new BlastEntityFX(world,x,y,z,mx,my,mz,particleScale); + world.spawnEntityInWorld(blast); + break; + default: + FlameEntityFX flamePEFX2 = new FlameEntityFX(world,x,y,z,mx,my,mz,particleScale); + world.spawnEntityInWorld(flamePEFX2); + break; + } + } + + @Override + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void registerIcons(TextureStitchEvent.Pre event) + { + if (event.map.getTextureType() == 0) + { + IHLFluid.registerIcons(event.map); + } + } + + @Override + public Render getRenderForEntityClass(Class entityClass) + { + return (Render) RenderManager.instance.entityRenderMap.get(entityClass); + } + + @Override + public void initBlockRenderer() + { + new IHLBlockRenderer(); + } + + @Override + public int getGLDisplayList() + { + return GLAllocation.generateDisplayLists(1); + } + + @Override + public File getMinecraftDir() + { + return Minecraft.getMinecraft().mcDataDir; + } + + @Override + public int shareBlockRendererByMachineType(MachineType type) + { + return sharedBlockRenders.get(type); + } + + public void registerBlockHandler(ISimpleBlockRenderingHandler handler, MachineType... types) + { + RenderingRegistry.registerBlockHandler(handler); + for(MachineType type:types) + { + sharedBlockRenders.put(type, handler.getRenderId()); + } + } + + @SubscribeEvent + public void onPacketFromServerToClient(FMLNetworkEvent.ClientCustomPacketEvent event) throws IOException + { + ByteBuf data = event.packet.payload(); + ByteBufInputStream byteBufInputStream = new ByteBufInputStream(data); + switch(byteBufInputStream.read()) + { + case 0: + int particleId = byteBufInputStream.read(); + float x=byteBufInputStream.readFloat(); + float y=byteBufInputStream.readFloat(); + float z=byteBufInputStream.readFloat(); + float mx=byteBufInputStream.readFloat(); + float my=byteBufInputStream.readFloat(); + float mz=byteBufInputStream.readFloat(); + float particleScale=byteBufInputStream.readFloat(); + this.spawnParticle(particleId, Minecraft.getMinecraft().theWorld, x, y, z, mx, my, mz, particleScale); + break; + case 1: + int entityId = byteBufInputStream.readInt(); + INetworkListener listener = (INetworkListener) Minecraft.getMinecraft().theWorld.getEntityByID(entityId); + if(listener!=null) + { + listener.recieveData(byteBufInputStream); + IHLMod.log.debug("Data delivered to client"); + } + else + { + delayedEntityDataPacket.put(entityId, data); + IHLMod.log.debug("Data delayed. Entity ID="+entityId); + } + break; + } + byteBufInputStream.close(); + } + + @Override + public boolean renderTESpecialSelectionBox(TileEntity te, EntityPlayer player, ItemStack currentItem, MovingObjectPosition target, float partialTicks) + { + ISelectionBoxSpecialRenderer ssbr = selectionBoxSpecialRendererRegistry.get(te.getClass()); + if(ssbr!=null) + { + ssbr.drawSelectionBox(player, currentItem, target, partialTicks); + return true; + } + else + { + return false; + } + } + + @Override + public void sendItemStackNBTTagFromClientToServerPlayer(EntityPlayer player, int slotNumber, String fieldName, int fieldValue) + { + ByteBuf bb = Unpooled.buffer(36); + ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb); + try + { + byteBufOutputStream.write(0); + byteBufOutputStream.writeInt(player.getEntityId()); + byteBufOutputStream.writeInt(player.worldObj.provider.dimensionId); + byteBufOutputStream.writeInt(slotNumber); + byteBufOutputStream.writeInt(fieldValue); + byteBufOutputStream.writeUTF(fieldName); + channel.sendToServer(new FMLProxyPacket(byteBufOutputStream.buffer(),IHLModInfo.MODID)); + byteBufOutputStream.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + + } + +} diff --git a/ihl/IHL3dPathFinder.java b/ihl/IHL3dPathFinder.java new file mode 100644 index 0000000..cfb71d1 --- /dev/null +++ b/ihl/IHL3dPathFinder.java @@ -0,0 +1,119 @@ +package ihl; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; + +public class IHL3dPathFinder { + public double waypointX; + public double waypointY; + public double waypointZ; + + public int lowestPointX; + public int lowestPointY; + public int lowestPointZ; + + public double targetX; + public double targetY; + public double targetZ; + + private Entity entity; + + public IHL3dPathFinder(Entity entity1) + { + this.entity=entity1; + } + + public boolean findPath(double x2, double y2, double z2) + { + if(this.isCourseTraversable(x2, y2, z2, this.entity.posX, this.entity.posY, this.entity.posZ)) + { + this.waypointX=x2; + this.waypointY=y2; + this.waypointZ=z2; + return true; + } + else + { + return this.takeVector(x2, y2, z2); + } + } + + private boolean isCourseTraversable(double toX, double toY, double toZ, double fromX, double fromY, double fromZ) + { + double var9 = toX - fromX; + double var11 = toY - fromY; + double var13 = toZ - fromZ; + double var7 = MathHelper.sqrt_double(var9 * var9 + var11 * var11 + var13 * var13); + var9 /= var7; + var11 /= var7; + var13 /= var7; + AxisAlignedBB var15 = this.entity.boundingBox.copy(); + for (int var16 = 1; var16 < var7; ++var16) + { + var15.offset(var9, var11, var13); + if (!this.entity.worldObj.getCollidingBoundingBoxes(this.entity, var15).isEmpty()) + { + return false; + } + } + return true; + } + + private boolean takeVector(double toX, double toY, double toZ) + { + int x=Math.round((float)toX); + int y=Math.round((float)toY); + int z=Math.round((float)toZ); + int xyz[] = {0,0,1,0,0,-1,0,0}; + List list = new ArrayList(); + for(int thread=0;thread<=256;thread++) + { + if(this.isCourseTraversable(x+0.5D, y+0.5D, z+0.5D, this.entity.posX, this.entity.posY, this.entity.posZ)) + { + this.waypointX=x+0.5D; + this.waypointY=y+0.5D; + this.waypointZ=z+0.5D; + return true; + } + Block block; + long number = new Long(x*256L*256L+y*256L+z); + list.add(number); + double lastDistanceSquared = this.entity.getDistanceSq(x, y, z); + boolean skip=false; + for(int i=0;i<=5;i++) + { + block = entity.worldObj.getBlock(x+xyz[i], y+xyz[i+1], z+xyz[i+2]); + number = new Long((x+xyz[i])*256L*256L+(y+xyz[i+1])*256L+z+xyz[i+2]); + if(block.isAir(entity.worldObj, x+xyz[i], y+xyz[i+1], z+xyz[i+2]) && !list.contains(number) && this.entity.getDistanceSq((double)x+xyz[i], (double)y+xyz[i+1], (double)z+xyz[i+2]) info1 = new ArrayList(); + info1.add("non vulcanized rubber insulated"); + DataCableItem.init(); + GroundRemoverItem.init(); + FlexibleCableItem.init(); + IHLGuidebookItem.init(); + //ExplosiveBlock.init(); + GameRegistry.registerTileEntity(AnchorTileEntity.class, "anchorTileEntity"); + + crucible=new Crucible(); + + 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).setResistance(5.0F); + electricEvaporatorBlock = (new ElectricEvaporatorBlock(Material.iron)).setBlockName("electricEvaporatorBlock").setBlockTextureName(IHLModInfo.MODID+":electricEvaporatorFrontActive").setHardness(5.0F).setResistance(5.0F); + 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"); + GameRegistry.registerTileEntity(SackTileEntity.class, "sackTileEntity"); + GameRegistry.registerBlock(evaporatorBlock, "evaporatorBlock"); + GameRegistry.registerBlock(electricEvaporatorBlock, "electricEvaporatorBlock"); + GameRegistry.registerTileEntity(EvaporatorTileEntity.class, "evaporatorTileEntity"); + GameRegistry.registerTileEntity(ElectricEvaporatorTileEntity.class, "electricEvaporatorTileEntity"); + + GameRegistry.registerBlock(tditBlock, "tditBlock"); + GameRegistry.registerTileEntity(TDITTileEntity.class, "tditTileEntity"); + GameRegistry.registerItem(tditft, "tditftItem"); + proxy.load(); + registerEntities(); + if(!IHLUtils.hasOreDictionaryEntry("ingotBrick")) + { + OreDictionary.registerOre("ingotBrick", Items.brick); + } + if(!IHLUtils.hasOreDictionaryEntry("dustGunpowder")) + { + OreDictionary.registerOre("dustGunpowder", Items.gunpowder); + } + + IHLMod.log.info("IHL precalculating explosion."); + explosionHandler = new ExplosionVector(); + IHLMod.log.info("Explosion calculated. Amount of start vectors is "+explosionHandler.startVectors.size()); + } + + @EventHandler + 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), new Object[]{ "STS", "L L", "LLL", 'S', Items.string, 'T', Items.stick, 'L', Items.leather}); + Recipes.advRecipes.addRecipe(new ItemStack(evaporatorBlock,1), new Object[] { " B ", " I ", " ", Character.valueOf('B'), Items.bucket, Character.valueOf('I'), IC2Items.getItem("ironFurnace")}); + EvaporatorTileEntity.init(); + } + if(IHLMod.config.enableTDIT) + { + Recipes.advRecipes.addRecipe(new ItemStack(tditBlock,1), new Object[] { "AAA", "CMC", "ATA", Character.valueOf('A'), IC2Items.getItem("advancedAlloy"), Character.valueOf('C'), new ItemStack(Blocks.chest,1), Character.valueOf('M'), IC2Items.getItem("advancedMachine"), Character.valueOf('T'), IC2Items.getItem("teleporter")}); + Recipes.advRecipes.addRecipe(new ItemStack(tditft,1), new Object[] { " CC", "IAI", " ", Character.valueOf('I'), IC2Items.getItem("casingiron"), 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), new Object[]{ "XZX", "XYX", "XZX", 'X', Items.bone, 'Y', Items.iron_ingot, 'Z', ihlSkull}); + GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 15), new Object[] {ihlSkull}); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getThisModItemStack("bucket_SpruceResin"), IHLUtils.getThisModItemStack("bucket_tarPitch"), 20F); + ItemStack nuggetTarPitch = OreDictionary.getOres("nuggetTarPitch").get(0).copy(); + GameRegistry.addShapelessRecipe(OreDictionary.getOres("ingotTarPitch").get(0).copy(), new Object[]{nuggetTarPitch,nuggetTarPitch,nuggetTarPitch,nuggetTarPitch,nuggetTarPitch,nuggetTarPitch,nuggetTarPitch,nuggetTarPitch,nuggetTarPitch}); + if(IHLUtils.hasOreDictionaryEntry("brickPeat") && GameRegistry.findItem("Forestry", "bituminousPeat")!=null)GameRegistry.addRecipe(new ItemStack(GameRegistry.findItem("Forestry", "bituminousPeat"), 5), new Object[] { "BBB", "BPB", "BBB", 'B', IHLUtils.getOreDictItemStack("brickPeat"), 'P', OreDictionary.getOres("ingotTarPitch").get(0)}); + pfaalimestone = IHLUtils.getOtherModItemStackWithDamage("PFAAGeologica", "mediumStone",0); + pfaacobblelimestone = IHLUtils.getOtherModItemStackWithDamage("PFAAGeologica", "mediumCobble",0); + isGregTechModLoaded=Loader.isModLoaded("gregtech"); + if(isGregTechModLoaded) + { + try + { + Class.forName("gregapi.GT_API"); + } + catch (ClassNotFoundException e) + { + isGT_API_Version_5=true; + } + if(isGT_API_Version_5) + { + this.loadGT5Recipes(); + } + else + { + this.loadGT6Recipes(); + } + } + else + { + this.loadIC2Recipes(); + } + IHLUtils.addIC2RollingRecipe("ingotTungsten", IHLUtils.getOreDictItemStack("plateTungsten")); + IHLUtils.addIC2CentrifugeRecipe("crushedGyubnera", IHLUtils.getThisModItemStack("crushedPurifiedGyubnera"),IHLUtils.getThisModItemStack("dustPotassiumFeldspar")); + IHLUtils.addIC2CentrifugeRecipe("crushedCinnabar", IHLUtils.getThisModItemStack("crushedPurifiedCinnabar"),IHLUtils.getThisModItemStack("dustPotassiumFeldspar")); + IHLUtils.addIC2CentrifugeRecipe("crushedBauxite", IHLUtils.getThisModItemStack("crushedPurifiedBauxite"),IHLUtils.getOreDictItemStack("dustClay")); + IHLUtils.addIC2CentrifugeRecipe("crushedStibnite", IHLUtils.getThisModItemStack("crushedPurifiedStibnite"),IHLUtils.getOreDictItemStack("dustTinyGold")); + IHLUtils.addIC2MaceratorRecipe("logWood", IHLUtils.getThisModItemStack("dustWood")); + if(IHLUtils.hasOreDictionaryEntry("blockLimestone"))IHLUtils.addIC2MaceratorRecipe("blockLimestone", IHLUtils.getOreDictItemStackWithSize("dustCalcite",4)); + if(pfaalimestone!=null)IHLUtils.addIC2MaceratorRecipe(pfaalimestone, IHLUtils.getOreDictItemStackWithSize("dustCalcite",4)); + if(pfaacobblelimestone!=null)IHLUtils.addIC2MaceratorRecipe(pfaacobblelimestone, IHLUtils.getOreDictItemStackWithSize("dustCalcite",4)); + IHLUtils.addIC2MaceratorRecipe("oreGypsum", IHLUtils.getOreDictItemStack("dustGypsum")); + IHLUtils.addIC2MaceratorRecipe("orePotassiumFeldspar", IHLUtils.getOreDictItemStack("dustPotassiumFeldspar")); + IHLUtils.addIC2MaceratorRecipe("oreLimestone", IHLUtils.getOreDictItemStackWithSize("dustCalcite",4)); + IHLUtils.addIC2MaceratorRecipe("oreSaltpeter", IHLUtils.getOreDictItemStackWithSize("dustSaltpeter",4)); + IHLUtils.addIC2MaceratorRecipe("oreGyubnera", IHLUtils.getThisModItemStackWithSize("crushedGyubnera",2)); + IHLUtils.addIC2MaceratorRecipe("oreCinnabar", IHLUtils.getThisModItemStackWithSize("crushedCinnabar",2)); + IHLUtils.addIC2MaceratorRecipe("oreBauxite", IHLUtils.getThisModItemStackWithSize("crushedBauxite",2)); + IHLUtils.addIC2MaceratorRecipe("crushedPurifiedBauxite", IHLUtils.getThisModItemStack("dustBauxite")); + IHLUtils.addIC2MaceratorRecipe("oreStibnite", IHLUtils.getThisModItemStackWithSize("crushedStibnite",2)); + IHLUtils.addIC2MaceratorRecipe("crushedPurifiedStibnite", IHLUtils.getThisModItemStack("dustStibnite")); + IHLUtils.addIC2MaceratorRecipe("blockGlass", IHLUtils.getOreDictItemStackWithSize("dustGlass",1)); + IHLUtils.addIC2MaceratorRecipe("stickGraphite",2, IHLUtils.getThisModItemStack("dustGraphite")); + IHLUtils.addIC2MaceratorRecipe("oreMica", IHLUtils.getThisModItemStackWithSize("dustMica",4)); + IHLUtils.addIC2MaceratorRecipe("oreTrona", IHLUtils.getThisModItemStackWithSize("dustTrona",4)); + IHLUtils.addIC2MaceratorRecipe(Ic2Items.iridiumOre, IHLUtils.getThisModItemStack("dustIridium")); + IHLUtils.addIC2MaceratorRecipe("oreDatolite", IHLUtils.getThisModItemStackWithSize("dustDatolite",4)); + IHLUtils.addIC2MaceratorRecipe("oreBischofite", IHLUtils.getThisModItemStackWithSize("dustBischofite",4)); + IHLUtils.addIC2MaceratorRecipe("ingotBrick", IHLUtils.getOreDictItemStackWithSize("dustBrick",1)); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStackWithSize("dustIrongraphite",2), new Object[] {new RecipeInputOreDict("dustIron"), new RecipeInputOreDict("dustGraphite")}); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getOreDictItemStackWithSize("dustPorcelain",4), new Object[] {new RecipeInputOreDict("dustClay"),new RecipeInputOreDict("dustClay"), new RecipeInputOreDict("dustSiliconDioxide"), new RecipeInputOreDict("dustPotassiumFeldspar")}); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStack("chisel"), new Object[] {IHLUtils.getThisModItemStack("grindstone"),IHLUtils.getThisModItemStack("blankChiselSteel")}); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze"), new Object[] {IHLUtils.getThisModItemStack("grindstone"),IHLUtils.getThisModItemStack("carvingKnifeBronze")}); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("hammer"), new Object[] { "H ", "SC ", " ", Character.valueOf('H'),IHLUtils.getThisModItemStack("toolHeadHammerSmallSteel"), Character.valueOf('S'),new ItemStack(Items.stick), Character.valueOf('C'), new RecipeInputOreDict("craftingToolKnife")}); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("grindstone",2), new Object[] { " H ", " Q ", " ", Character.valueOf('H'), new RecipeInputOreDict("craftingToolForgeHammer"), Character.valueOf('Q'), new RecipeInputOreDict("blockQuartz")}); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("grindstone",2), new Object[] { " H ", " Q ", " ", Character.valueOf('H'), new RecipeInputOreDict("craftingToolHardHammer"), Character.valueOf('Q'), new RecipeInputOreDict("blockQuartz")}); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("blankNeedleFileSteel",64), new Object[] { " H ", " C ", " P ", Character.valueOf('H'), new RecipeInputOreDict("craftingToolForgeHammer"), Character.valueOf('C'), new RecipeInputOreDict("craftingToolChisel"), Character.valueOf('P'), IHLUtils.getThisModItemStack("plateHotSteel")}); + Recipes.metalformerExtruding.addRecipe(new RecipeInputOreDict("dustIrongraphite"), null, IHLUtils.getThisModItemStackWithSize("linerIronGraphite",4)); + Recipes.compressor.addRecipe(new RecipeInputOreDict("foilMica",4), null, IHLUtils.getThisModItemStack("plateMica")); + Recipes.metalformerExtruding.addRecipe(new RecipeInputOreDict("dustBoronCarbide"), null, IHLUtils.getThisModItemStackWithSize("stickBoronCarbide",2)); + Recipes.metalformerRolling.addRecipe(new RecipeInputItemStack(IHLUtils.getThisModItemStack("dustCoalElectrodePremix")), null, IHLUtils.getThisModItemStack("plateRawCoal")); + Recipes.metalformerExtruding.addRecipe(new RecipeInputItemStack(IHLUtils.getThisModItemStack("foilRubberWithSulfur")), null, IHLUtils.getThisModItemStack("batteryCellsEbonite")); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStack("dustAntimony"), new Object[]{IHLUtils.getThisModItemStack("dustTinyAntimony"),IHLUtils.getThisModItemStack("dustTinyAntimony"),IHLUtils.getThisModItemStack("dustTinyAntimony"),IHLUtils.getThisModItemStack("dustTinyAntimony"),IHLUtils.getThisModItemStack("dustTinyAntimony"),IHLUtils.getThisModItemStack("dustTinyAntimony"),IHLUtils.getThisModItemStack("dustTinyAntimony"),IHLUtils.getThisModItemStack("dustTinyAntimony"),IHLUtils.getThisModItemStack("dustTinyAntimony")}); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStackWithSize("dustTinyAntimony",9), new Object[]{IHLUtils.getThisModItemStack("dustAntimony")}); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStack("dustSilicon"), new Object[]{IHLUtils.getThisModItemStack("dustTinySilicon"),IHLUtils.getThisModItemStack("dustTinySilicon"),IHLUtils.getThisModItemStack("dustTinySilicon"),IHLUtils.getThisModItemStack("dustTinySilicon"),IHLUtils.getThisModItemStack("dustTinySilicon"),IHLUtils.getThisModItemStack("dustTinySilicon"),IHLUtils.getThisModItemStack("dustTinySilicon"),IHLUtils.getThisModItemStack("dustTinySilicon"),IHLUtils.getThisModItemStack("dustTinySilicon")}); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStackWithSize("dustTinySilicon",9), new Object[]{IHLUtils.getThisModItemStack("dustSilicon")}); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStack("dustSolderingAlloy"), new Object[]{IHLUtils.getOreDictItemStack("dustTin"),IHLUtils.getThisModItemStack("dustTinyAntimony")}); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("achesonFurnance"), new Object[] { "BPB", " ", "B B", Character.valueOf('B'), new RecipeInputOreDict("ingotBrick"), Character.valueOf('P'), new RecipeInputOreDict("plateSteel")}); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("muffleFurnance"), new Object[] { "BCB", "SDP", "BSB", Character.valueOf('B'), new RecipeInputOreDict("ingotBrick"), Character.valueOf('P'), new RecipeInputOreDict("plateSteel"), Character.valueOf('C'), IHLUtils.getThisModItemStack("crucibleMixture"), Character.valueOf('S'), new RecipeInputOreDict("stickGraphite"), Character.valueOf('D'), new RecipeInputOreDict("dustCarborundum")}); + + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",64), new Object[] { "VFS", "DR ", "WT ", + Character.valueOf('V'), new RecipeInputItemStack(IHLUtils.getThisModItemStack("viseSteel")), + Character.valueOf('F'), new RecipeInputOreDict("craftingToolFile"), + Character.valueOf('S'), new RecipeInputOreDict("stickSteel"), + Character.valueOf('D'), new RecipeInputItemStack(IHLUtils.getThisModItemStack("handDrillBronze")), + Character.valueOf('R'), new RecipeInputItemStack(IHLUtils.getThisModItemStack("drillSteelHardened")), + Character.valueOf('W'), new RecipeInputOreDict("craftingToolSaw"), + Character.valueOf('T'), new RecipeInputItemStack(IHLUtils.getThisModItemStack("tapM10x1SteelHardened"))}); + + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",8), new Object[] { "VFS", "DR ", "W ", + Character.valueOf('V'), new RecipeInputItemStack(IHLUtils.getThisModItemStack("viseSteel")), + Character.valueOf('F'), new RecipeInputOreDict("craftingToolFile"), + Character.valueOf('S'), new RecipeInputItemStack(IHLUtils.getThisModItemStack("barD10Steel")), + Character.valueOf('D'), new RecipeInputOreDict("craftingToolHardHammer"), + Character.valueOf('R'), new RecipeInputItemStack(IHLUtils.getThisModItemStack("diceM10x1SteelHardened")), + Character.valueOf('W'), new RecipeInputOreDict("craftingToolSaw")}); + ItemStack crystal = IC2Items.getItem("lapotronCrystal").copy(); + ItemStack advBattery = IC2Items.getItem("advBattery").copy(); + ItemStack chargedReBattery = IC2Items.getItem("chargedReBattery").copy(); + crystal.setItemDamage(OreDictionary.WILDCARD_VALUE); + 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"), Character.valueOf('C'), IC2Items.getItem("cell"), Character.valueOf('P'), IC2Items.getItem("powerunitsmall")}); + Recipes.advRecipes.addRecipe(((AdvancedHandPump) ic2_advanced_handpump).getItemStack(0), new Object[] { "TK ", "KCA", " RP", Character.valueOf('T'), IC2Items.getItem("treetap"), Character.valueOf('K'), IC2Items.getItem("advancedAlloy"), Character.valueOf('C'), IC2Items.getItem("cell"), Character.valueOf('A'), IC2Items.getItem("advancedCircuit"), Character.valueOf('R'), IC2Items.getItem("energyCrystal"), Character.valueOf('P'), IC2Items.getItem("powerunitsmall")}); + } + + ItemStack forestryWaxCapsule = IHLUtils.getOtherModItemStackWithDamage("Forestry", "waxCapsule", 0); + ItemStack forestryWaxCast = IHLUtils.getOtherModItemStackWithDamage("Forestry", "waxCast", 0); + ItemStack forestryCandle = IHLUtils.getOtherModItemStackWithDamage("Forestry", "candle", 0); + ItemStack forestryBeesWax = IHLUtils.getOtherModItemStackWithDamage("Forestry", "beeswax", 0); + if(forestryWaxCapsule!=null) + { + Recipes.advRecipes.addRecipe(forestryWaxCapsule, new Object[] { "SBS", " ", " ", Character.valueOf('S'), IHLUtils.getThisModItemStack("ingotStearin"),Character.valueOf('B'),forestryBeesWax}); + } + if(forestryCandle!=null) + { + Recipes.advRecipes.addRecipe(forestryCandle, new Object[] { " S ", " I ", " ", Character.valueOf('S'), new ItemStack(Items.string),Character.valueOf('I'),IHLUtils.getThisModItemStack("ingotStearin")}); + } + if(forestryWaxCast!=null) + { + Recipes.advRecipes.addRecipe(forestryWaxCast, new Object[] { "BSS", "S S", "SSB", Character.valueOf('S'), IHLUtils.getThisModItemStack("ingotStearin"),Character.valueOf('B'),forestryBeesWax}); + } + Iterator odi = OreDictionary.getOres("dustGypsum").iterator(); + while(odi.hasNext()) + { + ItemStack stack = odi.next().copy(); + stack.stackSize=2; + FurnaceRecipes.smelting().func_151394_a(stack, IHLUtils.getThisModItemStack("dustDehydratedGypsum"), 20F); + } + Recipes.FluidHeatGenerator.addFluid("oleicacid", 10, 16); + Recipes.FluidHeatGenerator.addFluid("mineraloil", 10, 16); + Recipes.FluidHeatGenerator.addFluid("acetylene", 10, 64); + Recipes.FluidHeatGenerator.addFluid("glyceryl", 10, 16); + Recipes.FluidHeatGenerator.addFluid("turpentine", 10, 16); + Recipes.FluidHeatGenerator.addFluid("fueloil", 10, 32); + Recipes.FluidHeatGenerator.addFluid("crackinggas", 10, 32); + Recipes.semiFluidGenerator.addFluid("hydrogen", 10, 32); + Recipes.semiFluidGenerator.addFluid("crackinggas", 10, 32); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStackWithSize("breadWithLard",4), new Object[] {new ItemStack(Items.bread), IHLUtils.getThisModItemStack("muttonLard")}); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), new Object[] {Ic2Items.coalDust, IHLUtils.getOreDictItemStack("nuggetTarPitch")}); + Recipes.metalformerExtruding.addRecipe(new RecipeInputItemStack(IHLUtils.getThisModItemStack("dustCoalElectrodePremix")), null, IHLUtils.getThisModItemStack("stickCoalElectrodePremix")); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getThisModItemStack("stickCoalElectrodePremix"), IHLUtils.getOreDictItemStack("stickCoal"), 20F); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getThisModItemStack("plateRawCoal"), IHLUtils.getOreDictItemStack("plateCoal"), 20F); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getOreDictItemStackWithSize("dustCalcite",3), IHLUtils.getOreDictItemStack("dustQuicklime"), 2F); + ItemSubstance.postInit(); + ItemStack lathingTool = Ic2Items.LathingTool.copy(); + lathingTool.setItemDamage(OreDictionary.WILDCARD_VALUE); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new IRecipeInput[] {new RecipeInputDie("setOfDies1_5sqmm",240)}),Arrays.asList(new ItemStack[] {Ic2Items.copperCableItem}),Arrays.asList(new ItemStack[] {IHLUtils.getUninsulatedWire("Copper",1,240)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new IRecipeInput[] {new RecipeInputDie("setOfDies1_5sqmm",240)}),Arrays.asList(new ItemStack[] {Ic2Items.ironCableItem}),Arrays.asList(new ItemStack[] {IHLUtils.getUninsulatedWire("Steel",1,240)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("bucket_tarPitch"),new ItemStack(Items.stick)}),Arrays.asList(new ItemStack[] {new ItemStack(Items.bucket),IHLUtils.getOreDictItemStackWithSize("nuggetTarPitch",4),new ItemStack(Blocks.torch)}))); + List materialList3 = new ArrayList(); + materialList3.add(new RecipeInputItemStack(new ItemStack(Blocks.sand,1 , OreDictionary.WILDCARD_VALUE))); + materialList3.add(new RecipeInputOreDict("dustClay")); + materialList3.add(new RecipeInputFluidContainer(FluidRegistry.WATER,1)); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("ingot")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("tub")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("blankChisel")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("carvingKnife")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("toolHeadHammerSmall")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("barD10")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("stick")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("setOfPartsForLVElemotor")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("pipelineAccessories")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("highPressureVessel")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("gasJet")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("handDrillSetOfMoldedParts")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("detonationSprayingMachineSetOfMoldedParts")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,materialList3,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getSandInjectionMoldForResult("viseSetOfMoldedParts")}))); + //Sand molds recipe section end + List materialsForPrecisionMold = Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("ingotStearin"), IHLUtils.getOreDictItemStack("cellLiquidGlass"), IHLUtils.getOreDictItemStack("dustSiliconDioxide"), new ItemStack(Blocks.sand)}); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),materialsForPrecisionMold,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getGypsumInjectionMoldForResult("rollingMachineSetOfMoldedParts"), Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),materialsForPrecisionMold,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getGypsumInjectionMoldForResult("polishingPucks"), Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),materialsForPrecisionMold,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getGypsumInjectionMoldForResult("turboCompressorSetOfMoldedParts"), Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),materialsForPrecisionMold,Arrays.asList(new ItemStack[]{InjectionMoldBlock.instance.getGypsumInjectionMoldForResult("extruderSetOfMoldedParts"), Ic2Items.cell.copy()}))); + //Precision molds recipe section end + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("chisel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("barD10SteelHot")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("drillSteel",2)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("chisel"),IHLUtils.getThisModItemStack("needleFile")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("barD10SteelHot")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("sawBladeSteel",2)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze"),IHLUtils.getThisModItemStack("needleFile")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("barD10Steel"),IHLUtils.getThisModItemStack("sawBladeSteelHardened"),new ItemStack(Items.stick)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("hackSawSteel")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("needleFile"),IHLUtils.getThisModItemStack("hackSawSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("plateSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("blankSetOfFilesSteel",4)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("viseSetOfMoldedPartsSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("viseSteel")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("tapM10x1SteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("stickSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("diceM10x1Steel",16)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("needleFile"),IHLUtils.getThisModItemStack("hackSawSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("barD10Steel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("tapM10x1Steel",2)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"),IHLUtils.getThisModItemStack("tapM10x1SteelHardened"),IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",16),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",12),IHLUtils.getThisModItemStackWithSize("barD10Steel",16),IHLUtils.getOreDictItemStackWithSize("plateSteel",4),IHLUtils.getOreDictItemStack("stickSteel"), new ItemStack(Items.leather), new ItemStack(Items.string)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("lathePart1"),IHLUtils.getThisModItemStack("lathePart2")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("tapM10x1SteelHardened"),IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",16),IHLUtils.getOreDictItemStack("plateSteel"),IHLUtils.getThisModItemStack("extruderSetOfMoldedPartsSteel"),IHLUtils.getThisModItemStack("meshGlass"),IHLUtils.getThisModItemStack("dustCarborundum"), new ItemStack(Items.leather), new ItemStack(Items.string)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("extruder"),IHLUtils.getThisModItemStack("vulcanizationExtrudingMold")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("chisel"),IHLUtils.getThisModItemStack("hammer")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("barD10SteelHot")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("nailSteel",8)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("hackSawSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("barD10Steel"),IHLUtils.getThisModItemStackWithSize("nailSteel",16),new ItemStack(Blocks.planks), new ItemStack(Items.leather), new ItemStack(Items.string),IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",8),IHLUtils.getOreDictItemStack("plateSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("coiler")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"),IHLUtils.getThisModItemStack("hackSawSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("barD10Steel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",8)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("handDrillSetOfMoldedPartsBronze"), new ItemStack(Items.stick)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("handDrillBronze")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("setOfFilesSteel"), lathingTool}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",16),IHLUtils.getThisModItemStack("dustCarborundum"),IHLUtils.getThisModItemStack("crucibleMixture"),IHLUtils.getOreDictItemStack("stickGraphite"),IHLUtils.getOreDictItemStack("plateSteel"),IHLUtils.getThisModItemStackWithSize("stickSteel",4), IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 16)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("wireMill")}), Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("lathePart1")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("setOfPartsForLVElemotorSteel"),IHLUtils.getThisModItemStack("ingotStearin"),IHLUtils.getUninsulatedWire("Copper", 4,15),new ItemStack(Items.paper),new ItemStack(Blocks.planks), IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 2)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("electricMotorLVLEDC")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("setOfPartsForLVElemotorSteel"),IHLUtils.getOreDictItemStack("cellSpruceResin"),IHLUtils.getUninsulatedWire("Copper", 4,15),new ItemStack(Items.paper),new ItemStack(Blocks.planks), IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 2)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("electricMotorLVLEDC"),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("linerIronGraphiteHot"), IHLUtils.getThisModItemStack("muttonLard")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("linerIronGraphiteGreased")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStackWithSize("dustBrick",7),IHLUtils.getOreDictItemStackWithSize("dustClay",3), IHLUtils.getOreDictItemStackWithSize("dustGraphite",2),Ic2Items.waterCell.copy()}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("crucibleMixture",12),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("crucibleMixture")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("crucible")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("tapM10x1SteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("stickSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",64)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), Ic2Items.bronzeAxe}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("barD10Steel",4),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",8), new ItemStack(Items.leather), new ItemStack(Items.stick,8), IHLUtils.getThisModItemStackWithSize("nailSteel", 8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("loom")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), new ItemStack(Items.iron_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("barD10Steel",4),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",8), new ItemStack(Items.leather), new ItemStack(Items.stick,8), IHLUtils.getThisModItemStackWithSize("nailSteel", 8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("loom")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), new ItemStack(Items.golden_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("barD10Steel",4),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",8), new ItemStack(Items.leather), new ItemStack(Items.stick,8), IHLUtils.getThisModItemStackWithSize("nailSteel", 8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("loom")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), new ItemStack(Items.diamond_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("barD10Steel",4),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",8), new ItemStack(Items.leather), new ItemStack(Items.stick,8), IHLUtils.getThisModItemStackWithSize("nailSteel", 8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("loom")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"), Ic2Items.bronzeAxe.copy()}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("detonationSprayingMachineSetOfMoldedPartsBronze"), new ItemStack(Blocks.planks), IHLUtils.getThisModItemStackWithSize("nailSteel", 8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("cannonBronze")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"), new ItemStack(Items.iron_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("detonationSprayingMachineSetOfMoldedPartsBronze"), new ItemStack(Blocks.planks), IHLUtils.getThisModItemStackWithSize("nailSteel", 8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("cannonBronze")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"), new ItemStack(Items.golden_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("detonationSprayingMachineSetOfMoldedPartsBronze"), new ItemStack(Blocks.planks), IHLUtils.getThisModItemStackWithSize("nailSteel", 8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("cannonBronze")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"), new ItemStack(Items.diamond_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("detonationSprayingMachineSetOfMoldedPartsBronze"), new ItemStack(Blocks.planks), IHLUtils.getThisModItemStackWithSize("nailSteel", 8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("cannonBronze")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"), lathingTool, IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"),IHLUtils.getThisModItemStack("tapM10x1SteelHardened")}),Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("ingotHotSteel"),IHLUtils.getThisModItemStack("foilRubber"),IHLUtils.getThisModItemStack("springSteel"),IHLUtils.getThisModItemStack("barD10Steel"),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",6),IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",6)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("gasReducerSteel")}), Arrays.asList(new ItemStack [] {IHLUtils.getThisModItemStack("lathePart1")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"), lathingTool}),Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("ingotHotSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("pistonCylinderSteel")}), Arrays.asList(new ItemStack [] {IHLUtils.getThisModItemStack("lathePart1")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[] {IHLUtils.getUninsulatedWire("Steel", 1, 240), new ItemStack(Items.stick)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("springSteel",4)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStackWithSize("barD10SteelHot",2),IHLUtils.getThisModItemStack("springSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("tinSnipsSteel")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"),IHLUtils.getThisModItemStack("tapM10x1SteelHardened")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("foilRubber"),IHLUtils.getThisModItemStackWithSize("gasReducerSteel",2),IHLUtils.getThisModItemStack("gasJetSteel"),IHLUtils.getThisModItemStackWithSize("barD10Steel",10),IHLUtils.getThisModItemStackWithSize("highPressureVesselSteel",2),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",32),IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",32),IHLUtils.getThisModWireItemStackWithLength("pipeVulcanizedRubber", 16)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened"), lathingTool}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("pistonCylinderSteel"),IHLUtils.getOreDictItemStackWithSize("plateSteel",2),IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"),IHLUtils.getThisModItemStack("foilRubber"),IHLUtils.getThisModItemStackWithSize("stickSteel",2), IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 4),IHLUtils.getThisModItemStackWithSize("highPressureVesselSteel",2)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("cryogenicDistiller")}), Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("lathePart1")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("tinSnipsSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStack("meshGlass"), + IHLUtils.getThisModItemStack("dustCarborundum"), + IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"), + IHLUtils.getThisModItemStack("foilRubber"), + IHLUtils.getThisModItemStack("highPressureVesselSteel"), + IHLUtils.getOreDictItemStack("stickSteel"), + IHLUtils.getOreDictItemStack("plateSteel"), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("chemicalReactor")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), Ic2Items.bronzeAxe}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("barD10SteelHot",7),IHLUtils.getOreDictItemStack("plateSteel"), new ItemStack(Items.leather), IHLUtils.getThisModItemStackWithSize("nailSteel", 8), new ItemStack(Blocks.log)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("woodenRollingMachinePart1"),IHLUtils.getThisModItemStack("woodenRollingMachinePart2")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), new ItemStack(Items.iron_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("barD10SteelHot",7),IHLUtils.getOreDictItemStack("plateSteel"), new ItemStack(Items.leather), IHLUtils.getThisModItemStackWithSize("nailSteel", 8), new ItemStack(Blocks.log)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("woodenRollingMachinePart1"),IHLUtils.getThisModItemStack("woodenRollingMachinePart2")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), new ItemStack(Items.golden_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("barD10SteelHot",7),IHLUtils.getOreDictItemStack("plateSteel"), new ItemStack(Items.leather), IHLUtils.getThisModItemStackWithSize("nailSteel", 8), new ItemStack(Blocks.log)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("woodenRollingMachinePart1"),IHLUtils.getThisModItemStack("woodenRollingMachinePart2")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), new ItemStack(Items.diamond_axe)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("barD10SteelHot",7),IHLUtils.getOreDictItemStack("plateSteel"), new ItemStack(Items.leather), IHLUtils.getThisModItemStackWithSize("nailSteel", 8), new ItemStack(Blocks.log)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("woodenRollingMachinePart1"),IHLUtils.getThisModItemStack("woodenRollingMachinePart2")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("plateSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("fiberGlassDieSteel")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("foilRubber"),IHLUtils.getOreDictItemStackWithSize("plateSteel",2),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",8),IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",8)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("cableAnchor")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("plateSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getItemStackWithTag("setOfDies1_5sqmm","transverseSection",240)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("plateSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("setOfDies1_5sqmm")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("tapM10x1SteelHardened"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",8), + IHLUtils.getOreDictItemStackWithSize("plateSteel",4), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4), + IHLUtils.getThisModItemStack("rollingMachineSetOfMoldedPartsSteel"), + IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 4)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("rollingMachinePart1")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("tapM10x1SteelHardened"),IHLUtils.getThisModItemStack("setOfFilesSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",8), + IHLUtils.getOreDictItemStackWithSize("plateSteel",4), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("rollingMachinePart2")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{Ic2Items.waterCell.copy(), IHLUtils.getOreDictItemStack("dustPorcelain")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("electrolysisBathRawPorcelain"),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{Ic2Items.waterCell.copy(), IHLUtils.getOreDictItemStack("dustPorcelain")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("ovenRawPorcelain"),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{Ic2Items.waterCell.copy(), IHLUtils.getOreDictItemStack("dustPorcelain")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("precipitatorCondenserRawPorcelain"),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{Ic2Items.waterCell.copy(), IHLUtils.getOreDictItemStack("dustPorcelain")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("chimneyKneeRawPorcelain"),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{Ic2Items.waterCell.copy(), IHLUtils.getOreDictItemStack("dustPorcelain")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("gaedesPumpBarrelRawPorcelain"),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{Ic2Items.waterCell.copy(), IHLUtils.getOreDictItemStack("dustPorcelain")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("ringRawPorcelain",4),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{Ic2Items.waterCell.copy(), IHLUtils.getOreDictItemStack("dustPorcelain")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("lampHolderRawPorcelain",4),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{Ic2Items.waterCell.copy(), IHLUtils.getOreDictItemStack("dustPorcelain")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("insulatorRawPorcelain",4),Ic2Items.cell.copy()}))); + //Raw porcelain recipes section end + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getOreDictItemStackWithSize("foilSteel",4), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4), + IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"), + IHLUtils.getThisModItemStack("foilRubber"), + IHLUtils.getOreDictItemStack("plateSteel"), + IHLUtils.getThisModItemStack("turboCompressorSetOfMoldedPartsBronze"), + IHLUtils.getThisModItemStack("highPressureVesselSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("fluidizedBedReactor")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("pistonCylinderSteel",2),IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"),IHLUtils.getThisModItemStack("foilRubber"),IHLUtils.getOreDictItemStack("plateSteel"),IHLUtils.getThisModItemStackWithSize("highPressureVesselSteel",2),IHLUtils.getThisModItemStack("electrolysisBathPorcelain"),IHLUtils.getThisModItemStackWithSize("stickGraphite",2)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("labElectrolyzer")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("glassBlowingTubeSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getOreDictItemStack("foilTungsten"),IHLUtils.getOreDictItemStack("dustQuicklime"),IHLUtils.getOreDictItemStack("dustGlass"),IHLUtils.getOreDictItemStack("stickGraphite"),IHLUtils.getThisModItemStack("barD10Steel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("gu-81m",4)}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation"),IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getThisModItemStack("barD10Steel"),new ItemStack(Items.stick)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("glassBlowingTubeSteel")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getOreDictItemStack("plateSteel"),IHLUtils.getThisModItemStackWithSize("barD10Steel",4),IHLUtils.getThisModItemStack("foilRubber"),IHLUtils.getThisModItemStack("gaedesPumpBarrelPorcelain"),IHLFluid.getCell("mercury")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump"),Ic2Items.cell.copy()}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("cellMineralOil"),IHLUtils.getOreDictItemStack("foilMica"),IHLUtils.getOreDictItemStack("foilCopper"),IHLUtils.getOreDictItemStack("foilSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("highVoltageCapacitor"),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("cellMineralOil"),IHLUtils.getOreDictItemStack("foilMica"),IHLUtils.getOreDictItemStack("foilGold"),IHLUtils.getOreDictItemStack("foilSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("highVoltageCapacitor"),Ic2Items.cell.copy()}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("ringPorcelain",64),IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",6),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",6),IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getThisModItemStackWithSize("barD10Steel",4)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("fractionatorSection")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("stickSteel",4),IHLUtils.getOreDictItemStackWithSize("plateSteel",2),IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",6),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",6),IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getThisModItemStackWithSize("barD10Steel",4)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("fractionatorBottom")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",6),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",6),IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getThisModItemStackWithSize("barD10Steel",4)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("fractionatorCover")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("handDrillBronze"),IHLUtils.getThisModItemStack("drillSteelHardened")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",6),IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",6),IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getThisModItemStackWithSize("barD10Steel",4)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("refluxCondenser")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("dustFerrite"),IHLUtils.getThisModItemStack("ingotStearin")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("ringRawFerrite",4)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("glassBlowingTubeSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("foilSteel"),IHLFluid.getCell("mercury"),IHLUtils.getOreDictItemStack("stickBoronCarbide"),IHLUtils.getOreDictItemStack("dustGlass"),IHLUtils.getOreDictItemStack("stickGraphite"),IHLUtils.getThisModItemStack("barD10Steel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("ignitron",6),Ic2Items.cell.copy()}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation"),IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("glassBlowingTubeSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getOreDictItemStack("foilTungsten"),IHLUtils.getOreDictItemStack("dustQuicklime"),IHLUtils.getOreDictItemStack("dustGlass"),IHLUtils.getOreDictItemStack("stickGraphite"),IHLUtils.getThisModItemStack("barD10Steel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("valveTube1C21P",6)}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation"),IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("glassBlowingTubeSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("foilGold"),IHLUtils.getOreDictItemStack("foilMica"),IHLFluid.getCell("cablingcolophony"),IHLUtils.getOreDictItemStack("dustGlass"),IHLUtils.getOreDictItemStack("foilSteel"),IHLUtils.getThisModItemStack("springSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("vacuumSwitch",16),Ic2Items.cell.copy()}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation"),IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStackWithSize("insulatorPorcelain",8), + IHLUtils.getThisModItemStackWithSize("plateMica",2), + IHLUtils.getThisModItemStackWithSize("highVoltageCapacitor",3), + IHLFluid.getCell("cablingcolophony"), + IHLUtils.getThisModItemStack("dustSolderingAlloy"), + IHLUtils.getThisModItemStack("foilMica"), + IHLUtils.getThisModItemStackWithSize("gu-81m",4), + IHLUtils.getThisModItemStackWithSize("foilSteel",8), + IHLUtils.getUninsulatedWire("Copper",288,15), + IHLFluid.getCell("mineraloil"), + IHLUtils.getThisModItemStackWithSize("ignitron",6), + IHLUtils.getThisModItemStackWithSize("valveTube1C21P",6)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("rectifierTransformerUnit"),Ic2Items.cell.copy()}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStack("foilCopper"), + IHLFluid.getCell("cablingcolophony"), + IHLUtils.getThisModItemStack("dustSolderingAlloy"), + IHLUtils.getThisModItemStackWithSize("ringFerrite",8), + IHLUtils.getThisModItemStack("foilMica")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("hallSensor",8),Ic2Items.cell.copy()}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStackWithSize("insulatorPorcelain",4), + IHLUtils.getUninsulatedWire("Copper",4,15), + IHLUtils.getThisModItemStack("foilMica"), + IHLUtils.getThisModItemStack("leadAcidBattery"), + IHLUtils.getThisModItemStack("dustSolderingAlloy"), + IHLUtils.getThisModItemStack("vacuumSwitch"), + IHLUtils.getThisModItemStackWithSize("hallSensor",2), + IHLUtils.getThisModItemStackWithSize("valveTube1C21P",2)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("batterySwitchUnit")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + ItemStack twoEmptyCells = Ic2Items.cell.copy(); + twoEmptyCells.stackSize=2; + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStack("foilGold"), + IHLUtils.getThisModItemStack("foilRubberWithSulfur"), + IHLUtils.getThisModItemStack("foilLead"), + IHLFluid.getCell("sulfuricacid"), + IHLFluid.getCell("ic2distilledwater"), + IHLUtils.getThisModItemStack("dustSolderingAlloy"), + IHLUtils.getThisModItemStack("dustLeadPlumbate"), + IHLUtils.getThisModItemStackWithSize("batteryCellsEbonite",8)}),Arrays.asList(new ItemStack[]{BatteryItem.getFullyChargedItemStackWithSize("leadAcidBattery",8),twoEmptyCells}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStack("foilSteel"), + IHLUtils.getThisModItemStackWithSize("plateGraphite",5), + IHLUtils.getThisModItemStackWithSize("barD10Steel",4), + IHLUtils.getThisModItemStack("stickGraphite"), + IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), + IHLUtils.getThisModItemStack("foilRubber")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("electrolysisBath")}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{ + IHLUtils.getOreDictItemStack("dustTin"), + new ItemStack(Blocks.glass_pane,16), + IHLFluid.getCell("mercury"), + IHLFluid.getCell("turpentine"), + IHLUtils.getThisModItemStack("fabric")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("mirror",16),twoEmptyCells}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{ + IHLUtils.getOreDictItemStack("dustTin"), + new ItemStack(Blocks.glass_pane,16), + IHLFluid.getCell("mercury"), + IHLFluid.getCell("turpentine"), + new ItemStack(Blocks.wool)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("mirror",16),twoEmptyCells}))); + if(IHLUtils.hasOreDictionaryEntry("cellEthanol")) + { + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{ + IHLUtils.getOreDictItemStack("dustTin"), + new ItemStack(Blocks.glass_pane,16), + IHLFluid.getCell("mercury"), + IHLUtils.getOreDictItemStack("cellEthanol"), + IHLUtils.getThisModItemStack("fabric")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("mirror",16),twoEmptyCells}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{ + IHLUtils.getOreDictItemStack("dustTin"), + new ItemStack(Blocks.glass_pane,16), + IHLFluid.getCell("mercury"), + IHLUtils.getOreDictItemStack("cellEthanol"), + new ItemStack(Blocks.wool)}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("mirror",16),twoEmptyCells}))); + } + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("glassBlowingTubeSteel"),IHLUtils.getThisModItemStack("hackSawSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStack("foilTungsten"), + IHLUtils.getThisModItemStack("foilCopper"), + IHLUtils.getThisModItemStackWithSize("lampHolderPorcelain",16), + IHLUtils.getOreDictItemStack("dustGlass") + }),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("lightBulb",16)}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("gasWeldingStation"),IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hammer"),IHLUtils.getThisModItemStack("tinSnipsSteel"),IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("viseSteel")}),Arrays.asList(new ItemStack[]{ + IHLUtils.getThisModItemStack("lightBulb"), + IHLUtils.getThisModItemStack("foilSteel"), + 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), + new RecipeInputOreDict("foilSteel",2), + RecipeInputs.get("boltM10x1Steel",8), + RecipeInputs.get("nutM10x1Steel",8), + RecipeInputs.get("barD10Steel",16), + RecipeInputs.get("rollingMachineSetOfMoldedPartsSteel"), + RecipeInputs.get("linerIronGraphiteGreased",4), + RecipeInputs.get("turboCompressorSetOfMoldedPartsBronze"), + 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(Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("hackSawSteel"),IHLUtils.getThisModItemStack("viseSteel"),IHLUtils.getThisModItemStack("setOfFilesSteel"),IHLUtils.getThisModItemStack("drillSteelHardened"),IHLUtils.getThisModItemStack("handDrillBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getOreDictItemStack("plateSteel")}),Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStackWithSize("incisorSteel",4)}))); + if(IHLMod.isGregTechModLoaded && IHLMod.isGT_API_Version_5) + { + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,15),IHLUtils.getOreDictItemStack("dustRawRubber")}),Arrays.asList(new ItemStack[] {IHLUtils.getInsulatedWire("Copper", 1,15,"RawRubber",100)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,240),IHLUtils.getOreDictItemStack("dustRawRubber")}),Arrays.asList(new ItemStack[] {IHLUtils.getInsulatedWire("Copper", 1,240,"RawRubber",100)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,15),IHLUtils.getOreDictItemStack("dustRawRubber")}),Arrays.asList(new ItemStack[] {IHLUtils.getInsulatedWire("Steel", 1,15,"RawRubber",100)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,240),IHLUtils.getOreDictItemStack("dustRawRubber")}),Arrays.asList(new ItemStack[] {IHLUtils.getInsulatedWire("Steel", 1,240,"RawRubber",100)}))); + + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Copper", 1,15,"RawRubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,15),IHLUtils.getOreDictItemStack("dustRawRubber")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Copper", 1,240,"RawRubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,240),IHLUtils.getOreDictItemStack("dustRawRubber")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Steel", 1,15,"RawRubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,15),IHLUtils.getOreDictItemStack("dustRawRubber")}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Steel", 1,240,"RawRubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,240),IHLUtils.getOreDictItemStack("dustRawRubber")}))); + } + else + { + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,15),Ic2Items.rubber}),Arrays.asList(new ItemStack[] {IHLUtils.getInsulatedWire("Copper", 1,15,"RawRubber",100)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,240),Ic2Items.rubber}),Arrays.asList(new ItemStack[] {IHLUtils.getInsulatedWire("Copper", 1,240,"RawRubber",100)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,15),Ic2Items.rubber}),Arrays.asList(new ItemStack[] {IHLUtils.getInsulatedWire("Steel", 1,15,"RawRubber",100)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null,Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,240),Ic2Items.rubber}),Arrays.asList(new ItemStack[] {IHLUtils.getInsulatedWire("Steel", 1,240,"RawRubber",100)}))); + + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Copper", 1,15,"RawRubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,15),Ic2Items.rubber}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Copper", 1,240,"RawRubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,240),Ic2Items.rubber}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Steel", 1,15,"RawRubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,15),Ic2Items.rubber}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Steel", 1,240,"RawRubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,240),Ic2Items.rubber}))); + } + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Copper", 1,15,"Rubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,15)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Copper", 1,240,"Rubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Copper", 1,240)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[]{IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze")}),Arrays.asList(new ItemStack[]{IHLUtils.getInsulatedWire("Steel", 1,15,"Rubber",100)}),Arrays.asList(new ItemStack[]{IHLUtils.getUninsulatedWire("Steel", 1,15)}))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(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)}))); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustSiliconDioxide",2), new RecipeInputOreDict("dustCoal",4), "dustCarborundum"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustQuicklime"), new RecipeInputOreDict("dustCoal",4), "dustCalciumCarbide"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("stickCoal"), new RecipeInputOreDict("dustCoal"), "stickGraphite"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustTungsten"), new RecipeInputOreDict("dustCoal"), "ingotTungsten"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustBoricAcid",4), new RecipeInputOreDict("dustCoal",8), "dustBoronCarbide"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("plateCoal"), new RecipeInputOreDict("dustCoal",1), "plateGraphite"); + GoldChimneyKneeTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("ic2steam", 1),IHLUtils.getFluidStackWithSize("sulfuricanhydride", 1)}),null), IHLUtils.getFluidStackWithSize("vapour.sulfuricacid", 1)); + if(FluidRegistry.isFluidRegistered("steam"))GoldChimneyKneeTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("steam", 1),IHLUtils.getFluidStackWithSize("sulfuricanhydride", 1)}),null), IHLUtils.getFluidStackWithSize("vapour.sulfuricacid", 1)); + GoldChimneyKneeTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("ic2superheatedsteam", 15),IHLUtils.getFluidStackWithSize("sulfuricanhydride", 4)}),null), IHLUtils.getFluidStackWithSize("vapour.sulfuricacid", 4)); + LeadOvenTileEntity.addRecipe(new UniversalRecipeInput(null,Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustSulfur"), IHLUtils.getOreDictItemStack("dustSaltpeter")})), IHLUtils.getFluidStackWithSize("sulfuricanhydride", 23000)); + LeadOvenTileEntity.addRecipe(new UniversalRecipeInput(null,Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("crushedPurifiedCinnabar")})), IHLUtils.getFluidStackWithSize("vapour.mercury", 3600)); + LeadOvenTileEntity.addRecipe(IHLUtils.getThisModItemStack("dustStibnite"), IHLUtils.getThisModItemStack("dustAntimonyOxide")); + LeadOvenTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("dustSodiumHydrogenSulfate",2), IHLUtils.getFluidStackWithSize("vapour.sulfuricacid", 20000), IHLUtils.getOreDictItemStack("dustSodiumSulfate")); + LeadOvenTileEntity.addRecipe(IHLUtils.getThisModItemStackWithSize("dustSodiumZeoliteCoked",2), IHLUtils.getThisModItemStack("dustSodiumZeolite")); + ImpregnatingMachineTileEntity.addChemicalRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {new FluidStack(FluidRegistry.WATER, 1500)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStackWithSize("dustQuicklime", 1)})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("limemilk", 2500)}),null,20)); + ImpregnatingMachineTileEntity.addChemicalRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {new FluidStack(FluidRegistry.WATER, 130),IHLUtils.getFluidStackWithSize("limemilk", 142)}), Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStackWithSize("muttonLard", 6)})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("glyceryl", 130)}),Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStackWithSize("ingotCalciumSoap", 5)}),200)); + ImpregnatingMachineTileEntity.addChemicalRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {new FluidStack(FluidRegistry.WATER, 600),IHLUtils.getFluidStackWithSize("sulfuricacid", 284)}), Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStackWithSize("ingotCalciumSoap", 6)})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("oleicacid", 280)}),Arrays.asList(new RecipeOutputItemStack[] {new RecipeOutputItemStack(IHLUtils.getThisModItemStackWithSize("ingotStearin", 4)),new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustGypsum"),0.48f)}),200)); + ImpregnatingMachineTileEntity.addChemicalRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("limemilk", 1000)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustTrona")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 1000)}),Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustCalcite")}),200)); + DetonationSprayingMachineTileEntity.addRecipe(IHLUtils.getThisModItemStack("blankNeedleFileSteel"), IHLUtils.getThisModItemStack("needleFile")); + DetonationSprayingMachineTileEntity.addRecipe(IHLUtils.getThisModItemStack("blankSetOfFilesSteel"), IHLUtils.getThisModItemStack("setOfFilesSteel")); + DetonationSprayingMachineTileEntity.addRecipe(IHLUtils.getThisModItemStack("incisorSteel"), IHLUtils.getThisModItemStack("incisorSteelDiamondCoated")); + ItemStack drill = Ic2Items.miningDrill.copy(); + drill.setItemDamage(OreDictionary.WILDCARD_VALUE); + DetonationSprayingMachineTileEntity.addRecipe(drill, Ic2Items.diamondDrill.copy()); + MuffleFurnanceTileEntity.addRecipe(Ic2Items.plateadviron.copy(), IHLUtils.getThisModItemStack("plateHotSteel")); + MuffleFurnanceTileEntity.addRecipe(Ic2Items.advIronIngot.copy(), IHLUtils.getOreDictItemStack("ingotHotSteel")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getOreDictItemStack("plateTungsten"),IHLUtils.getThisModItemStack("plateHotTungsten")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("gaedesPumpBarrelRawPorcelain"),IHLUtils.getThisModItemStack("gaedesPumpBarrelPorcelain")); + MuffleFurnanceTileEntity.addRecipe(new ItemStack(IHLMod.crucible,0, OreDictionary.WILDCARD_VALUE), new ItemStack(IHLMod.crucible,0,1)); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStackWithSize("injectionMold",0), IHLUtils.getThisModItemStackWithSize("injectionMold",0)); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("sawBladeSteel"),IHLUtils.getThisModItemStack("sawBladeSteelHot")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("barD10Steel"),IHLUtils.getThisModItemStack("barD10SteelHot")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("linerIronGraphite"),IHLUtils.getThisModItemStack("linerIronGraphiteHot")); + MuffleFurnanceTileEntity.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustIronOxide"), IHLUtils.getOreDictItemStack("dustLithiumOxide")})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStackWithSize("dustFerrite",2)}),200)); + MuffleFurnanceTileEntity.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStackWithSize("dustSiliconDioxide",3), IHLUtils.getOreDictItemStackWithSize("dustMagnesium",2)})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustSilicon"), IHLUtils.getOreDictItemStackWithSize("dustMagnesiumOxide",4)}),200)); + MuffleFurnanceTileEntity.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustBauxite"), IHLUtils.getOreDictItemStack("dustSodiumHydroxide")})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustSodiumAluminate")}),200)); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("drillSteel"),IHLUtils.getThisModItemStack("drillSteelHot")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("tapM10x1Steel"),IHLUtils.getThisModItemStack("tapM10x1SteelHot")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("diceM10x1Steel"),IHLUtils.getThisModItemStack("diceM10x1SteelHot")); + LoomTileEntity.addRecipe(IHLUtils.getThisModWireItemStackWithLength("fiberGlass", 1024), IHLUtils.getThisModItemStack("meshGlass")); + LoomTileEntity.addRecipe(new ItemStack(Items.string,4), IHLUtils.getThisModItemStack("fabric")); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getThisModItemStack("plateHotSteel"), IHLUtils.getOreDictItemStackWithSize("foilSteel",4)); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getThisModItemStack("plateHotTungsten"), IHLUtils.getOreDictItemStackWithSize("foilTungsten",4)); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getOreDictItemStack("plateGold"), IHLUtils.getOreDictItemStackWithSize("foilGold",4)); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getOreDictItemStack("plateCopper"), IHLUtils.getOreDictItemStackWithSize("foilCopper",4)); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getOreDictItemStack("plateLead"), IHLUtils.getOreDictItemStackWithSize("foilLead",4)); + ImpregnatingMachineTileEntity.addQuenchingRecipe("diceM10x1SteelHot","diceM10x1SteelHardened"); + ImpregnatingMachineTileEntity.addQuenchingRecipe("tapM10x1SteelHot","tapM10x1SteelHardened"); + ImpregnatingMachineTileEntity.addQuenchingRecipe("drillSteelHot","drillSteelHardened"); + ImpregnatingMachineTileEntity.addQuenchingRecipe("sawBladeSteelHot","sawBladeSteelHardened"); + ImpregnatingMachineTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("oleicacid", 1)}), Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("linerIronGraphiteHot")})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("linerIronGraphiteGreased")}),2)); + ImpregnatingMachineTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("seedoil", 1)}), Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("linerIronGraphiteHot")})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("linerIronGraphiteGreased")}),2)); + ImpregnatingMachineTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("mineraloil", 1)}), Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("linerIronGraphiteHot")})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("linerIronGraphiteGreased")}),2)); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("foilRubberWithSulfur"),IHLUtils.getThisModItemStack("foilRubber")); + MuffleFurnanceTileEntity.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new IRecipeInput[] {new RecipeInputItemStack(IHLUtils.getThisModItemStack("pipeRubberWithSulfur"))})),new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack("pipeVulcanizedRubber")}), 20)); + GasWeldingStationTileEntity.addGasRecipe(IHLUtils.getOreDictItemStack("dustCalciumCarbide"),IHLUtils.getFluidStackWithSize("water", 666), IHLUtils.getFluidStackWithSize("acetylene", 1333), IHLUtils.getFluidStackWithSize("limemilk", 333)); + CryogenicDistillerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("air", 1000), IHLUtils.getFluidStackWithSize("nitrogen", 781), IHLUtils.getFluidStackWithSize("oxygen", 209), false); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 500)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustSiliconDioxide")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("liquidglass", 500)}),null,200)); + PrecipitatorCondenserTileEntity.addRecipe("vapour.sulfuricacid", "sulfuricacid", 50); + PrecipitatorCondenserTileEntity.addRecipe("vapour.mercury", "mercury", 50); + PrecipitatorCondenserTileEntity.addRecipe("ic2steam", "ic2distilledwater", 100); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("glyceryl", 50),IHLUtils.getFluidStackWithSize("spruceresin", 1000)}),null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("cablingcolophony", 600)}),null,200,true)); + CryogenicDistillerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("spruceresin", 1000), IHLUtils.getFluidStackWithSize("ic2distilledwater", 150), IHLUtils.getFluidStackWithSize("turpentine", 300), true); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("fueloil", 2000)}),null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("molten.tarpitch", 144)}),null,200,true)); + CryogenicDistillerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("fueloil", 2000), IHLUtils.getFluidStackWithSize("mineraloil", 1000), null, true); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 4000)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("crushedPurifiedGyubnera")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("solution.natriumtungstate", 4000)}),Arrays.asList(new RecipeOutputItemStack[] {new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyManganeseOxide"),3.75f),new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyIronOxide"),9f/12f)}),200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("sulfuricacid", 1750)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStackWithSize("dustRockSalt",1)})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("hydrogenchloride", 1000)}),Arrays.asList(new RecipeOutputItemStack[] {new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustPotassiumSulphate"),1.75f)}),200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("sulfuricacid", 3500)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustSalt")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("hydrogenchloride", 1000)}),Arrays.asList(new RecipeOutputItemStack[] {new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustSodiumHydrogenSulfate"),3.5f)}),200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("sulfuricacid", 7000/9),new FluidStack(FluidRegistry.WATER,6000/9+1000)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustDatolite")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("boricacid", 1777)}),Arrays.asList(new RecipeOutputItemStack[] {new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustGypsum"),12f/9f),new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinySiliconDioxide"),3f)}),200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("limemilk", 1667),IHLUtils.getFluidStackWithSize("hydrogenchloride", 1334)}), null), new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustCalciumChloride")}),200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("solution.natriumtungstate", 6667)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustCalciumChloride")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("saltwater", 6000)}),Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustCalciumTungstate")}),200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 2000)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustWood"),IHLUtils.getOreDictItemStack("dustSodiumSulfide")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("pulp.cellulose", 1500),IHLUtils.getFluidStackWithSize("ic2biomass", 500)}),null,200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("cablingcolophony", 50),new FluidStack(FluidRegistry.WATER,2000)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustMica")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("pulp.mica", 2000)}),null,200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("hydrogenchloride", 500),new FluidStack(FluidRegistry.WATER,7500)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustMagnesiumOxide")})), new UniversalRecipeOutput(null,Arrays.asList(new RecipeOutputItemStack[] {new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustBischofite"),8.75f)}),200)); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("liquidglass", 1000),new FluidStack(FluidRegistry.WATER,2000)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustSodiumAluminate")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("pulp.sodiumzeolite", 4000)}),null,200)); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("saltwater", 4000), IHLUtils.getOreDictItemStack("dustSalt")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("boricacid", 2288), IHLUtils.getOreDictItemStack("dustBoricAcid")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 2000), IHLUtils.getOreDictItemStack("dustSodiumHydroxide")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("pulp.sodiumzeolite", 4000), IHLUtils.getOreDictItemStack("dustSodiumZeolite")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("solution.lithiumchloride", 4000), IHLUtils.getOreDictItemStack("dustLithiumChloride")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("solution.calciumchloride", 4000), IHLUtils.getOreDictItemStack("dustCalciumChloride")); + ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("water", 2000),IHLUtils.getFluidStackWithSize("hydrogenchloride", 667)}), Arrays.asList(new IRecipeInput[] {new RecipeInputOreDict("dustCalciumTungstate")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack [] {IHLUtils.getFluidStackWithSize("solution.calciumchloride", 2000)}),Arrays.asList(new RecipeOutputItemStack[] {new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTungsticAcid"),1.16f)}),200)); + if(IHLUtils.hasOreDictionaryEntry("dustTungstate"))ChemicalReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("water", 1000),IHLUtils.getFluidStackWithSize("hydrogenchloride",140)}), Arrays.asList(new IRecipeInput[] {new RecipeInputOreDict("dustTungstate")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack [] {IHLUtils.getFluidStackWithSize("solution.lithiumchloride", 560)}),Arrays.asList(new RecipeOutputItemStack[] {new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTungsticAcid"),1.0f)}),200)); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("dustTungsticAcid",2), IHLUtils.getOreDictItemStack("dustTungstenOxide"),1.14f); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("electrolysisBathRawPorcelain"), IHLUtils.getThisModItemStack("electrolysisBathPorcelain")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("ovenRawPorcelain"), IHLUtils.getThisModItemStack("leadOven")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("precipitatorCondenserRawPorcelain"), IHLUtils.getThisModItemStack("goldPrecipitatorCondenser")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("chimneyKneeRawPorcelain"), IHLUtils.getThisModItemStack("goldChimneyKnee")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("ringRawPorcelain"), IHLUtils.getThisModItemStack("ringPorcelain")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("ringRawFerrite"), IHLUtils.getThisModItemStack("ringFerrite")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("insulatorRawPorcelain"), IHLUtils.getThisModItemStack("insulatorPorcelain")); + MuffleFurnanceTileEntity.addRecipe(IHLUtils.getThisModItemStack("lampHolderRawPorcelain"), IHLUtils.getThisModItemStack("lampHolderPorcelain")); + LabElectrolyzerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("water", 300), IHLUtils.getFluidStackWithSize("hydrogen", 200), IHLUtils.getFluidStackWithSize("oxygen", 100), null); + LabElectrolyzerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("saltwater", 1000), IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 875), IHLUtils.getFluidStackWithSize("chlorine", 100), null); + if(IHLUtils.hasOreDictionaryEntry("dustSilicon"))FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 1333), IHLUtils.getOreDictItemStackWithSize("dustSiliconDioxide",1), IHLUtils.getFluidStackWithSize("ic2distilledwater", 2000), IHLUtils.getOreDictItemStackWithSize("dustTinySilicon",3)); + if(IHLUtils.hasOreDictionaryEntry("dustManganese"))FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 2000), IHLUtils.getOreDictItemStackWithSize("dustManganeseOxide",2), IHLUtils.getFluidStackWithSize("ic2distilledwater", 3000), IHLUtils.getOreDictItemStack("dustManganese")); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 1200), IHLUtils.getOreDictItemStack("dustIronOxide"), IHLUtils.getFluidStackWithSize("ic2distilledwater", 1800), new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyIron"),3.6f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 1500), IHLUtils.getOreDictItemStack("dustTungstenOxide"), IHLUtils.getFluidStackWithSize("ic2distilledwater", 2250), new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyTungsten"),2.25f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 4000), IHLUtils.getOreDictItemStackWithSize("dustSodiumSulfate",3), IHLUtils.getFluidStackWithSize("ic2distilledwater", 6000), IHLUtils.getOreDictItemStack("dustSodiumSulfide")); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 1200), IHLUtils.getOreDictItemStack("dustAntimonyOxide"), IHLUtils.getFluidStackWithSize("ic2distilledwater", 1800), new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyAntimony"),3.6f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("oxygen", 1500), IHLUtils.getOreDictItemStack("dustIron"), null, new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustIronOxide"),2.5f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("oxygen", 500), IHLUtils.getOreDictItemStack("dustLithium"), null, new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustLithiumOxide"),1.5f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("oxygen", 1333), IHLUtils.getOreDictItemStack("dustLead"), null, new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustLeadPlumbate"),2.333f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("chlorine", 2000), IHLUtils.getOreDictItemStack("dustCarborundum"), IHLUtils.getFluidStackWithSize("silicontetrachloride", 2500), new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustCoal"),0.5f)); + FluidizedBedReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack [] {IHLUtils.getFluidStackWithSize("hydrogen", 445),IHLUtils.getFluidStackWithSize("silicontetrachloride", 1667)}),Arrays.asList(new ItemStack [] {IHLUtils.getOreDictItemStackWithSize("dustIridium", 0),IHLUtils.getOreDictItemStack("dustTinySilicon")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack [] {IHLUtils.getFluidStackWithSize("trichlorosilane", 2112)}),null,200)); + FluidizedBedReactorTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack [] {IHLUtils.getFluidStackWithSize("fueloil", 6000)}), Arrays.asList(new ItemStack [] {IHLUtils.getOreDictItemStack("dustSodiumZeolite")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack [] {IHLUtils.getFluidStackWithSize("fuel", 4500),IHLUtils.getFluidStackWithSize("crackinggas", 500)}),Arrays.asList(new RecipeOutputItemStack [] { new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustSodiumZeoliteCoked"),1.9f)}), 2000)); + Crucible.addRecipe("ingotSteel", IHLUtils.getFluidStackWithSize("molten.steel", 144)); + Crucible.addRecipe("ingotBronze", IHLUtils.getFluidStackWithSize("molten.bronze", 144)); + Crucible.addRecipe("ingotGold", IHLUtils.getFluidStackWithSize("molten.gold", 144)); + Crucible.addRecipe("ingotMagnesium", IHLUtils.getFluidStackWithSize("molten.magnesium", 144)); + Crucible.addRecipe("dustGold", IHLUtils.getFluidStackWithSize("molten.gold", 144)); + Crucible.addRecipe("dustSalt", IHLUtils.getFluidStackWithSize("molten.sodiumchloride", 144)); + Crucible.addRecipe("dustGlass", IHLUtils.getFluidStackWithSize("molten.glass", 144)); + PaperMachineTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("pulp.cellulose", 1500), new ItemStack(Items.paper)); + PaperMachineTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("pulp.mica", 500), IHLUtils.getThisModItemStack("foilMica")); + FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("oil", 100), IHLUtils.getFluidStackWithSize("fueloil", 60), IHLUtils.getFluidStackWithSize("fuel", 40)); + if(FluidRegistry.isFluidRegistered("liquid_light_oil"))FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("liquid_light_oil", 100), IHLUtils.getFluidStackWithSize("fueloil", 40), IHLUtils.getFluidStackWithSize("fuel", 60)); + if(FluidRegistry.isFluidRegistered("liquid_medium_oil"))FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("liquid_medium_oil", 100), IHLUtils.getFluidStackWithSize("fueloil", 60), IHLUtils.getFluidStackWithSize("fuel", 40)); + if(FluidRegistry.isFluidRegistered("liquid_heavy_oil"))FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("liquid_heavy_oil", 100), IHLUtils.getFluidStackWithSize("fueloil", 70), IHLUtils.getFluidStackWithSize("fuel", 30)); + if(FluidRegistry.isFluidRegistered("liquid_extra_heavy_oil"))FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("liquid_extra_heavy_oil", 100), IHLUtils.getFluidStackWithSize("fueloil", 80), IHLUtils.getFluidStackWithSize("fuel", 20)); + ElectrolysisBathTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("molten.sodiumchloride", 1000)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustBischofite")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("molten.magnesium", 6)}),null,200)); + ElectrolysisBathTileEntity.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("molten.sodiumchloride", 1000)}), Arrays.asList(new ItemStack[] {IHLUtils.getOreDictItemStack("dustLithiumChloride")})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize("molten.lithium", 72)}),null,200)); + // 1 mb of molten metal per 1 m of cable with transverse section equals to 1.5 sq. mm. + fluidDictionary.registerFluidStack("water", IHLUtils.getFluidStackWithSize("water", 1000)); + fluidDictionary.registerFluidStack("water", IHLUtils.getFluidStackWithSize("ic2distilledwater", 1000)); + fluidDictionary.registerFluidStack("lubricant", IHLUtils.getFluidStackWithSize("seedoil", 1000)); + fluidDictionary.registerFluidStack("lubricant", IHLUtils.getFluidStackWithSize("oleicacid", 1000)); + fluidDictionary.registerFluidStack("lubricant", IHLUtils.getFluidStackWithSize("mineraloil", 1000)); + if(FluidRegistry.isFluidRegistered("lubricant"))fluidDictionary.registerFluidStack("lubricant", IHLUtils.getFluidStackWithSize("lubricant", 1000)); + WireMillTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("molten.glass", 1), new RecipeInputItemStack(IHLUtils.getThisModItemStack("fiberGlassDieSteel"), 0), IHLUtils.getThisModWireItemStackWithLength("fiberGlass", 64)); + WireMillTileEntity.addRecipe("dustGlass",IHLUtils.getFluidStackWithSize("molten.glass", 144)); + for(ElectricConductor ec:ElectricConductor.values()) + { + String fluidName = "molten."+ec.toString().toLowerCase(); + if(FluidRegistry.isFluidRegistered(fluidName)) + { + WireMillTileEntity.addRecipe(IHLUtils.getFluidStackWithSize(fluidName, 1), new RecipeInputDie("setOfDies1_5sqmm",15), IHLUtils.getUninsulatedWire(ec.toString(), 1, 15)); + log.debug("added recipe for "+fluidName); + if(ec.meltingPoint<500) + { + WireMillTileEntity.addRecipe("ingot"+ec.toString(),IHLUtils.getFluidStackWithSize(fluidName, 144)); + } + } + } + VulcanizationExtrudingMoldTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("molten.rubber", 32), IHLUtils.getThisModWireItemStackWithLength("copperWire", 1), IHLUtils.getInsulatedWire("Copper", 1, 15, "Rubber", 100)); + IHLMod.config.loadRecipeModificators(); + } + 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.registerGlobalEntityID(LostHeadEntity.class, "LostHead", EntityRegistry.findGlobalUniqueEntityId(), 0x0033FF, 0x00CCFF); + if(IHLMod.config.enableWailers) + { + BiomeGenBase[] biomes = BiomeDictionary.getBiomesForType(Type.END); + for(int i=0;i dsmInputs1 = new ArrayList(); + ItemStack gregtechfile = GT_ModHandler.getModItem("gregtech", "gt.metatool.01", 1, 18); + dsmInputs1.add(new RecipeInputItemStack(gregtechfile)); + dsmInputs1.add(new RecipeInputOreDict("dustDiamond")); + dsmInputs1.add(new RecipeInputOreDict("dustGunpowder")); + DetonationSprayingMachineTileEntity.addRecipe((new UniversalRecipeInput(null,dsmInputs1)), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {gregtechfile.copy()}),2)); + + if(IHLMod.config.enableRubberTreeSack) + { + long[] chances={10000,2000,2000,1000,100,0}; + long[] chances2={10000,10000,10000,5000,500,10000}; + Recipe.RecipeMap.sCoagulatorRecipes.addRecipe( + true, + new ItemStack[] {}, + new ItemStack[] {OreDictManager.INSTANCE.getStack(OP.nugget,MT.Rubber, 1)}, + null, + chances, + new FluidStack [] {new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"),22)}, + new FluidStack [] {}, + 16, 5, 0); + } + + if(IHLMod.config.enableHandpump) + { + GT_ModHandler.addCraftingRecipe(((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), 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), 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), 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"), 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"), new Object[] { " ", "fPs", " ", Character.valueOf('P'), OP.plate.get(MT.Steel)}); + GT_ModHandler.addCraftingRecipe(IHLUtils.getItemStackWithTag("setOfDies1_5sqmm","transverseSection",240), new Object[] { " f ", " P ", " s ", Character.valueOf('P'), OP.plate.get(MT.Steel)}); + } + if(pfaalimestone!=null) + { + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {pfaalimestone}, + new ItemStack[] {IHLUtils.getOreDictItemStackWithSize("dustCalcite",4)}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + } + if(pfaacobblelimestone!=null) + { + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {pfaacobblelimestone}, + new ItemStack[] {IHLUtils.getOreDictItemStackWithSize("dustCalcite",4)}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + } + List gypsumOreList = IHLUtils.getEntryListForOre("oreGypsum"); + Iterator oreListIterator = gypsumOreList.iterator(); + while(oreListIterator.hasNext()) + { + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {oreListIterator.next().copy()}, + new ItemStack[] {IHLUtils.getOreDictItemStack("dustGypsum")}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + } + + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getThisModItemStack("orePotassiumFeldspar")}, + new ItemStack[] {IHLUtils.getOreDictItemStack("dustPotassiumFeldspar")}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getThisModItemStack("oreLimestone")}, + new ItemStack[] {IHLUtils.getOreDictItemStack("dustCalcite")}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getThisModItemStack("oreSaltpeter")}, + new ItemStack[] {IHLUtils.getOreDictItemStack("dustSaltpeter")}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {new ItemStack(Items.brick)}, + new ItemStack[] {IHLUtils.getOreDictItemStack("dustBrick")}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getOreDictItemStack("stickGraphite")}, + new ItemStack[] {IHLUtils.getOreDictItemStack("dustSmallGraphite")}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + Recipe.RecipeMap.sChemicalRecipes.addRecipe( + true, + new ItemStack[] {OreDictManager.INSTANCE.getStack(OP.dust,MT.Sodium, 1), + OreDictManager.INSTANCE.getStack(OP.cell,MT.Empty, 1)}, + new ItemStack[] {OreDictManager.INSTANCE.getStack(OP.cell,MT.Hydrogen, 1)}, + null, + new long[]{10000}, + new FluidStack[]{new FluidStack(FluidRegistry.WATER, 1500)}, + new FluidStack[]{FluidRegistry.getFluidStack("solution.natriumhydroxide", 1000)}, + 950,30,0); + Recipe.RecipeMap.sChemicalRecipes.addRecipe( + true, + new ItemStack[] {OreDictManager.INSTANCE.getStack(OP.dust,MT.SiliconDioxide, 1),OreDictManager.INSTANCE.getStack(OP.cell,MT.Empty, 2)}, + new ItemStack[] {OreDictManager.INSTANCE.getStack("cellLiquidGlass", 2)}, + null, + new long[]{10000}, + new FluidStack[]{FluidRegistry.getFluidStack("solution.natriumhydroxide", 1000)}, + new FluidStack[]{}, + 950,30,0); + Recipe.RecipeMap.sChemicalRecipes.addRecipe( + true, + new ItemStack[] {OreDictManager.INSTANCE.getStack("cellSpruceResin", 1)}, + new ItemStack[] {}, + null, + new long[]{10000}, + new FluidStack[]{FluidRegistry.getFluidStack("glyceryl", 50)}, + new FluidStack[]{FluidRegistry.getFluidStack("cablingcolophony", 600)}, + 950,30,0); + GT_ModHandler.addShapelessCraftingRecipe(IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), new Object[] {OreDictManager.INSTANCE.getStack(OP.dust,MT.Coal,1), IHLUtils.getOreDictItemStack("nuggetTarPitch")}); + GT_ModHandler.addShapelessCraftingRecipe(IHLUtils.getThisModItemStackWithSize("dustIrongraphite",2), new Object[] {OreDictManager.INSTANCE.getStack(OP.dust,MT.Iron,1), OreDictManager.INSTANCE.getStack(OP.dust,MT.Graphite,1)}); + GT_ModHandler.addShapelessCraftingRecipe(IHLUtils.getThisModItemStackWithSize("dustPorcelain",4), new Object[] {OreDictManager.INSTANCE.getStack(OP.dust,MT.Clay,1),OreDictManager.INSTANCE.getStack(OP.dust,MT.Clay,1), OreDictManager.INSTANCE.getStack(OP.dust,MT.SiliconDioxide,1), OreDictManager.INSTANCE.getStack(OP.dust,MT.PotassiumFeldspar,1)}); + GT_ModHandler.addSmeltingRecipe(IHLUtils.getThisModItemStack("stickCoalElectrodePremix"), OreDictManager.INSTANCE.getStack(OP.stick,MT.Coal, 1)); + GT_ModHandler.addSmeltingRecipe(OreDictManager.INSTANCE.getStack(OP.dust,MT.Calcite, 1), OreDictManager.INSTANCE.getStack("dustQuicklime", 1)); + Recipe.RecipeMap.sPressRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getThisModItemStack("dustIrongraphite"), IL.Shape_Mold_Cylinder.get(0)}, + new ItemStack[] {IHLUtils.getThisModItemStackWithSize("linerIronGraphite",4)}, + null, + new long[]{10000}, + new FluidStack[]{}, + new FluidStack[]{}, + 950,30,0); + Recipe.RecipeMap.sPressRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), IL.Shape_Extruder_Rod.get(0)}, + new ItemStack[] {IHLUtils.getThisModItemStack("stickCoalElectrodePremix")}, + null, + new long[]{10000}, + new FluidStack[]{}, + new FluidStack[]{}, + 950,30,0); + Recipe.RecipeMap.sPressRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getThisModItemStack("foilRubberWithSulfur"), IL.Shape_Extruder_Casing.get(0)}, + new ItemStack[] {IHLUtils.getThisModItemStack("batteryCellsEbonite")}, + null, + new long[]{10000}, + new FluidStack[]{}, + new FluidStack[]{}, + 950,30,0); + Recipe.RecipeMap.sCompressorRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getThisModItemStackWithSize("foilMica",4)}, + new ItemStack[] {IHLUtils.getThisModItemStack("plateMica")}, + null, + new long[]{10000}, + new FluidStack[]{}, + new FluidStack[]{}, + 950,30,0); + Recipe.RecipeMap.sMaceratorRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getOreDictItemStack("oreGyubnera")}, + new ItemStack[] {IHLUtils.getOreDictItemStack("crushedGyubnera")}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + Recipe.RecipeMap.sCentrifugeRecipes.addRecipe( + true, + new ItemStack[] {IHLUtils.getOreDictItemStack("crushedGyubnera")}, + new ItemStack[] {IHLUtils.getOreDictItemStack("crushedPurifiedGyubnera"),IHLUtils.getOreDictItemStack("dustPotassiumFeldspar")}, + null, + new long[]{10000}, + new FluidStack [] {}, + new FluidStack [] {}, + 600, 30, 0); + } + + private void loadIC2Recipes() + { + ItemStack crystal = IC2Items.getItem("lapotronCrystal").copy(); + ItemStack advBattery = IC2Items.getItem("advBattery").copy(); + ItemStack chargedReBattery = IC2Items.getItem("chargedReBattery").copy(); + 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"), Character.valueOf('F'), IC2Items.getItem("electroFurnace")}); + } + if(IHLMod.config.enableFlexibleCablesCrafting) + { + ItemStack cutter = Ic2Items.cutter.copy(); + cutter.setItemDamage(OreDictionary.WILDCARD_VALUE); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("setOfDies1_5sqmm"), new Object[] { " ", " PC", " ", Character.valueOf('P'), Ic2Items.plateadviron, Character.valueOf('C'), cutter}); + Recipes.advRecipes.addRecipe(IHLUtils.getItemStackWithTag("setOfDies1_5sqmm","transverseSection",240), new Object[] { " C ", " P ", " ", Character.valueOf('P'), Ic2Items.plateadviron, Character.valueOf('C'), cutter}); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("ironWorkbench"), new Object[] { "P ", "P ", "P H", Character.valueOf('P'), Ic2Items.plateadviron, Character.valueOf('H'), Ic2Items.ForgeHammer}); + } + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("itemRubber", 5), IHLUtils.getOreDictItemStackWithSize("dustTinySulfur", 1), IHLUtils.getFluidStackWithSize("molten.rubber", 144*5)); + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("itemRubber", 20), IHLUtils.getOreDictItemStackWithSize("dustSulfur", 1), IHLUtils.getFluidStackWithSize("molten.rubber", 144*20)); + WoodenRollingMachinePart1TileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("itemRubber", 5), IHLUtils.getOreDictItemStackWithSize("dustTinySulfur", 1), IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur",20)); + WoodenRollingMachinePart1TileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("itemRubber", 20), IHLUtils.getOreDictItemStackWithSize("dustSulfur", 1), IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur",80)); + WoodenRollingMachinePart1TileEntity.addRecipe(IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur",16), IHLUtils.getThisModItemStackWithSize("fabric",8), IHLUtils.getOreDictItemStack("dustGraphite"), IHLUtils.getThisModWireItemStackWithLength("pipeRubberWithSulfur",16)); + } +} \ No newline at end of file diff --git a/ihl/IHLModConfig.java b/ihl/IHLModConfig.java new file mode 100644 index 0000000..c22b580 --- /dev/null +++ b/ihl/IHLModConfig.java @@ -0,0 +1,585 @@ +package ihl; + +import ic2.api.item.IC2Items; +import ic2.api.recipe.IRecipeInput; +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; +import ihl.recipes.RecipeInputWire; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +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.FluidStack; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class IHLModConfig +{ + public int handpumpTier=1; + public int handpumpMaxCharge=30000; + public int handpumpOperationEUCost=180; + + public int advancedHandpumpTier=3; + 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; + + public boolean enableFlexibleCablesCrafting=true; + public boolean enableFlexibleCablesGridPowerLossCalculations=true; + public double additionalPowerLossesAtFrequencyGenerator = 0.01D; + public boolean generateApatiteOre=true; + public boolean generateSaltpeterOre=true; + public boolean generateLimestone=true; + public boolean generateGypsum=true; + public boolean generatePotassiumFeldspar=true; + public boolean generateTrona=true; + public boolean generateRocksalt=true; + public boolean generateCinnabar=true; + public boolean generateGyubnera=true; + public boolean generateBauxite=true; + public boolean generateChromite=true; + public boolean generateMuscovite=true; + public boolean generateOil=true; + public boolean generateDatolite=true; + public boolean generateSaltwater=true; + public boolean generateBischofite=true; + public int mirrorReflectionRange=14; + public int mirrorReflectionUpdateSpeed=128; + public String preventMachineBlockRegistrationName="null"; + public boolean skipRecipeLoad=false; + public boolean giveIHLManualOnPlayerWakeUpEvent=true; + + public IHLModConfig(FMLPreInitializationEvent evt) throws IOException + { + Configuration config = new Configuration(evt.getSuggestedConfigurationFile()); + 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); + generateLimestone = config.get(Configuration.CATEGORY_GENERAL, "generateLimestone", generateLimestone).getBoolean(generateLimestone); + generateGypsum = config.get(Configuration.CATEGORY_GENERAL, "generateGypsum", generateGypsum).getBoolean(generateGypsum); + generatePotassiumFeldspar = config.get(Configuration.CATEGORY_GENERAL, "generatePotassiumFeldspar", generatePotassiumFeldspar).getBoolean(generatePotassiumFeldspar); + generateTrona = config.get(Configuration.CATEGORY_GENERAL, "generateTrona", generateTrona).getBoolean(generateTrona); + generateRocksalt = config.get(Configuration.CATEGORY_GENERAL, "generateRocksalt", generateRocksalt).getBoolean(generateRocksalt); + generateCinnabar = config.get(Configuration.CATEGORY_GENERAL, "generateCinnabar", generateCinnabar).getBoolean(generateCinnabar); + generateGyubnera = config.get(Configuration.CATEGORY_GENERAL, "generateGyubnera", generateGyubnera).getBoolean(generateGyubnera); + generateBauxite = config.get(Configuration.CATEGORY_GENERAL, "generateBauxite", generateBauxite).getBoolean(generateBauxite); + generateChromite = config.get(Configuration.CATEGORY_GENERAL, "generateChromite", generateChromite).getBoolean(generateChromite); + generateMuscovite = config.get(Configuration.CATEGORY_GENERAL, "generateMuscovite", generateMuscovite).getBoolean(generateMuscovite); + generateOil = config.get(Configuration.CATEGORY_GENERAL, "generateOil", generateOil).getBoolean(generateOil); + generateDatolite = config.get(Configuration.CATEGORY_GENERAL, "generateDatolite", generateDatolite).getBoolean(generateDatolite); + generateSaltwater = config.get(Configuration.CATEGORY_GENERAL, "generateSaltwater", generateSaltwater).getBoolean(generateSaltwater); + generateBischofite = config.get(Configuration.CATEGORY_GENERAL, "generateBischofite", generateBischofite).getBoolean(generateBischofite); + + handpumpTier = config.get(Configuration.CATEGORY_GENERAL, "handpumpTier", handpumpTier).getInt(); + handpumpMaxCharge = config.get(Configuration.CATEGORY_GENERAL, "handpumpMaxCharge", handpumpMaxCharge).getInt(); + handpumpOperationEUCost = config.get(Configuration.CATEGORY_GENERAL, "handpumpOperationEUCost", handpumpOperationEUCost).getInt(); + 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); + enableFlexibleCablesCrafting = config.get(Configuration.CATEGORY_GENERAL, "enableFlexibleCablesCrafting", enableFlexibleCablesCrafting).getBoolean(enableFlexibleCablesCrafting); + mirrorReflectionRange = config.get(Configuration.CATEGORY_GENERAL, "mirrorReflectionRange", mirrorReflectionRange).getInt(); + mirrorReflectionUpdateSpeed = config.get(Configuration.CATEGORY_GENERAL, "mirrorReflectionUpdateSpeed", mirrorReflectionUpdateSpeed).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(); + } + + private void loadRecipeConfig(InputStream resourceAsStream, boolean rewriteConfig) throws IOException + { + OutputStreamWriter osWriter = null; + BufferedWriter writer = null; + if(rewriteConfig) + { + osWriter = new OutputStreamWriter(new FileOutputStream(getFile()), "UTF-8"); + writer = new BufferedWriter(osWriter); + } + InputStreamReader isReader = new InputStreamReader(resourceAsStream, "UTF-8"); + LineNumberReader reader = new LineNumberReader(isReader); + String line; + StringBuffer currentModificator = new StringBuffer(""); + int bracketCounter=0; + boolean modificatorStart=false; + while ((line = reader.readLine()) != null) + { + if(osWriter!=null) + { + writer.newLine(); + writer.append(line); + } + line = IHLUtils.trim(line); + if (!line.isEmpty() && !line.startsWith("//") && !line.startsWith(";")) + { + currentModificator.append(line); + for(int i=0;i> urmi = UniversalRecipeManager.machineRecipeManagers.entrySet().iterator(); + while(urmi.hasNext()) + { + writer.newLine(); + writer.append("//"+urmi.next().getKey()); + } + writer.close(); + osWriter.close(); + } + } + + private void processModificator(String string) + { + String action = null; + String machineName = null; + String recipeInput = null; + String recipeOutput = null; + UniversalRecipeInput uRecipeInput = null; + UniversalRecipeOutput uRecipeOutput = null; + String[] functionAndParameters = extractFunctionAndParameters(string); + action=functionAndParameters[0].toLowerCase(); + List parameters = splitParameters(functionAndParameters[1]); + Iterator parametersi=parameters.iterator(); + while(parametersi.hasNext()) + { + String parameter = parametersi.next(); + if(parameter.equalsIgnoreCase("ironworkbench")) + { + machineName=parameter; + } + else if(UniversalRecipeManager.machineRecipeManagers.containsKey(parameter)) + { + machineName=parameter; + } + else if(parameter.startsWith("recipeinput")) + { + recipeInput=parameter; + } + else if(parameter.startsWith("recipeoutput")) + { + recipeOutput=parameter; + } + } + List recipeInputsItems = new ArrayList(); + List recipeInputsTools = new ArrayList(); + List recipeInputsMachines = new ArrayList(); + if(recipeInput!=null) + { + List recipeInputsFluids = new ArrayList(); + String[] rifunctionAndParameters = extractFunctionAndParameters(recipeInput); + List riparameters = splitParameters(rifunctionAndParameters[1]); + Iterator riparametersi=riparameters.iterator(); + while(riparametersi.hasNext()) + { + String parameter = riparametersi.next(); + String[] riItemFunctionAndParameters = extractFunctionAndParameters(parameter); + if(riItemFunctionAndParameters[0].startsWith("itemstack")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + String[] modAndItemName = riItemStackparameters.get(0).split(":"); + ItemStack stack = IHLUtils.getOtherModItemStackWithDamage(modAndItemName[0], modAndItemName[1], Integer.parseInt(riItemStackparameters.get(2))); + stack.stackSize = Integer.parseInt(riItemStackparameters.get(1)); + recipeInputsItems.add(new RecipeInputItemStack(stack,stack.stackSize)); + } + else if(riItemFunctionAndParameters[0].startsWith("die")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + recipeInputsItems.add(new RecipeInputDie("setOfDies1_5sqmm", Integer.parseInt(riItemStackparameters.get(0)))); + } + else if(riItemFunctionAndParameters[0].startsWith("fiber")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + ItemStack stack = IHLUtils.getThisModWireItemStackWithLength(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1))); + recipeInputsItems.add(new RecipeInputWire(stack, Integer.parseInt(riItemStackparameters.get(1)))); + } + else if(riItemFunctionAndParameters[0].startsWith("wire")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + recipeInputsItems.add(new RecipeInputWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2)))); + } + else if(riItemFunctionAndParameters[0].startsWith("cable")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + recipeInputsItems.add(new RecipeInputWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2)),riItemStackparameters.get(3),Integer.parseInt(riItemStackparameters.get(4)),Integer.parseInt(riItemStackparameters.get(5)))); + } + else if(riItemFunctionAndParameters[0].startsWith("oredict")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + recipeInputsItems.add(new RecipeInputOreDict(riItemStackparameters.get(0),Integer.parseInt(riItemStackparameters.get(1)))); + } + else if(riItemFunctionAndParameters[0].startsWith("toolitemstack")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + String[] modAndItemName = riItemStackparameters.get(0).split(":"); + ItemStack stack = IHLUtils.getOtherModItemStackWithDamage(modAndItemName[0], modAndItemName[1], Integer.parseInt(riItemStackparameters.get(2))); + stack.stackSize = Integer.parseInt(riItemStackparameters.get(1)); + recipeInputsTools.add(new RecipeInputItemStack(stack,stack.stackSize)); + } + else if(riItemFunctionAndParameters[0].startsWith("tooloredict")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + recipeInputsTools.add(new RecipeInputOreDict(riItemStackparameters.get(0),Integer.parseInt(riItemStackparameters.get(1)))); + } + else if(riItemFunctionAndParameters[0].startsWith("machine")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + String[] modAndItemName = riItemStackparameters.get(0).split(":"); + recipeInputsMachines.add(IHLUtils.getThisModItemStack(modAndItemName[1])); + } + else if(riItemFunctionAndParameters[0].startsWith("fluidstack")) + { + List riFluidStackparameters = splitParameters(riItemFunctionAndParameters[1]); + recipeInputsFluids.add(IHLUtils.getFluidStackWithSize(riFluidStackparameters.get(0),Integer.parseInt(riFluidStackparameters.get(1)))); + } + } + uRecipeInput = new UniversalRecipeInput(recipeInputsFluids,recipeInputsItems); + } + List recipeOutputsItems = new ArrayList(); + List recipeOutputsRecipeOut = new ArrayList(); + if(recipeOutput!=null) + { + List recipeOutputsFluids = new ArrayList(); + String[] rifunctionAndParameters = extractFunctionAndParameters(recipeOutput); + List riparameters = splitParameters(rifunctionAndParameters[1]); + Iterator riparametersi=riparameters.iterator(); + while(riparametersi.hasNext()) + { + String parameter = riparametersi.next(); + String[] riItemFunctionAndParameters = extractFunctionAndParameters(parameter); + if(riItemFunctionAndParameters[0].startsWith("itemstack")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + String[] modAndItemName = riItemStackparameters.get(0).split(":"); + ItemStack stack = IHLUtils.getOtherModItemStackWithDamage(modAndItemName[0], modAndItemName[1], Integer.parseInt(riItemStackparameters.get(2))); + stack.stackSize = Integer.parseInt(riItemStackparameters.get(1)); + recipeOutputsItems.add(stack); + recipeOutputsRecipeOut.add(new RecipeOutputItemStack(stack,Float.parseFloat(riItemStackparameters.get(1)))); + } + else if(riItemFunctionAndParameters[0].startsWith("fiber")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + ItemStack stack = IHLUtils.getThisModWireItemStackWithLength(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1))); + recipeOutputsItems.add(stack); + recipeOutputsRecipeOut.add(new RecipeOutputItemStack(stack,1)); + } + else if(riItemFunctionAndParameters[0].startsWith("wire")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + ItemStack stack = IHLUtils.getUninsulatedWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2))); + recipeOutputsItems.add(stack); + recipeOutputsRecipeOut.add(new RecipeOutputItemStack(stack,1)); + } + else if(riItemFunctionAndParameters[0].startsWith("cable")) + { + List riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]); + ItemStack stack = IHLUtils.getInsulatedWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2)),riItemStackparameters.get(3),Integer.parseInt(riItemStackparameters.get(4))); + recipeOutputsItems.add(stack); + recipeOutputsRecipeOut.add(new RecipeOutputItemStack(stack,1)); + } + else if(riItemFunctionAndParameters[0].startsWith("fluidstack")) + { + List riFluidStackparameters = splitParameters(riItemFunctionAndParameters[1]); + recipeOutputsFluids.add(IHLUtils.getFluidStackWithSize(riFluidStackparameters.get(0),Integer.parseInt(riFluidStackparameters.get(1)))); + } + } + uRecipeOutput = new UniversalRecipeOutput(recipeOutputsFluids,recipeOutputsRecipeOut, 200); + } + if(action.equalsIgnoreCase("addrecipe")) + { + if(machineName.equalsIgnoreCase("ironworkbench")) + { + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(recipeInputsTools,recipeInputsItems, recipeOutputsItems, recipeInputsMachines)); + } + else + { + UniversalRecipeManager.machineRecipeManagers.get(machineName).addRecipe(uRecipeInput, uRecipeOutput); + } + } + else if(action.equalsIgnoreCase("removerecipe")) + { + if(machineName.equalsIgnoreCase("ironworkbench")) + { + if(recipeInputsTools.isEmpty() && recipeInputsItems.isEmpty() && recipeInputsMachines.isEmpty()) + { + IronWorkbenchTileEntity.removeRecipeByOutput(recipeOutputsItems); + } + else + { + IronWorkbenchTileEntity.removeRecipeByInput(recipeInputsTools,recipeInputsItems, recipeInputsMachines); + } + } + else + { + if(uRecipeInput==null) + { + UniversalRecipeManager.machineRecipeManagers.get(machineName).removeRecipeByOutput(uRecipeOutput); + } + else + { + UniversalRecipeManager.machineRecipeManagers.get(machineName).removeRecipeByInput(uRecipeInput); + } + } + } + } + + private List splitParameters(String string) { + ArrayList result = new ArrayList(); + int bracketCounter=0; + boolean modificatorStart=false; + String function = null; + String parameters = null; + StringBuffer currentModificator = new StringBuffer(""); + for(int i=0;i entityList = new HashMap(); + protected Set entityServerList = new HashSet(); + protected Map delayedEntityDataPacket = new HashMap(); + public Map> nodeEntityRegistry = new HashMap(); + + public ServerProxy() {} + + public void load() throws ParserConfigurationException + { + if(channel==null) + { + channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(IHLModInfo.MODID); + channel.register(this); + } + } + public void spawnParticle(int particle, World world, double x, double y, double z, double mx, double my, double mz, float paticleScale){} + + public void spawnParticleFromServer(int particle, World world, double x, double y, double z, double mx, double my, double mz, float paticleScale) + { + ByteBuf bb = Unpooled.buffer(36); + ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb); + try + { + byteBufOutputStream.write(0); + byteBufOutputStream.write(particle); + byteBufOutputStream.writeFloat((float) x); + byteBufOutputStream.writeFloat((float) y); + byteBufOutputStream.writeFloat((float) z); + byteBufOutputStream.writeFloat((float) mx); + byteBufOutputStream.writeFloat((float) my); + byteBufOutputStream.writeFloat((float) mz); + byteBufOutputStream.writeFloat(paticleScale); + channel.sendToAllAround(new FMLProxyPacket(byteBufOutputStream.buffer(),IHLModInfo.MODID), new TargetPoint(world.provider.dimensionId, x, y, z, 32d)); + byteBufOutputStream.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + public void registerIcons(Pre event) {} + public void initBlockRenderer(){} + public Object getRenderForEntityClass(Class entityClass) + { + return null; + } + public int getGLDisplayList() {return -1;} + + public File getMinecraftDir() + { + return new File("."); + } + public int shareBlockRendererByMachineType(MachineType type) + { + return 0; + } + + public void addEntityToList(INetworkListener entity) + { + this.entityList.put(entity.getId(), entity); + } + + public void recieveDelayedDataPacket(INetworkListener listener) + { + ByteBuf data = delayedEntityDataPacket.remove(listener.getId()); + if(data!=null) + { + ByteBufInputStream byteBufInputStream = new ByteBufInputStream(data); + try + { + //byteBufInputStream.skipBytes(5); + listener.recieveData(byteBufInputStream); + byteBufInputStream.close(); + IHLMod.log.debug("Delayed data read."); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + else + { + IHLMod.log.debug("Delayed data is null. Entity ID="+listener.getId()); + } + } + + public void sendFromServerToAll(FMLProxyPacket fmlProxyPacket) + { + channel.sendToAll(fmlProxyPacket); + } + + public void sendFromServerToPlayer(FMLProxyPacket fmlProxyPacket, EntityPlayerMP player) + { + channel.sendTo(fmlProxyPacket, player); + } + + @SubscribeEvent + public void onPacketFromClientToServer(FMLNetworkEvent.ServerCustomPacketEvent event) throws IOException + { + ByteBuf data = event.packet.payload(); + ByteBufInputStream byteBufInputStream = new ByteBufInputStream(data); + switch(byteBufInputStream.read()) + { + case 0: + int playerEntityId = byteBufInputStream.readInt(); + int worldDimensionId = byteBufInputStream.readInt(); + int containerSlotNumber = byteBufInputStream.readInt(); + int fieldValue = byteBufInputStream.readInt(); + String fieldName = byteBufInputStream.readUTF(); + EntityPlayerMP player = (EntityPlayerMP) MinecraftServer.getServer().worldServerForDimension(worldDimensionId).getEntityByID(playerEntityId); + ItemStack stack = ((Slot)player.openContainer.inventorySlots.get(containerSlotNumber)).getStack(); + stack.stackTagCompound.setInteger(fieldName, fieldValue); + player.openContainer.detectAndSendChanges(); + System.out.println("Field now "+stack.stackTagCompound.getInteger(fieldName)); + break; + } + + byteBufInputStream.close(); + + } + + @SubscribeEvent + public void onPlayerConnectedToServer(PlayerLoggedInEvent event) + { + IHLMod.log.debug("player connected"); + Iterator inli=this.entityServerList.iterator(); + while(inli.hasNext()) + { + INetworkListener inl = inli.next(); + if(inl.isInvalid()) + { + inli.remove(); + } + else if(event.player instanceof EntityPlayerMP) + { + inl.registerAndSendData((EntityPlayerMP)event.player); + } + } + } + + @SubscribeEvent + public void onPlayerTeleport(PlayerChangedDimensionEvent event) + { + FlexibleCableItem.instance.onPlayerTeleport(event); + Iterator inli=this.entityServerList.iterator(); + while(inli.hasNext()) + { + INetworkListener inl = inli.next(); + if(inl.isInvalid()) + { + inli.remove(); + } + else if(event.player instanceof EntityPlayerMP) + { + inl.registerAndSendData((EntityPlayerMP)event.player); + } + } + } + + public void addEntityToServerList(INetworkListener entity) + { + this.entityServerList.add(entity); + } + + public boolean renderTESpecialSelectionBox(TileEntity te, EntityPlayer player, ItemStack currentItem, MovingObjectPosition target, float partialTicks) { + return false; + } + + public void sendItemStackNBTTagFromClientToServerPlayer(EntityPlayer player, int slotNumber, String fieldName, int fieldValue){} +} diff --git a/ihl/collector/ChargerEjectorBlock.java b/ihl/collector/ChargerEjectorBlock.java new file mode 100644 index 0000000..cfeb567 --- /dev/null +++ b/ihl/collector/ChargerEjectorBlock.java @@ -0,0 +1,90 @@ +package ihl.collector; + +import ic2.api.item.IC2Items; +import ihl.IHLModInfo; + +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.BlockContainer; +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.tileentity.TileEntity; +import net.minecraft.world.World; + +public class ChargerEjectorBlock extends BlockContainer { + + public ChargerEjectorBlock(Material material) { + super(material); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return IC2Items.getItem("glassFiberCableItem").getItem(); + } + + @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 ChargerEjectorTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":ace"); + } + + @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){ + if(world.getTileEntity(x,y,z) instanceof ChargerEjectorTileEntity) + { + ChargerEjectorTileEntity var10 = (ChargerEjectorTileEntity)world.getTileEntity(x,y,z); + if (var10 == null || entityPlayer.isSneaking()) { + return false; + } + else + { + return var10.getGui(entityPlayer); + } + } + return false; + } + + /** + * The type of render function that is called for this block + */ + @Override + public int getRenderType() + { + return -2; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } +} diff --git a/ihl/collector/ChargerEjectorContainer.java b/ihl/collector/ChargerEjectorContainer.java new file mode 100644 index 0000000..8d18998 --- /dev/null +++ b/ihl/collector/ChargerEjectorContainer.java @@ -0,0 +1,93 @@ +package ihl.collector; + +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; +import net.minecraft.item.ItemStack; + +public class ChargerEjectorContainer extends ContainerBase { + + 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)); + } + short st = 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 new file mode 100644 index 0000000..79a0c0c --- /dev/null +++ b/ihl/collector/ChargerEjectorGui.java @@ -0,0 +1,128 @@ +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.network.NetworkManager; +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; + } + + @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 new file mode 100644 index 0000000..5177fee --- /dev/null +++ b/ihl/collector/ChargerEjectorModel.java @@ -0,0 +1,150 @@ +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 new file mode 100644 index 0000000..07ed0af --- /dev/null +++ b/ihl/collector/ChargerEjectorRender.java @@ -0,0 +1,92 @@ +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 new file mode 100644 index 0000000..fdb18ed --- /dev/null +++ b/ihl/collector/ChargerEjectorTileEntity.java @@ -0,0 +1,521 @@ +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 ic2.core.network.NetworkManager; +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; + } + } + + 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; + } + } + + 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; + } + + @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.stackSizemax) + { + return max; + } + else if(motion<-max) + { + return -max; + } + else + { + return 0D; + } + } + + public ItemStack getVisibleItemStack() + { + return this.dataWatcher.getWatchableObjectItemStack(18); + } + + private void harvest() + { + double range = 1D; + AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.posX-range,this.posY-range-1D,this.posZ-range,this.posX+range,this.posY+range,this.posZ+range); + List 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 new file mode 100644 index 0000000..510e28b --- /dev/null +++ b/ihl/collector/CollectorHeavyEntity.java @@ -0,0 +1,305 @@ +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 + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) + { + info.add("PowerTier: " + this.tier); + } + + @Override + @SideOnly(Side.CLIENT) + 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 new file mode 100644 index 0000000..39040bb --- /dev/null +++ b/ihl/collector/CollectorItemRender.java @@ -0,0 +1,112 @@ +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 new file mode 100644 index 0000000..a1bada9 --- /dev/null +++ b/ihl/collector/CollectorModel.java @@ -0,0 +1,110 @@ +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 new file mode 100644 index 0000000..1ad7be7 --- /dev/null +++ b/ihl/collector/GlassBoxContainer.java @@ -0,0 +1,45 @@ +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 new file mode 100644 index 0000000..4e09187 --- /dev/null +++ b/ihl/collector/GlassBoxGui.java @@ -0,0 +1,55 @@ +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 net.minecraft.util.StatCollector; + +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; + private String title = StatCollector.translateToLocal("ihl.gui.charger_ejector"); + + public GlassBoxGui (GlassBoxContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + } + + @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 new file mode 100644 index 0000000..764314d --- /dev/null +++ b/ihl/collector/GlassBoxRender.java @@ -0,0 +1,49 @@ +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); + float rotation=0F; + 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; + } + + 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/BlobEntityFX.java b/ihl/crop_harvestors/BlobEntityFX.java new file mode 100644 index 0000000..60a3ad9 --- /dev/null +++ b/ihl/crop_harvestors/BlobEntityFX.java @@ -0,0 +1,84 @@ +package ihl.crop_harvestors; + +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +public class BlobEntityFX extends EntityFX { + + public FluidType fluid = FluidType.RESIN; + + public BlobEntityFX(World world, double x, double y, double z) + { + super(world, x, y, z); + this.noClip = true; + } + + public BlobEntityFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14, FluidType fluid1) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.1D; + this.motionY *= 0.1D; + this.motionZ *= 0.1D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + this.particleScale *= par14; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.noClip = true; + fluid=fluid1; + } + + @Override + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float var8 = ((float)this.particleAge) / (float)this.particleMaxAge * 32.0F; + + if (var8 < 0.0F) + { + var8 = 0.0F; + } + + if (var8 > 1.0F) + { + var8 = 1.0F; + } + this.renderParticle2(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void renderParticle2(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float var12 = 0.1F * this.particleScale; + float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX); + float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY); + float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ); + par1Tessellator.addVertexWithUV(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12, 1D, 1D); + par1Tessellator.addVertexWithUV(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12, 1D, 0D); + par1Tessellator.addVertexWithUV(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12, 0D, 0D); + par1Tessellator.addVertexWithUV(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12, 0D, 1D); + } + + @Override + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + this.motionX *= 0.5D; + this.motionZ *= 0.5D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionY -= 0.001D; + this.motionY *= 0.96D; + } + + public enum FluidType + { + SAP, + RESIN + } +} diff --git a/ihl/crop_harvestors/BlobRenderFX.java b/ihl/crop_harvestors/BlobRenderFX.java new file mode 100644 index 0000000..21fe3a3 --- /dev/null +++ b/ihl/crop_harvestors/BlobRenderFX.java @@ -0,0 +1,63 @@ +package ihl.crop_harvestors; + +import ihl.IHLModInfo; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class BlobRenderFX extends Render{ + private ResourceLocation tex, tex2; + +public BlobRenderFX() +{ + super(); + tex = new ResourceLocation(IHLModInfo.MODID+":textures/particles/blob.png"); + tex2 = new ResourceLocation(IHLModInfo.MODID+":textures/particles/blobOfResin.png"); +} + +@Override +public void doRender(Entity entity, double x, double y, double z, + float arg4, float arg5) +{ + float var3 = ActiveRenderInfo.rotationX; + float var4 = ActiveRenderInfo.rotationZ; + float var5 = ActiveRenderInfo.rotationYZ; + float var6 = ActiveRenderInfo.rotationXY; + float var7 = ActiveRenderInfo.rotationXZ; + EntityFX.interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * arg4; + EntityFX.interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * arg4; + EntityFX.interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * arg4; + if(((BlobEntityFX)entity).fluid==BlobEntityFX.FluidType.RESIN) + { + this.renderManager.renderEngine.bindTexture(tex); + } + else + { + this.renderManager.renderEngine.bindTexture(tex2); + } + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslatef((float)x, (float)y, (float)z); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + Tessellator var9 = Tessellator.instance; + var9.startDrawingQuads(); + EntityFX var11 = (EntityFX) entity; + var11.renderParticle(var9, arg4, var3, var7, var4, var5, var6); + var9.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glPopMatrix(); +} + + @Override + protected ResourceLocation getEntityTexture(Entity arg0) + { + return tex; + } +} \ No newline at end of file diff --git a/ihl/crop_harvestors/BlowerBlock.java b/ihl/crop_harvestors/BlowerBlock.java new file mode 100644 index 0000000..9d4c782 --- /dev/null +++ b/ihl/crop_harvestors/BlowerBlock.java @@ -0,0 +1,170 @@ +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) + { + IIcon sideIcon = this.blockIcon; + 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 new file mode 100644 index 0000000..65393bf --- /dev/null +++ b/ihl/crop_harvestors/BlowerContainer.java @@ -0,0 +1,89 @@ +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 new file mode 100644 index 0000000..f74ac51 --- /dev/null +++ b/ihl/crop_harvestors/BlowerGui.java @@ -0,0 +1,66 @@ +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 + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + } + + @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 new file mode 100644 index 0000000..1c06f6c --- /dev/null +++ b/ihl/crop_harvestors/BlowerTileEntity.java @@ -0,0 +1,1074 @@ +package ihl.crop_harvestors; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +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.network.NetworkManager; +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 boolean shouldCalculateAirFlow=true; + private int sCAFCount=0; + public boolean addedToEnergyNet = false; + private boolean hasEntityInFlow=false; + private ArrayList aszlist = new ArrayList(); + public final InvSlotUpgrade upgradeSlot; + public final IHLInvSlotDischarge dischargeSlot; + public int updateChecksum=-1; + private final float lambda=0.00001F; + private Random rand = new Random(); + 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; + } + } + + + @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 isCNE(int x,int y,int z,int x1,int y1,int z1) + { + return x!=x1||y!=y1||z!=z1; + } + + 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/crop_harvestors/RubberTreeBlock.java b/ihl/crop_harvestors/RubberTreeBlock.java new file mode 100644 index 0000000..bb2128b --- /dev/null +++ b/ihl/crop_harvestors/RubberTreeBlock.java @@ -0,0 +1,167 @@ +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.IHLModInfo; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class RubberTreeBlock extends Block{ + + IIcon textureSide, textureTop; + TreeType type; + + public RubberTreeBlock(TreeType type1) + { + super(Material.wood); + type=type1; + } + + @Override + public Item getItemDropped(int var1, Random rnd, int var2) + { + switch(type) + { + case RUBBERTREE: + return IC2Items.getItem("rubberWood").getItem(); + case SPRUCE: + return Blocks.log.getItemDropped(var1, rnd, var2); + default: + return IC2Items.getItem("rubberWood").getItem(); + } + + } + + @Override + public boolean canSustainLeaves(IBlockAccess blockAccess, int x, int y, int z) + { + return true; + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + ItemStack result; + switch(type) + { + case RUBBERTREE: + result = IC2Items.getItem("rubberWood").copy(); + case SPRUCE: + result = new ItemStack(Blocks.log,1,1); + default: + result = IC2Items.getItem("rubberWood").copy(); + } + this.dropBlockAsItem(world, x, y, z, result); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + ItemStack result; + switch(type) + { + case RUBBERTREE: + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodFront"); + this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodTop"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodSide"); + case SPRUCE: + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockSpruceFront"); + this.textureTop = par1IconRegister.registerIcon("minecraft:log_spruce_top"); + this.textureSide = par1IconRegister.registerIcon("minecraft:log_spruce"); + } + } + + @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 + }; + facing=world.getBlockMetadata(x, y, z); + switch (mask[facing*6+side]) + { + case 0: + return this.textureSide; + case 1: + return this.blockIcon; + case 2: + return this.textureTop; + case 3: + return this.textureTop; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + IIcon sideIcon = this.blockIcon; + switch (side) + { + case 0: + return this.textureTop; + case 1: + return this.textureTop; + case 2: + return this.blockIcon; + case 3: + return this.textureSide; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + public enum TreeType + { + RUBBERTREE, + SPRUCE + } + + @Override + public boolean isWood(IBlockAccess world, int x, int y, int z) + { + return true; + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) + { + return 4; + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) + { + return 20; + } + +} diff --git a/ihl/crop_harvestors/SackBlock.java b/ihl/crop_harvestors/SackBlock.java new file mode 100644 index 0000000..78a5735 --- /dev/null +++ b/ihl/crop_harvestors/SackBlock.java @@ -0,0 +1,167 @@ +package ihl.crop_harvestors; + +import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +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.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +public class SackBlock extends Block implements ITileEntityProvider{ + + public SackBlock(Material material) + { + super(material); + this.setCreativeTab(IHLCreativeTab.tab); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new SackTileEntity(); + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":sackItem"); + } + + @Override + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) + { + this.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.1F, 0.8F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.2F, 0.0F, 0.2F, 0.21F, 1.0F, 0.8F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 1.0F, 0.21F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.79F, 0.0F, 0.0F, 0.8F, 1.0F, 0.8F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.79F, 0.8F, 1.0F, 0.8F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBoundsForItemRender(); + } + + @Override + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + @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(!world.isRemote && te instanceof SackTileEntity) + { + SackTileEntity ste = (SackTileEntity)te; + if (ste == null || entityPlayer.isSneaking()) { + return false; + } + else + { + if(ste.fluidTank.getFluid()!=null) + { + if(entityPlayer.inventory.getCurrentItem()!=null) + { + if(entityPlayer.inventory.getCurrentItem().getItem() instanceof IFluidContainerItem) + { + return false; + } + FluidStack drainFS = ste.drain(ForgeDirection.UNKNOWN, ste.fluidTank.getCapacity(), false); + ItemStack stackToAdd = FluidContainerRegistry.fillFluidContainer(drainFS, entityPlayer.inventory.getCurrentItem()); + if(stackToAdd!=null) + { + if (entityPlayer.inventory.addItemStackToInventory(stackToAdd)) + { + entityPlayer.inventory.getCurrentItem().stackSize--; + entityPlayer.inventoryContainer.detectAndSendChanges(); + ste.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getContainerCapacity(stackToAdd),true); + } + } + } + } + } + } + return false; + } + + /** + * 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 onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null && t instanceof SackTileEntity) + { + SackTileEntity te = (SackTileEntity)t; + switch(var7) + { + case 0: + te.setFacing((short) 3); + break; + case 1: + te.setFacing((short) 4); + break; + case 2: + te.setFacing((short) 2); + break; + case 3: + te.setFacing((short) 5); + break; + default: + break; + } + + } + } +} diff --git a/ihl/crop_harvestors/SackModel.java b/ihl/crop_harvestors/SackModel.java new file mode 100644 index 0000000..a0fe780 --- /dev/null +++ b/ihl/crop_harvestors/SackModel.java @@ -0,0 +1,103 @@ +package ihl.crop_harvestors; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class SackModel extends ModelBase { + //fields + ModelRenderer Base; + ModelRenderer Top; + ModelRenderer Liquid; + ModelRenderer Liquid_overflow; + ModelRenderer Liquid2; + ModelRenderer Liquid2_overflow; + ModelRenderer Rope1; + ModelRenderer Rope2; + + public SackModel() + { + textureWidth = 64; + textureHeight = 64; + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape4", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Top.Shape6", 0, 0); + setTextureOffset("Top.Shape7", 0, 0); + setTextureOffset("Top.Shape8", 0, 0); + setTextureOffset("Liquid.Shape9", 20, 20); + setTextureOffset("Liquid_overflow.Shape12", 46, 25); + setTextureOffset("Rope1.Shape12", 56, 17); + setTextureOffset("Rope2.Shape13", 48, 17); + + setTextureOffset("Liquid2.Shape14", 0, 32); + setTextureOffset("Liquid2_overflow.Shape15", 46, 57); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 8F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape1", -6F, 15F, -4F, 12, 1, 12); + Base.addBox("Shape2", -6F, 2F, -4F, 12, 13, 1); + Base.addBox("Shape3", -6F, 2F, -3F, 1, 13, 10); + Base.addBox("Shape4", 5F, 2F, -3F, 1, 13, 10); + Base.addBox("Shape5", -6F, 0F, 7F, 12, 15, 1); + Top = new ModelRenderer(this, "Top"); + Top.setRotationPoint(0F, 9F, 0F); + setRotation(Top, 0.05F, 0F, 0F); + Top.mirror = true; + Top.addBox("Shape6", -6.2F, -0.5F, -4.4F, 1, 2, 12); + Top.addBox("Shape7", 5.2F, -0.5F, -4.4F, 1, 2, 12); + Top.addBox("Shape8", -6F, -0.4F, -4.5F, 12, 2, 1); + Liquid = new ModelRenderer(this, "Liquid"); + Liquid.setRotationPoint(0F, 8F, 0F); + setRotation(Liquid, 0F, 0F, 0F); + Liquid.mirror = true; + Liquid.addBox("Shape9", -5.5F, 0.5F, -3.5F, 11, 1, 11); + Liquid_overflow = new ModelRenderer(this, "Liquid_overflow"); + Liquid_overflow.setRotationPoint(0F, 8F, 0F); + setRotation(Liquid_overflow, 0.051F, 0F, 0.01F); + Liquid_overflow.mirror = true; + Liquid_overflow.addBox("Shape12", -4F, 0.55F, -4.4F, 8, 2, 2); + + Liquid2 = new ModelRenderer(this, "Liquid2"); + Liquid2.setRotationPoint(0F, 8F, 0F); + setRotation(Liquid2, 0F, 0F, 0F); + Liquid2.mirror = true; + Liquid2.addBox("Shape14", -5.5F, 0.5F, -3.5F, 11, 1, 11); + Liquid2_overflow = new ModelRenderer(this, "Liquid2_overflow"); + Liquid2_overflow.setRotationPoint(0F, 8F, 0F); + setRotation(Liquid2_overflow, 0.051F, 0F, 0.01F); + Liquid2_overflow.mirror = true; + Liquid2_overflow.addBox("Shape15", -4F, 0.55F, -4.4F, 8, 2, 2); + + + Rope1 = new ModelRenderer(this, "Rope1"); + Rope1.setRotationPoint(0F, 8F, 0F); + setRotation(Rope1, 0F, 0F, -0.2F); + Rope1.mirror = true; + Rope1.addBox("Shape12", 5F, 0.7F, 7.9F, 3, 1, 1); + Rope2 = new ModelRenderer(this, "Rope2"); + Rope2.setRotationPoint(0F, 8F, 0F); + setRotation(Rope2, 0F, 0F, 0.2F); + Rope2.mirror = true; + Rope2.addBox("Shape13", -8F, 0.7F, 7.9F, 3, 1, 1); + } + + 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/crop_harvestors/SackRender.java b/ihl/crop_harvestors/SackRender.java new file mode 100644 index 0000000..e359e3a --- /dev/null +++ b/ihl/crop_harvestors/SackRender.java @@ -0,0 +1,95 @@ +package ihl.crop_harvestors; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidRegistry; + +import org.lwjgl.opengl.GL11; +import ihl.IHLModInfo; + +public class SackRender extends TileEntitySpecialRenderer{ +private SackModel model = new SackModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/sack.png"); +private final float maxRenderLiquidLevel=0.5F; +private final float minRenderLiquidLevel=14.5F; +private final float scale=1F/16F; +private float overflow=0F; + + +public SackRender(){} + +public void renderAModelAt(SackTileEntity 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(scale); +model.Top.render(scale); +model.Rope1.render(scale); +model.Rope2.render(scale); +GL11.glEnable(GL11.GL_BLEND); +GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); +GL11.glColor4f(1f,1f,1f,1f); +model.Liquid2.offsetY=model.Liquid.offsetY=(minRenderLiquidLevel-(minRenderLiquidLevel-maxRenderLiquidLevel)*tile.getRenderLiquidLevel())*scale; +if(tile.getRenderLiquidLevel()>0) +{ + if(tile.visibleFluidId!=-1) + { + if(tile.visibleFluidId==FluidRegistry.getFluid("fluidrubbertreesap").getID()) + { + model.Liquid.render(scale); + } + else if(tile.visibleFluidId==FluidRegistry.getFluid("spruceresin").getID()) + { + model.Liquid2.render(scale); + } + } +} +if(tile.getRenderLiquidLevel()>0.98F) +{ + if(overflow<0.5F)overflow+=0.001F; + model.Liquid2_overflow.offsetZ=model.Liquid_overflow.offsetZ=-overflow*scale; + if(tile.visibleFluidId!=-1) + { + if(tile.visibleFluidId==FluidRegistry.getFluid("fluidrubbertreesap").getID()) + { + model.Liquid_overflow.render(scale); + } + else if(tile.visibleFluidId==FluidRegistry.getFluid("spruceresin").getID()) + { + model.Liquid2_overflow.render(scale); + } + } +} +GL11.glDisable(GL11.GL_BLEND); +GL11.glPopMatrix(); //end +} + + @Override + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) + { + this.renderAModelAt((SackTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/ihl/crop_harvestors/SackTileEntity.java b/ihl/crop_harvestors/SackTileEntity.java new file mode 100644 index 0000000..9704b7f --- /dev/null +++ b/ihl/crop_harvestors/SackTileEntity.java @@ -0,0 +1,569 @@ +package ihl.crop_harvestors; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +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.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.IC2; +import ic2.core.block.TileEntityInventory; +import ic2.core.network.NetworkManager; +import ihl.IHLMod; +import ihl.utils.IHLFluidTank; + +public class SackTileEntity extends TileEntityInventory implements IFluidHandler +{ + private final int maxLeavesHeight=12; + private final int maxLeavesWidth=5; + public float leavesCounter=0F; + private int updateCounter=1100; + private Random rand=new Random(); + private int blobTimer=20; + public byte currentTree = RUBBERTREE; + public final int blobCapacity = 1; + private final static byte RUBBERTREE=0; + private final static byte SPRUCE=1; + public final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public int visibleFluidId = -1; + public int visibleFluidAmount = 1; + + public SackTileEntity() { + super(); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("visibleFluidId"); + fields.add("visibleFluidAmount"); + fields.add("leavesCounter"); + fields.add("currentTree"); + return fields; + } + + @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 boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return new ItemStack(IHLMod.sackBlock,1); + } + + public boolean enableUpdateEntity() + { + return true; + } + + + @Override + public void updateEntityClient() + { + super.updateEntityClient(); + if(IHLMod.ic2Leaves!=null && IHLMod.ic2Wood!=null) + { + if(this.blobTimer<=0) + { + if(IC2.platform.isRendering()) + { + switch(this.currentTree) + { + case RUBBERTREE: + IHLMod.proxy.spawnParticle(1,worldObj, xCoord+0.5D+mX()*0.5D,yCoord+1.05D,zCoord+0.5D+mZ()*0.5D,-(double)mX()*0.1D,-0.03D,-(double)mZ()*0.1D,0.1F); + break; + case SPRUCE: + IHLMod.proxy.spawnParticle(2,worldObj, xCoord+0.5D+mX()*0.5D,yCoord+1.05D,zCoord+0.5D+mZ()*0.5D,-(double)mX()*0.1D,-0.03D,-(double)mZ()*0.1D,0.1F); + break; + } + } + if(this.fluidTank.getFluidAmount()>=this.fluidTank.getCapacity()) + { + if(IC2.platform.isRendering()) + { + switch(this.currentTree) + { + case RUBBERTREE: + IHLMod.proxy.spawnParticle(1,worldObj, xCoord+0.5D-mX()*0.3D+(rand.nextDouble()-0.5D)*mZ()*0.6D,yCoord+0.8D,zCoord+0.5D-mZ()*0.3D+(rand.nextDouble()-0.5D)*mX()*0.6D,0D,-0.05D,0D,0.1F); + break; + case SPRUCE: + IHLMod.proxy.spawnParticle(2,worldObj, xCoord+0.5D-mX()*0.3D+(rand.nextDouble()-0.5D)*mZ()*0.6D,yCoord+0.8D,zCoord+0.5D-mZ()*0.3D+(rand.nextDouble()-0.5D)*mX()*0.6D,0D,-0.05D,0D,0.1F); + break; + } + } + } + if(this.leavesCounter>1F) + { + this.blobTimer=Math.round(4000F/this.leavesCounter); + } + else + { + this.blobTimer=200; + } + } + else + { + if(this.leavesCounter>1F) + { + this.blobTimer--; + } + } + if(this.updateCounter<1200) + { + this.updateCounter++; + } + } + + } + + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(IHLMod.ic2Leaves!=null && IHLMod.ic2Wood!=null) + { + if(this.blobTimer<=0) + { + { + if(IC2.platform.isSimulating()) + { + switch(this.currentTree) + { + case RUBBERTREE: + this.fluidTank.fill(new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"), blobCapacity), true); + break; + case SPRUCE: + this.fluidTank.fill(new FluidStack(FluidRegistry.getFluid("spruceresin"), blobCapacity), true); + break; + } + } + } + if(this.leavesCounter>1F) + { + this.blobTimer=Math.round(4000F/this.leavesCounter); + } + else + { + this.blobTimer=200; + } + } + else + { + if(this.leavesCounter>1F) + { + this.blobTimer--; + } + } + if(this.updateCounter<1200) + { + this.updateCounter++; + } + else + { + if(IC2.platform.isSimulating()) + { + this.updateCounter=rand.nextInt(600); + if(checkCorrectPlacing()) + { + countRubberTreeLeaves(); + } + else + { + leavesCounter=0F; + } + IC2.network.get().updateTileEntityField(this, "currentTree"); + IC2.network.get().updateTileEntityField(this, "leavesCounter"); + if(this.fluidTank.getFluid()!=null) + { + + TileEntity te = worldObj.getTileEntity(xCoord, yCoord-1, zCoord); + if(te!=null && te instanceof IFluidHandler) + { + IFluidHandler fte = (IFluidHandler) te; + FluidStack fStack = this.fluidTank.drain(Integer.MAX_VALUE, false); + if(fte.canFill(ForgeDirection.UP, fStack.getFluid())) + { + if(fte.fill(ForgeDirection.UP, fStack, false)>0) + { + int amount = fte.fill(ForgeDirection.UP, fStack, true); + this.fluidTank.drain(amount, true); + } + } + } + } + } + } + if(this.fluidTank.getFluid()!=null && (visibleFluidId!=this.fluidTank.getFluid().getFluid().getID() || Math.abs(visibleFluidAmount-this.fluidTank.getFluidAmount())>20)) + { + visibleFluidId = this.fluidTank.getFluid().getFluid().getID(); + visibleFluidAmount = this.fluidTank.getFluidAmount(); + IC2.network.get().updateTileEntityField(this, "visibleFluidId"); + IC2.network.get().updateTileEntityField(this, "visibleFluidAmount"); + } + else if(this.fluidTank.getFluid()==null && visibleFluidId!=-1) + { + visibleFluidId=-1; + IC2.network.get().updateTileEntityField(this, "visibleFluidId"); + } + } + } + + private boolean checkCorrectPlacing() + { + int xz[]={0,1,0,-1,0}; + Block block, block2; + int meta,meta2; + for(int i =0;i<=3;i++) + { + block=worldObj.getBlock(xCoord+xz[i], yCoord, zCoord+xz[i+1]); + meta=worldObj.getBlockMetadata(xCoord+xz[i], yCoord, zCoord+xz[i+1]); + block2=worldObj.getBlock(xCoord+xz[i], yCoord+1, zCoord+xz[i+1]); + meta2=worldObj.getBlockMetadata(xCoord+xz[i], yCoord+1, zCoord+xz[i+1]); + if( + meta>0 && + meta2>0 && + (block==IHLMod.ic2Wood||block==IHLMod.rubberTreeBlock) && + (block2==IHLMod.ic2Wood||block2==IHLMod.rubberTreeBlock) + ) + { + short newFacing = this.getFacingFromXZ(xz[i], xz[i+1]); + this.setFacing(newFacing); + if(block2==IHLMod.ic2Wood) + { + worldObj.setBlock(xCoord+xz[i], yCoord+1, zCoord+xz[i+1],IHLMod.rubberTreeBlock,newFacing,3); + } + else + { + if(newFacing!=meta2) + { + return false; + } + } + this.currentTree=RUBBERTREE; + return checkGround(); + } + else if( + ((block==Blocks.log && meta==1) || + (block==IHLMod.spruceTreeBlock && meta>0)) && + ((block2==Blocks.log && meta2==1) || + (block2==IHLMod.spruceTreeBlock && meta2>0)) + ) + { + short newFacing = this.getFacingFromXZ(xz[i], xz[i+1]); + this.setFacing(newFacing); + if(block2==Blocks.log) + { + worldObj.setBlock(xCoord+xz[i], yCoord+1, zCoord+xz[i+1],IHLMod.spruceTreeBlock,newFacing,3); + } + else + { + if(newFacing!=meta2) + { + return false; + } + } + this.currentTree=SPRUCE; + return checkGround(); + } + } + return false; + } + + private boolean checkGround() + { + Block block; + int meta; + for(int h=0; h<=this.maxLeavesHeight; h++) + { + block=worldObj.getBlock(xCoord+mX(), yCoord-h, zCoord+mZ()); + meta=worldObj.getBlockMetadata(xCoord+mX(), yCoord-h, zCoord+mZ()); + if(!isLogBlock(block, meta)) + { + if(block==Blocks.dirt) + { + return true; + } + else + { + return false; + } + } + else if(meta<=0) + { + return false; + } + } + return false; + } + + private boolean isLogBlock(Block block, int meta) + { + switch(this.currentTree) + { + case RUBBERTREE: + return block==IHLMod.ic2Wood || block==IHLMod.rubberTreeBlock; + case SPRUCE: + return (block==Blocks.log && meta==1) || (block==IHLMod.spruceTreeBlock && meta>0); + } + return false; + } + + private boolean isLeavesBlock(Block block) + { + switch(this.currentTree) + { + case RUBBERTREE: + return block==IHLMod.ic2Leaves; + case SPRUCE: + return block==Blocks.leaves; + } + return false; + } + + private boolean isIncisedLog(Block block) + { + switch(this.currentTree) + { + case RUBBERTREE: + return block==IHLMod.rubberTreeBlock; + case SPRUCE: + return block==IHLMod.spruceTreeBlock; + } + return false; + } + + private void countRubberTreeLeaves() + { + this.leavesCounter=0; + int[][][] leavesMatrix=new int[this.maxLeavesWidth][this.maxLeavesWidth][this.maxLeavesHeight]; + for(int iy=1;iy=2) + { + break; + } + for(int sign=1;sign>=-1;sign-=2) + { + for(int ix=1;ix<=2;ix++) + { + + block=worldObj.getBlock(xCoord+mX()+ix*sign, yCoord+iy, zCoord+mZ()); + if(isLeavesBlock(block)) + { + this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+ix*sign, yCoord+iy, zCoord+mZ()); + leavesMatrix[2+ix*sign][2][iy-1]=1; + } + else + { + break; + } + } + for(int iz=1;iz<=2;iz++) + { + block=worldObj.getBlock(xCoord+mX(), yCoord+iy, zCoord+mZ()+iz*sign); + if(isLeavesBlock(block)) + { + this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX(), yCoord+iy, zCoord+mZ()+iz*sign); + leavesMatrix[2][2+iz*sign][iy-1]=1; + } + else + { + break; + } + } + } + for(int signx=1;signx>=-1;signx-=2) + { + for(int signz=1;signz>=-1;signz-=2) + { + if(leavesMatrix[2][2+signz][iy-1]==1||leavesMatrix[2+signx][2][iy-1]==1) + { + block=worldObj.getBlock(xCoord+mX()+signx, yCoord+iy, zCoord+mZ()+signz); + if(isLeavesBlock(block)) + { + this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+signx, yCoord+iy, zCoord+mZ()+signz); + leavesMatrix[2+signx][2+signz][iy-1]=1; + } + } + if(leavesMatrix[2+signx*2][2][iy-1]==1||leavesMatrix[2+signx][2+signz][iy-1]==1) + { + block=worldObj.getBlock(xCoord+mX()+signx*2, yCoord+iy, zCoord+mZ()+signz); + if(block==IHLMod.ic2Leaves) + { + this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+signx*2, yCoord+iy, zCoord+mZ()+signz); + leavesMatrix[2+signx*2][2+signz][iy-1]=1; + } + } + if(leavesMatrix[2][2+signz*2][iy-1]==1||leavesMatrix[2+signx][2+signz][iy-1]==1) + { + block=worldObj.getBlock(xCoord+mX()+signx, yCoord+iy, zCoord+mZ()+signz*2); + if(isLeavesBlock(block)) + { + this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+signx, yCoord+iy, zCoord+mZ()+signz*2); + leavesMatrix[2+signx][2+signz*2][iy-1]=1; + } + } + if(leavesMatrix[2+signx*2][2+signz][iy-1]==1||leavesMatrix[2+signx][2+signz*2][iy-1]==1) + { + block=worldObj.getBlock(xCoord+mX()+signx*2, yCoord+iy, zCoord+mZ()+signz*2); + if(isLeavesBlock(block)) + { + this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+signx*2, yCoord+iy, zCoord+mZ()+signz*2); + } + } + } + } + } + else + { + break; + } + } + } + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public String getInventoryName() { + return "sack"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + public float getRenderLiquidLevel() + { + return (float)this.visibleFluidAmount/(float)this.fluidTank.getCapacity(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) + { + if(this.canDrain(arg0, arg1.getFluid())) + { + FluidStack fStack = fluidTank.drain(arg1, arg2); + return fStack; + } + return null; + } + + @Override + public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2) + { + if(this.canDrain(arg0, null)) + { + FluidStack fStack = fluidTank.drain(arg1, arg2); + return fStack; + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[]{this.fluidTank.getInfo()}; + } +} \ No newline at end of file diff --git a/ihl/datanet/Contact.java b/ihl/datanet/Contact.java new file mode 100644 index 0000000..3d5b6af --- /dev/null +++ b/ihl/datanet/Contact.java @@ -0,0 +1,254 @@ +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(); + 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; + } + + @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; + private IDataNode sink; + private IDataNode source; + private double voltage; + private short frequency=0; + private double lastVoltage; + public boolean isGridValid=true; + private double total20TicksEU; + private int lastTickCounter=0; + + 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 new file mode 100644 index 0000000..3f88c55 --- /dev/null +++ b/ihl/datanet/DataNet.java @@ -0,0 +1,127 @@ +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 new file mode 100644 index 0000000..2222859 --- /dev/null +++ b/ihl/datanet/GuiInvisibleButton.java @@ -0,0 +1,21 @@ +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 { + + 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 new file mode 100644 index 0000000..c075b38 --- /dev/null +++ b/ihl/datanet/RedstoneSignalConverterContainer.java @@ -0,0 +1,101 @@ +package ihl.datanet; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.slot.SlotInvSlot; +import ihl.processing.invslots.SlotRedstoneConverterCableInvSlot; +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 new file mode 100644 index 0000000..b823f9f --- /dev/null +++ b/ihl/datanet/RedstoneSignalConverterGui.java @@ -0,0 +1,141 @@ +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 ic2.core.network.NetworkManager; +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 batterySlotPlus; + private GuiInvisibleButton batterySlotMinus; + 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; + } + + @Override + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + int i,i1; + batterySlotPlus = new GuiInvisibleButton(0, x+24, y+121, 3, 3, linksCoordinatesMap, buttonList); + batterySlotMinus = new GuiInvisibleButton(1, x+24, y+124, 3, 3, linksCoordinatesMap, buttonList); + 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/GlowningAirBlock.java b/ihl/enviroment/GlowningAirBlock.java new file mode 100644 index 0000000..e6dfb8e --- /dev/null +++ b/ihl/enviroment/GlowningAirBlock.java @@ -0,0 +1,34 @@ +package ihl.enviroment; + +import net.minecraft.block.BlockAir; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class GlowningAirBlock extends BlockAir +{ + public GlowningAirBlock() + { + super(); + this.setBlockName("glowningAir"); + this.setLightLevel(1.0f); + this.setBlockTextureName("glass"); + } + + @Override + public boolean isAir(IBlockAccess world, int x, int y, int z) + { + return true; + } + + @Override + public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) + { + if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) + { + entity.setFire(20); + } + } +} diff --git a/ihl/enviroment/LaserHitMirrorEventHandler.java b/ihl/enviroment/LaserHitMirrorEventHandler.java new file mode 100644 index 0000000..9baee2d --- /dev/null +++ b/ihl/enviroment/LaserHitMirrorEventHandler.java @@ -0,0 +1,48 @@ +package ihl.enviroment; + +import ic2.api.event.LaserEvent; +import ic2.core.item.tool.EntityMiningLaser; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class LaserHitMirrorEventHandler +{ + public LaserHitMirrorEventHandler(){} + + @SubscribeEvent + public void onLaserHit(LaserEvent.LaserHitsBlockEvent event) + { + TileEntity te = event.world.getTileEntity(event.x, event.y, event.z); + if(te instanceof MirrorTileEntity) + { + ForgeDirection mirrorDirection = ForgeDirection.getOrientation(((MirrorTileEntity)te).getFacing()); + Entity ls = event.lasershot; + if((ls.motionX*mirrorDirection.offsetX+ls.motionY*mirrorDirection.offsetY+ls.motionZ*mirrorDirection.offsetZ)<0) + { + if(mirrorDirection.offsetX!=0) + { + ls.motionX=-ls.motionX; + } + if(mirrorDirection.offsetY!=0) + { + ls.motionY=-ls.motionY; + } + if(mirrorDirection.offsetZ!=0) + { + ls.motionZ=-ls.motionZ; + } + if(!event.world.isRemote) + { + EntityMiningLaser tLaser = new EntityMiningLaser(event.world, event.owner, event.range, event.power, event.blockBreaks, event.explosive, 0, 0, ls.posY); + tLaser.setPosition(ls.posX, ls.posY, ls.posZ); + tLaser.setLaserHeading(ls.motionX, ls.motionY, ls.motionZ, 1d); + ls.setDead(); + event.world.spawnEntityInWorld(tLaser); + } + event.setCanceled(true); + } + } + } +} diff --git a/ihl/enviroment/LightBulbBlock.java b/ihl/enviroment/LightBulbBlock.java new file mode 100644 index 0000000..7175949 --- /dev/null +++ b/ihl/enviroment/LightBulbBlock.java @@ -0,0 +1,133 @@ +package ihl.enviroment; + +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; + +import ihl.IHLCreativeTab; +import ihl.items_blocks.IHLItemBlock; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class LightBulbBlock extends Block implements ITileEntityProvider +{ + public static GlowningAirBlock glowningAir; + + public LightBulbBlock(String unlocalizedName1) + { + super(Material.glass); + this.setStepSound(soundTypeGlass); + this.setBlockName(unlocalizedName1); + GameRegistry.registerBlock(this,IHLItemBlock.class, unlocalizedName1); + this.setHardness(0.3F); + this.setResistance(0.5F); + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockTextureName("glass"); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + public static void init() + { + glowningAir = new GlowningAirBlock(); + GameRegistry.registerBlock(glowningAir, "glowningAir"); + LightBulbBlock mblock = new LightBulbBlock("lightBulb"); + GameRegistry.registerTileEntity(LightBulbTileEntity.class, "lightBulb"); + SpotlightBlock sblock = new SpotlightBlock("spotlight"); + GameRegistry.registerTileEntity(SpotlightTileEntity.class, "spotlight"); + SpotlightTileEntity.createLightSphereVectors(); + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random random) + { + return 0; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + /** + * The type of render function that is called for this block + */ + @Override + public int getRenderType() + { + return -2; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) + { + TileEntity te = iBlockAccess.getTileEntity(x, y, z); + if(te!=null && te instanceof LightBulbTileEntity) + { + LightBulbTileEntity ate = (LightBulbTileEntity) te; + setBlockBoundsBasedOnFacing(ate.getFacing()); + } + } + + private void setBlockBoundsBasedOnFacing(int facing) + { + int var2 = facing & 7; + float var6 = 0.1875F; + float var7 = 0.5F; + + if (var2 == 0) + { + this.setBlockBounds(0.5F - var6, 1.0F - var7, 0.5F - var6, 0.5F + var6, 1.0F, 0.5F + var6); + } + else if (var2 == 1) + { + this.setBlockBounds(0.5F - var6, 0.0F, 0.5F - var6, 0.5F + var6, var7, 0.5F + var6); + } + else if (var2 == 2) + { + this.setBlockBounds(0.5F - var6, 0.5F - var6, 1.0F - var7, 0.5F + var6, 0.5F + var6, 1.0F); + } + else if (var2 == 3) + { + this.setBlockBounds(0.5F - var6, 0.5F - var6, 0.0F, 0.5F + var6, 0.5F + var6, var7); + } + else if (var2 == 4) + { + this.setBlockBounds(1.0F - var7, 0.5F - var6, 0.5F - var6, 1.0F, 0.5F + var6, 0.5F + var6); + } + else if (var2 == 5) + { + this.setBlockBounds(0.0F, 0.5F - var6, 0.5F - var6, var7, 0.5F + var6, 0.5F + var6); + } + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean isNormalCube() + { + return false; + } + + @Override + public TileEntity createNewTileEntity(World arg0, int arg1) + { + return new LightBulbTileEntity(); + } +} diff --git a/ihl/enviroment/LightBulbModel.java b/ihl/enviroment/LightBulbModel.java new file mode 100644 index 0000000..710d7fb --- /dev/null +++ b/ihl/enviroment/LightBulbModel.java @@ -0,0 +1,59 @@ +package ihl.enviroment; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class LightBulbModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer BaseON; + + public LightBulbModel() + { + textureWidth = 32; + textureHeight = 32; + setTextureOffset("Base.Shape1", 0, 19); + setTextureOffset("Base.TubeNorth", 20, 0); + setTextureOffset("Base.CylinderNorth", 0, 0); + setTextureOffset("Base.CylinderNorth2", 0, 0); + setTextureOffset("Base.SpyralNorth", 16, 24); + + setTextureOffset("BaseON.Shape1", 0, 19); + setTextureOffset("BaseON.TubeNorth", 20, 0); + setTextureOffset("BaseON.CylinderNorth", 0, 9); + setTextureOffset("BaseON.CylinderNorth2", 10, 10); + setTextureOffset("BaseON.SpyralNorth", 0, 24); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + Base.mirror = true; + Base.addBox("Shape1", -2F, -2F, 7F, 4, 4, 1); + Base.addTube("TubeNorth", -2F, -2F, 5F, 4, 4, 2, 0.8f, 1f, ForgeDirection.NORTH); + Base.drawFromInside = true; + Base.addTube("CylinderNorth", -1.5F, -1.5F, 0F, 3, 3, 7, 0f, 1f, ForgeDirection.NORTH); + Base.addTube("CylinderNorth2", -1F, -1F, 0.5F, 2, 2, 5, 0f, 1f, ForgeDirection.NORTH); + Base.drawFromInside = false; + Base.addTube("SpyralNorth", -0.5F, -0.5F, 0.5F, 1, 1, 7, 0f, 1f, ForgeDirection.NORTH); + + BaseON = new IHLModelRenderer(this, "BaseON"); + BaseON.setRotationPoint(0F, 16F, 0F); + BaseON.mirror = true; + BaseON.addBox("Shape1", -2F, -2F, 7F, 4, 4, 1); + BaseON.addTube("TubeNorth", -2F, -2F, 5F, 4, 4, 2, 0.8f, 1f, ForgeDirection.NORTH); + BaseON.drawFromInside = true; + BaseON.addTube("CylinderNorth", -1.5F, -1.5F, 0F, 3, 3, 7, 0f, 1f, ForgeDirection.NORTH); + BaseON.addTube("CylinderNorth2", -1F, -1F, 0.5F, 2, 2, 5, 0f, 1f, ForgeDirection.NORTH); + BaseON.drawFromInside = false; + BaseON.addTube("SpyralNorth", -0.5F, -0.5F, 0.5F, 1, 1, 7, 0f, 1f, ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/enviroment/LightBulbRender.java b/ihl/enviroment/LightBulbRender.java new file mode 100644 index 0000000..97104f7 --- /dev/null +++ b/ihl/enviroment/LightBulbRender.java @@ -0,0 +1,77 @@ +package ihl.enviroment; +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 LightBulbRender extends TileEntitySpecialRenderer{ +private LightBulbModel model = new LightBulbModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/lightBulb.png"); +private final float scale=1F/16F; + + public LightBulbRender() {} + + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + LightBulbTileEntity cte = (LightBulbTileEntity)tile; + int rotation = 0; + int rotationz = 0; + if(tile.getWorldObj() != null) + { + switch (cte.getFacing()) + { + case 0: + rotationz = 1; + break; + case 1: + rotationz = 3; + break; + case 2: + rotation = 2; + break; + case 5: + rotation = 3; + break; + case 3: + rotation = 0; + break; + case 4: + rotation = 1; + break; + default: + rotation = 0; + } + } + else + { + return; + } + model.BaseON.rotateAngleY=(float) (rotation*Math.PI/2); + model.BaseON.rotateAngleX=(float) (rotationz*Math.PI/2); + model.Base.rotateAngleY=(float) (rotation*Math.PI/2); + model.Base.rotateAngleX=(float) (rotationz*Math.PI/2); + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + bindTexture(tex); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1f, 1f, 1f, 1f); + if(cte.getActive()) + { + GL11.glDisable(GL11.GL_LIGHTING); + model.BaseON.render(scale); + } + else + { + model.Base.render(scale); + } + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/ihl/enviroment/LightBulbTileEntity.java b/ihl/enviroment/LightBulbTileEntity.java new file mode 100644 index 0000000..0d8f399 --- /dev/null +++ b/ihl/enviroment/LightBulbTileEntity.java @@ -0,0 +1,308 @@ +package ihl.enviroment; + +import java.util.List; +import java.util.Vector; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +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.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.ITickCallback; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; + +public class LightBulbTileEntity extends TileEntity implements IEnergySink, IWrenchable, INetworkDataProvider +{ + private boolean active = false; + private short facing = 0; + public boolean prevActive = false; + public short prevFacing = 0; + private double maxEnergy=1.1d; + private double energy; + public boolean addedToEnergyNet = false; + private boolean loaded = false; + private int ticker; + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.energy = nbttagcompound.getDouble("energy"); + this.facing = nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setDouble("energy", this.energy); + nbttagcompound.setShort("facing", this.facing); + } + + /** + * validates a tile entity + */ + @Override + public void validate() + { + super.validate(); + IC2.tickHandler.addSingleTickCallback(this.worldObj, new ITickCallback() + { + @Override + public void tickCallback(World world) + { + if (!LightBulbTileEntity.this.isInvalid() && world.blockExists(LightBulbTileEntity.this.xCoord, LightBulbTileEntity.this.yCoord, LightBulbTileEntity.this.zCoord)) + { + LightBulbTileEntity.this.onLoaded(); + + if (LightBulbTileEntity.this.enableUpdateEntity()) + { + world.loadedTileEntityList.add(LightBulbTileEntity.this); + } + } + } + }); + } + + /** + * invalidates a tile entity + */ + @Override + public void invalidate() + { + super.invalidate(); + if (this.loaded) + { + this.onUnloaded(); + } + } + + @Override + public void onChunkUnload() + { + super.onChunkUnload(); + if (this.loaded) + { + this.onUnloaded(); + } + } + + public void onLoaded() + { + if (IC2.platform.isSimulating() && !this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + this.loaded = true; + } + + public void onUnloaded() + { + if (IC2.platform.isSimulating()) + { + if(this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + this.active=false; + this.updateLightState(); + } + } + + @Override + public final boolean canUpdate() + { + return false; + } + + @Override + public void updateEntity() + { + if(++this.ticker % 4 == 0) + { + if(this.prevFacing != facing) + { + this.setFacing(facing); + } + if(this.energy>0) + { + this.energy--; + this.setActive(this.energy>0); + } + else + { + this.setActive(false); + } + } + } + + protected void updateLightState() + { + int x,y,z; + int xyz[] = {0,0,1,0,0,-1,0,0}; + Block block; + for(int i=0;i<=5;i++) + { + x=xCoord+xyz[i]; + y=yCoord+xyz[i+1]; + z=zCoord+xyz[i+2]; + block = this.worldObj.getBlock(x,y,z); + if(block.isAir(this.worldObj, x,y,z)) + { + if(this.getActive()) + { + worldObj.setBlock(x, y, z, LightBulbBlock.glowningAir); + } + if(!this.getActive()) + { + worldObj.setBlockToAir(x, y, z); + } + } + } + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, + ForgeDirection direction) { + switch(direction) + { + case UP: + return this.getFacing()==0; + case DOWN: + return this.getFacing()==1; + case SOUTH: + return this.getFacing()==2; + case NORTH: + return this.getFacing()==3; + case EAST: + return this.getFacing()==4; + case WEST: + return this.getFacing()==5; + default: + return false; + } + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return false; + } + + @Override + public short getFacing() { + return this.facing; + } + + @Override + public void setFacing(short facing1) + { + if (IC2.platform.isSimulating()&&this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + this.facing=facing1; + if(IC2.platform.isSimulating()) + { + if (this.prevFacing != facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + this.prevFacing = facing; + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public List getNetworkedFields() + { + Vector ret = new Vector(2); + ret.add("active"); + ret.add("facing"); + return ret; + } + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + @Override + public float getWrenchDropRate() { + return 1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("lightBulb"); + } + + @Override + public double getDemandedEnergy() + { + return this.maxEnergy-this.energy; + } + + @Override + public int getSinkTier() { + return 1; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) + { + if (this.energy >= this.maxEnergy) + { + return amount; + } + else + { + this.energy += amount; + return 0.0D; + } + } + + public boolean getActive() + { + return this.active; + } + + public void setActive(boolean active1) + { + this.active = active1; + + if (this.prevActive != active1) + { + IC2.network.get().updateTileEntityField(this, "active"); + updateLightState(); + } + this.prevActive = active1; + } + public void setActiveWithoutNotify(boolean active1) + { + this.active = active1; + this.prevActive = active1; + } +} diff --git a/ihl/enviroment/MirrorBlock.java b/ihl/enviroment/MirrorBlock.java new file mode 100644 index 0000000..fd1418e --- /dev/null +++ b/ihl/enviroment/MirrorBlock.java @@ -0,0 +1,222 @@ +package ihl.enviroment; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.utils.IHLUtils; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class MirrorBlock extends Block implements ITileEntityProvider { + + private String unlocalizedName; + private IIcon blockIconSide; + + public MirrorBlock(String unlocalizedName1) + { + super(Material.glass); + this.setBlockName(unlocalizedName1); + GameRegistry.registerBlock(this, unlocalizedName1); + this.setCreativeTab(IHLCreativeTab.tab); + this.setHardness(0.3f); + this.setResistance(0.3f); + this.setBlockTextureName("clay"); + } + + public static void init() + { + MirrorBlock mblock = new MirrorBlock("mirror"); + GameRegistry.registerTileEntity(MirrorTileEntity.class, "mirror"); + } + + @Override + public TileEntity createNewTileEntity(World arg0, int arg1) { + return new MirrorTileEntity(); + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) + { + TileEntity te = iBlockAccess.getTileEntity(x, y, z); + if(te!=null && te instanceof MirrorTileEntity) + { + MirrorTileEntity ate = (MirrorTileEntity) te; + setBlockBoundsBasedOnFacing(ate.getFacing()); + } + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te!=null && te instanceof MirrorTileEntity) + { + MirrorTileEntity ate = (MirrorTileEntity) te; + int var2 = ate.getFacing() & 7; + float var4 = 0.375F; + float var5 = 0.625F; + float var6 = 0.5F; + float var7 = 0.09F; + if (var2 == 0) + { + return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+1.0F - var7,z+ 0.5F - var6, x+0.5F + var6, y+1.0F, z+0.5F + var6); + } + else if (var2 == 1) + { + return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.0F,z+ 0.5F - var6, x+0.5F + var6, y+var7, z+0.5F + var6); + } + else if (var2 == 2) + { + return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.5F - var6,z+ 1.0F - var7, x+0.5F + var6, y+0.5F + var6, z+1.0F); + } + else if (var2 == 3) + { + return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.5F - var6,z+ 0.0F, x+0.5F + var6, y+0.5F + var6, z+var7); + } + else if (var2 == 4) + { + return AxisAlignedBB.getBoundingBox(x+1.0F - var7,y+ 0.5F - var6,z+0.5F - var6, x+1.0F, y+0.5F + var6, z+0.5F + var6); + } + else if (var2 == 5) + { + return AxisAlignedBB.getBoundingBox(x+0.0F,y+ 0.5F - var6, z+0.5F - var6, x+var7, y+0.5F + var6, z+0.5F + var6); + } + } + return null; + } + + private void setBlockBoundsBasedOnFacing(int facing) + { + int var2 = facing & 7; + float var4 = 0.375F; + float var5 = 0.625F; + float var6 = 0.5F; + float var7 = 0.09F; + if (var2 == 0) + { + this.setBlockBounds(0.5F - var6, 1.0F - var7, 0.5F - var6, 0.5F + var6, 1.0F, 0.5F + var6); + } + else if (var2 == 1) + { + this.setBlockBounds(0.5F - var6, 0.0F, 0.5F - var6, 0.5F + var6, var7, 0.5F + var6); + } + else if (var2 == 2) + { + this.setBlockBounds(0.5F - var6, 0.5F - var6, 1.0F - var7, 0.5F + var6, 0.5F + var6, 1.0F); + } + else if (var2 == 3) + { + this.setBlockBounds(0.5F - var6, 0.5F - var6, 0.0F, 0.5F + var6, 0.5F + var6, var7); + } + else if (var2 == 4) + { + this.setBlockBounds(1.0F - var7, 0.5F - var6, 0.5F - var6, 1.0F, 0.5F + var6, 0.5F + var6); + } + else if (var2 == 5) + { + this.setBlockBounds(0.0F, 0.5F - var6, 0.5F - var6, var7, 0.5F + var6, 0.5F + var6); + } + } + + /** + * Sets the block's bounds for rendering it as an item + */ + @Override + public void setBlockBoundsForItemRender() + { + float var1 = 0.5F; + float var2 = 0.5F; + float var3 = 0.05F; + this.setBlockBounds(0.5F - var1, 0.5F - var2, 0.5F - var3, 0.5F + var1, 0.5F + var2, 0.5F + var3); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + 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; + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null && t instanceof MirrorTileEntity) + { + MirrorTileEntity te = (MirrorTileEntity)t; + if(var6==1) + { + te.setFacing((short) 1); + } + else if(var6==3) + { + te.setFacing((short) 0); + } + else + { + switch(var7) + { + case 0: + te.setFacing((short) 2); + break; + case 1: + te.setFacing((short) 5); + break; + case 2: + te.setFacing((short) 3); + break; + case 3: + te.setFacing((short) 4); + break; + default: + break; + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":mirror"); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + this.dropBlockAsItem(world, x, y, z, IHLUtils.getThisModItemStack("dustGlass")); + } + /* @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z){ + TileEntity te = world.getTileEntity(x,y,z); + if(IC2.platform.isRendering()) + { + MirrorTileEntity rtu = (MirrorTileEntity)te; + if(player.getCurrentEquippedItem()==null) + { + IC2.platform.messagePlayer(player, "ic2.tooltip.mode", new Object[] {"Facing " + rtu.getFacing()}); + } + } + return false; + } + */ +} diff --git a/ihl/enviroment/MirrorRender.java b/ihl/enviroment/MirrorRender.java new file mode 100644 index 0000000..9e06f90 --- /dev/null +++ b/ihl/enviroment/MirrorRender.java @@ -0,0 +1,427 @@ +package ihl.enviroment; + +import java.nio.IntBuffer; +import java.util.Iterator; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; + +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.ARBFramebufferObject; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.EXTFramebufferObject; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL30; +import org.lwjgl.util.glu.GLU; +import org.lwjgl.util.glu.Project; + +import ihl.IHLMod; +import ihl.model.IHLBlockRenderer; +import ihl.utils.IHLRenderUtils; + +public class MirrorRender extends TileEntitySpecialRenderer{ +private int texture=-1; +private int fb=-1; +private static final IntBuffer textureIDBuffer = BufferUtils.createIntBuffer(1); +private static final float zNear = 1.5f;//1.5f +private static final float zFar = 0.1f;//0.1f +private final int textureWidth=512; +private final int textureHeight=512; +private final int[] xdepth; +private final int[] ydepth; +private final int[] textureU; +private final int[] textureV; +private final Minecraft mc; +private static final boolean useARB = true; + +public MirrorRender() +{ + xdepth=new int[] {0,0,1,1}; + ydepth=new int[] {0,1,1,0}; + textureU=new int[] {0,0,1,1}; + textureV=new int[]{0,1,1,0}; + mc=Minecraft.getMinecraft(); +} + +public void renderAModelAt(MirrorTileEntity tile, double x, double y, double z, float f) { + Tessellator tessellator=Tessellator.instance; + float[] mAxis = tile.getMirrorAxis(); + if(texture==-1) + { + GL11.glGenTextures(textureIDBuffer); + texture=textureIDBuffer.get(0); + fb=GL30.glGenFramebuffers(); + GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB8, textureWidth, textureHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer)null); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,GL11. GL_LINEAR); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + int depthBuffer = GL30.glGenRenderbuffers(); + GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthBuffer); + GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, textureWidth, textureHeight); + GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthBuffer); + GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0); + IntBuffer drawBuffs = BufferUtils.createIntBuffer(1); + drawBuffs.put(0, GL30.GL_COLOR_ATTACHMENT0); + GL20.glDrawBuffers(drawBuffs);// SPme parts of code here mindlessly taken from TheArni/Advanced-Graphics-Processing-Units. https://github.com/TheArni/Advanced-Graphics-Processing-Units/ + + if (GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE) + { + IHLMod.log.error("Something went wrong while creating frame buffer!"); + IHLMod.log.error(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER)); + } + else + { + IHLMod.log.info("FrameBuffer loaded correctly!"); + } + } + //Show reflection when: + //x>-1 when offsetX==-1 + //x<0 when offsetX==1 + if(tile.shouldReflect && + ((x>-0.8D && mAxis[3]==-1)|| + (x<-0.2 && mAxis[3]==1)|| + (y>-0.8D && mAxis[4]==-1)|| + (y<-0.2D && mAxis[4]==1)|| + (z>-0.8D && mAxis[5]==-1)|| + (z<-0.2D && mAxis[5]==1))) + { + GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb); + drawReflection(tile, x, y, z, f); + mc.entityRenderer.setupCameraTransform(f, 0); + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); + GL11.glPushMatrix(); + GL11.glTranslatef((float) x, (float) y , (float) z); + defineMeshAndTextureCoordinates(tile); + IHLRenderUtils.instance.enableAmbientLighting(); + drawMirrorFrame(tile); + IHLRenderUtils.instance.disableAmbientLighting(); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + } +} + + @Override + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) + { + this.renderAModelAt((MirrorTileEntity)par1TileEntity, par2, par4, par6, par8); + } + + private void drawReflection(MirrorTileEntity tile, double x, double y, double z, float f) + { + GL11.glViewport(0, 0, textureWidth, textureHeight); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + GL11.glColor4f(1f, 1f, 1f, 1f); + setMirrorView(tile, x, y, z); + IHLRenderUtils.instance.enableAmbientLighting(); + mc.renderGlobal.renderSky(f); + mc.renderGlobal.renderClouds(f); + IHLRenderUtils.instance.disableAmbientLighting(); + setMirrorView(tile, x, y, z); + GL11.glColor4f(1f, 1f, 1f, 1f); + bindTexture(TextureMap.locationBlocksTexture); + GL11.glTranslatef((-tile.xCoord), (-tile.yCoord), (-tile.zCoord)); + if (tile.displayListCache != -1) + { + GL11.glCallList(tile.displayListCache); + if(tile.needRenderUpdate) + { + IHLBlockRenderer.instance.refreshDisplayLists(tile.displayListCache, tile.bwc, tile.chunkCache); + tile.needRenderUpdate=false; + } + } + else if(tile.chunkCache!=null) + { + tile.displayListCache=GLAllocation.generateDisplayLists(1); + IHLBlockRenderer.instance.refreshDisplayLists(tile.displayListCache, tile.bwc, tile.chunkCache); + } + Iterator ientity = tile.reflectedEntity.iterator(); + while(ientity.hasNext()) + { + Entity centity = ientity.next(); + Render render = (Render) IHLMod.proxy.getRenderForEntityClass(centity.getClass()); + if(render!=null) + { + render.doRender(centity, centity.prevPosX, centity.prevPosY, centity.prevPosZ, 1f, f); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glColor4f(1f, 1f, 1f, 1f); + } + } + Iterator itentity = tile.reflectedTileEntity.iterator(); + while(itentity.hasNext()) + { + TileEntity te = itentity.next(); + if(TileEntityRendererDispatcher.instance.hasSpecialRenderer(te)) + { + TileEntitySpecialRenderer specialRenderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(te); + specialRenderer.renderTileEntityAt(te, te.xCoord, te.yCoord, te.zCoord, f); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + } + } + GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight()); + } + + private void defineMeshAndTextureCoordinates(MirrorTileEntity tile) + { + switch (tile.getFacing()) + { + case 0://up + xdepth[0]=1+tile.reflectExtensionRight; + xdepth[1]=1+tile.reflectExtensionRight; + xdepth[2]=0; + xdepth[3]=0; + ydepth[0]=0; + ydepth[1]=1+tile.reflectExtensionTop; + ydepth[2]=1+tile.reflectExtensionTop; + ydepth[3]=0; + textureU[0]=0; + textureU[1]=0; + textureU[2]=1; + textureU[3]=1; + textureV[0]=0; + textureV[1]=1; + textureV[2]=1; + textureV[3]=0; + break; + case 1://down + xdepth[0]=-tile.reflectExtensionRight; + xdepth[1]=-tile.reflectExtensionRight; + xdepth[2]=1; + xdepth[3]=1; + ydepth[0]=-tile.reflectExtensionTop; + ydepth[1]=1; + ydepth[2]=1; + ydepth[3]=-tile.reflectExtensionTop; + textureU[0]=0; + textureU[1]=0; + textureU[2]=1; + textureU[3]=1; + textureV[0]=0; + textureV[1]=1; + textureV[2]=1; + textureV[3]=0; + break; + case 2: + xdepth[0]=0; + xdepth[1]=0; + xdepth[2]=1+tile.reflectExtensionRight; + xdepth[3]=1+tile.reflectExtensionRight; + ydepth[0]=0; + ydepth[1]=1+tile.reflectExtensionTop; + ydepth[2]=1+tile.reflectExtensionTop; + ydepth[3]=0; + textureU[0]=0; + textureU[1]=0; + textureU[2]=1; + textureU[3]=1; + textureV[0]=0; + textureV[1]=1; + textureV[2]=1; + textureV[3]=0; + break; + case 3: + xdepth[0]=-tile.reflectExtensionRight; + xdepth[1]=1; + xdepth[2]=1; + xdepth[3]=-tile.reflectExtensionRight; + ydepth[0]=0; + ydepth[1]=0; + ydepth[2]=1+tile.reflectExtensionTop; + ydepth[3]=1+tile.reflectExtensionTop; + textureU[0]=1; + textureU[1]=0; + textureU[2]=0; + textureU[3]=1; + textureV[0]=0; + textureV[1]=0; + textureV[2]=1; + textureV[3]=1; + break; + case 4: + xdepth[0]=-tile.reflectExtensionRight; + xdepth[1]=1; + xdepth[2]=1; + xdepth[3]=-tile.reflectExtensionRight; + ydepth[0]=0; + ydepth[1]=0; + ydepth[2]=1+tile.reflectExtensionTop; + ydepth[3]=1+tile.reflectExtensionTop; + textureU[0]=1; + textureU[1]=0; + textureU[2]=0; + textureU[3]=1; + textureV[0]=0; + textureV[1]=0; + textureV[2]=1; + textureV[3]=1; + break; + case 5: + xdepth[0]=0; + xdepth[1]=0; + xdepth[2]=1+tile.reflectExtensionRight; + xdepth[3]=1+tile.reflectExtensionRight; + ydepth[0]=0; + ydepth[1]=1+tile.reflectExtensionTop; + ydepth[2]=1+tile.reflectExtensionTop; + ydepth[3]=0; + textureU[0]=0; + textureU[1]=0; + textureU[2]=1; + textureU[3]=1; + textureV[0]=0; + textureV[1]=1; + textureV[2]=1; + textureV[3]=0; + break; + default: + } + + } + + private void drawMirrorFrame(MirrorTileEntity tile) + { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); + GL11.glColor4f(1f, 1f, 1f, 1f); + GL11.glDisable(GL11.GL_BLEND); + Tessellator tessellator=Tessellator.instance; + tessellator.startDrawingQuads(); + for(int i=0;i bwc = new ArrayList(); + public final List reflectedEntity = new ArrayList(); + public final List reflectedTileEntity = new ArrayList(); + private int bwcListPos=0; + private int reflectedEntityListPos=0; + private int reflectedTileEntityListPos=0; + private int reflectionVolumePos=0; + boolean firstTick=true; + public int dnx,dpx,dny,dpy,dnz,dpz; + boolean shouldReflect=true; + int reflectExtensionRight=0; + int reflectExtensionTop=0; + int timer=0; + int blockReflectionUpdateTimer=0; + int reflectionVolumeSize=-1; + AxisAlignedBB reflectionArea; + int displayListCache=-1; + public ChunkCache chunkCache; + public boolean needRenderUpdate=false; + private int minX; + private int maxX; + private int minY; + private int maxY; + private int minZ; + private int maxZ; + private int lastBWCSize; + + public MirrorTileEntity() + {} + + @Override + public void updateEntityClient() + { + super.updateEntityClient(); + if(this.shouldReflect) + { + int i=0; + for(i=0;i20) + { + boolean isFirst=true; + TileEntity t = worldObj.getTileEntity(xCoord-mXT(),yCoord-mYT(), zCoord-mZT()); + if(t instanceof MirrorTileEntity) + { + if(((MirrorTileEntity)t).getFacing()==this.getFacing()) + { + isFirst=false; + } + } + t = worldObj.getTileEntity(xCoord-mXR(),yCoord-mYR(), zCoord-mZR()); + if(t instanceof MirrorTileEntity) + { + if(((MirrorTileEntity)t).getFacing()==this.getFacing()) + { + isFirst=false; + } + } + if(isFirst) + { + this.shouldReflect=true; + this.reflectExtensionTop=0; + this.reflectExtensionRight=0; + for(int i=1;i<=IHLMod.config.mirrorReflectionRange+2;i++) + { + t = worldObj.getTileEntity(xCoord+mXT()*i,yCoord+mYT()*i, zCoord+mZT()*i); + if(t instanceof MirrorTileEntity && ((MirrorTileEntity)t).getFacing()==this.getFacing()) + { + MirrorTileEntity te = (MirrorTileEntity) t; + te.shouldReflect=false; + this.reflectExtensionTop=i; + } + else + { + break; + } + } + a:for(int i0=1;i0<=IHLMod.config.mirrorReflectionRange+2;i0++) + { + for(int i=0;i<=this.reflectExtensionTop;i++) + { + t = worldObj.getTileEntity(xCoord+mXT()*i+mXR()*i0,yCoord+mYT()*i+mYR()*i0, zCoord+mZT()*i+mZR()*i0); + if(t instanceof MirrorTileEntity && ((MirrorTileEntity)t).getFacing()==this.getFacing()) + { + MirrorTileEntity te = (MirrorTileEntity) t; + te.shouldReflect=false; + } + else + { + break a; + } + } + this.reflectExtensionRight=i0; + } + } + if(this.reflectionArea!=null) + { + this.reflectedEntity.clear(); + this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.reflectionArea)); + this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityBoat.class, this.reflectionArea)); + this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityItem.class, this.reflectionArea)); + this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityMinecart.class, this.reflectionArea)); + } + timer=0; + } + if(firstTick && this.shouldReflect) + { + int ix,iy,iz; + int range=IHLMod.config.mirrorReflectionRange; + ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()); + bwc.clear(); + { + dpx = direction.offsetX==-1?0:1; + dnx = direction.offsetX==1?0:1; + dpy = direction.offsetY==-1?0:1; + dny = direction.offsetY==1?0:1; + dpz = direction.offsetZ==-1?0:1; + dnz = direction.offsetZ==1?0:1; + reflectionVolumeSize=(range*dnx+range*dpx+dnx)*(range*dny+range*dpy+dny)*(range*dnz+range*dpz+dnz); + reflectionArea = AxisAlignedBB.getBoundingBox(xCoord-range*dnx-1d, yCoord-range*dny-1d, zCoord-range*dnz-1d, xCoord+range*dpx+dnx+1d, yCoord+range*dpy+dny+1d, zCoord+range*dpz+dnz+1d); + minX = xCoord-range*dnx; + maxX = xCoord+range*dpx+dnx; + minY = Math.max(yCoord-range*dny,0); + maxY = Math.min(yCoord+range*dpy+dny,this.worldObj.getActualHeight()); + minZ = zCoord-range*dnz; + maxZ = zCoord+range*dpz+dnz; + chunkCache = new ChunkCache(worldObj, minX, minY, minZ, maxX, maxY, maxZ, 16); + for(ix=minX;ix=0) + { + bwc.add(new BlockWithCoordinates(block, ix, iy, iz, worldObj.getBlockMetadata(ix, iy, iz))); + } + } + + } + } + } + } + lastBWCSize=bwc.size(); + firstTick=false; + } + } + + private void dropMirrorStatusByDirection(ForgeDirection direction) + { + for(int i=1;i<=IHLMod.config.mirrorReflectionRange+2;i++) + { + TileEntity t = worldObj.getTileEntity(xCoord+direction.offsetX*i,yCoord+direction.offsetY*i, zCoord+direction.offsetZ*i); + if(t instanceof MirrorTileEntity) + { + MirrorTileEntity te = (MirrorTileEntity) t; + te.firstTick=false; + } + else + { + break; + } + } + + } + + private boolean isBlockVisible(Block block, int x, int y, int z) + { + if(block instanceof MirrorBlock) + { + ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()); + int x1=x*direction.offsetX; + int y1=y*direction.offsetY; + int z1=z*direction.offsetZ; + int x2=xCoord*direction.offsetX; + int y2=yCoord*direction.offsetY; + int z2=zCoord*direction.offsetZ; + return !(x1==x2 && y1==y2 && z1==z2); + } + if(block.shouldSideBeRendered(worldObj, x, y-1, z, 0)) + { + return true; + } + if(block.shouldSideBeRendered(worldObj, x, y+1, z, 1)) + { + return true; + } + if(block.shouldSideBeRendered(worldObj, x, y, z-1, 2)) + { + return true; + } + if(block.shouldSideBeRendered(worldObj, x, y, z+1, 3)) + { + return true; + } + if(block.shouldSideBeRendered(worldObj, x-1, y, z, 4)) + { + return true; + } + if(block.shouldSideBeRendered(worldObj, x+1, y, z, 5)) + { + return true; + } + return false; + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + @Override + public void setFacing(short side) + { + super.setFacing(side); + this.bwc.clear(); + this.firstTick=true; + } + + @Override + public float getWrenchDropRate() { + return 1F; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("mirror"); + } + + public float[] getMirrorAxis() + { + ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()); + int mx = direction.offsetX!=0?-1:1; + int my = direction.offsetY!=0?-1:1; + int mz = direction.offsetZ!=0?-1:1; + return new float[] {mx,my,mz,direction.offsetX,direction.offsetY,direction.offsetZ}; + } + + private void checkBWCList() + { + if(++this.bwcListPos>=bwc.size()) + { + this.bwcListPos=0; + } + if(!bwc.isEmpty()) + { + BlockWithCoordinates bwcEntry = bwc.get(bwcListPos); + if(bwcEntry.block!=worldObj.getBlock(bwcEntry.x, bwcEntry.y, bwcEntry.z)) + { + bwc.remove(bwcListPos); + } + } + } + + private void checkTileEntityList() + { + if(++this.reflectedTileEntityListPos>=reflectedTileEntity.size()) + { + this.reflectedTileEntityListPos=0; + } + if(!reflectedTileEntity.isEmpty()) + { + TileEntity entry = reflectedTileEntity.get(reflectedTileEntityListPos); + if(entry==null || entry.isInvalid() || entry!=worldObj.getTileEntity(entry.xCoord, entry.yCoord, entry.zCoord)) + { + reflectedTileEntity.remove(reflectedTileEntityListPos); + } + } + } + + private void checkReflectionVolume() + { + if(++this.reflectionVolumePos>=reflectionVolumeSize) + { + this.reflectionVolumePos=0; + if(lastBWCSize!=bwc.size()) + { + this.needRenderUpdate=true; + lastBWCSize=bwc.size(); + } + } + if(reflectionVolumeSize>0) + { + int range=IHLMod.config.mirrorReflectionRange; + //reflectionVolumePos = x+y*maxX+z*maxX*maxY; + int z = reflectionVolumePos / (maxX-minX) / (maxY-minY); + int y = (reflectionVolumePos % ((maxX-minX) * (maxY-minY)))/ (maxX-minX); + int x = reflectionVolumePos - y * (maxX-minX) - z * (maxX-minX) * (maxY-minY); + //for example position is 69 volume is 4*5*5=100, therefore z will be 69 / (4*5)=3 + //y will be (69 % (4*5))/4=9/4=2 + //x will be 69 - 2*4 - 3*4*5 = 69-8-60=1 + //for check 1+2*4+3*4*5=1+8+60 + int ix = minX+x; + int iy = minY+y; + int iz = minZ+z; + Block block = worldObj.getBlock(ix, iy, iz); + if(block!=null && !block.isAir(worldObj, ix, iy, iz) && isBlockVisible(block,ix,iy,iz)) + { + TileEntity te = worldObj.getTileEntity(ix, iy, iz); + if(te!=null && !te.isInvalid() && !reflectedTileEntity.contains(te) && TileEntityRendererDispatcher.instance.hasSpecialRenderer(te) && !(te instanceof MirrorTileEntity)) + { + reflectedTileEntity.add(te); + } + if(block.getRenderType()>=0) + { + BlockWithCoordinates bwc1 = new BlockWithCoordinates(block, ix, iy, iz, worldObj.getBlockMetadata(ix, iy, iz)); + if(!bwc.contains(bwc1)) + { + bwc.add(bwc1); + } + } + } + } + } + + private int mXR() + { + switch(this.getFacing()) + { + case 0: + return 1; + case 1: + return -1; + case 2: + return 1; + case 3: + return -1; + default: + return 0; + } + } + + private int mYR() + { + return 0; + } + + private int mZR() + { + 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 AxisAlignedBB getRenderBoundingBox() + { + double xMinD=(double)this.xCoord-this.reflectExtensionRight*Math.abs(this.mXR())-this.reflectExtensionTop*Math.abs(this.mXT()); + double xMaxD=(double)this.xCoord+this.reflectExtensionRight*Math.abs(this.mXR())+this.reflectExtensionTop*Math.abs(this.mXT())+1d; + double yMinD=(double)this.yCoord-this.reflectExtensionRight*Math.abs(this.mYR())-this.reflectExtensionTop*Math.abs(this.mYT()); + double yMaxD=(double)this.yCoord+this.reflectExtensionRight*Math.abs(this.mYR())+this.reflectExtensionTop*Math.abs(this.mYT())+1d; + double zMinD=(double)this.zCoord-this.reflectExtensionRight*Math.abs(this.mZR())-this.reflectExtensionTop*Math.abs(this.mZT()); + double zMaxD=(double)this.zCoord+this.reflectExtensionRight*Math.abs(this.mZR())+this.reflectExtensionTop*Math.abs(this.mZT())+1d; + return AxisAlignedBB.getBoundingBox(xMinD, yMinD, zMinD, xMaxD, yMaxD, zMaxD); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} \ No newline at end of file diff --git a/ihl/enviroment/SpotlightBlock.java b/ihl/enviroment/SpotlightBlock.java new file mode 100644 index 0000000..2cabecf --- /dev/null +++ b/ihl/enviroment/SpotlightBlock.java @@ -0,0 +1,108 @@ +package ihl.enviroment; + +import ic2.core.IC2; +import ihl.IHLCreativeTab; +import ihl.items_blocks.IHLItemBlock; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; + +public class SpotlightBlock extends Block implements ITileEntityProvider +{ + + public SpotlightBlock(String unlocalizedName1) + { + super(Material.glass); + this.setStepSound(soundTypeGlass); + this.setBlockName(unlocalizedName1); + GameRegistry.registerBlock(this,IHLItemBlock.class, unlocalizedName1); + this.setHardness(0.3F); + this.setResistance(0.5F); + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockTextureName("glass"); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + @Override + public int quantityDropped(Random random) + { + return 0; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + /** + * The type of render function that is called for this block + */ + @Override + public int getRenderType() + { + return -2; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean isNormalCube() + { + return false; + } + + @Override + public TileEntity createNewTileEntity(World arg0, int arg1) + { + return new SpotlightTileEntity(); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + TileEntity t = world.getTileEntity(x, y, z); + if(IC2.platform.isSimulating() && t instanceof SpotlightTileEntity) + { + SpotlightTileEntity te = (SpotlightTileEntity)t; + te.setDirectionVector(player); + } + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z) + { + TileEntity te = world.getTileEntity(x,y,z); + if(IC2.platform.isSimulating() && te instanceof SpotlightTileEntity) + { + ((SpotlightTileEntity)te).setDirectionVector(player); + return true; + } + return false; + } + + + + +} \ No newline at end of file diff --git a/ihl/enviroment/SpotlightModel.java b/ihl/enviroment/SpotlightModel.java new file mode 100644 index 0000000..057bf94 --- /dev/null +++ b/ihl/enviroment/SpotlightModel.java @@ -0,0 +1,71 @@ +package ihl.enviroment; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; + + +public class SpotlightModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart1; + IHLModelRenderer RotatingPart2; + IHLModelRenderer RotatingPart3Halo; + + public SpotlightModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("RotatingPart1.Shape3", 0, 0); + setTextureOffset("RotatingPart1.Shape2", 0, 0); + setTextureOffset("RotatingPart1.Shape4", 0, 0); + setTextureOffset("RotatingPart2.Shape5", 0, 15); + setTextureOffset("RotatingPart2.Shape6", 13, 14); + setTextureOffset("RotatingPart2.Shape7", 7, 15); + setTextureOffset("RotatingPart2.Shape8", 14, 8); + setTextureOffset("RotatingPart2.Shape9", 6, 8); + setTextureOffset("RotatingPart2.Shape10", 0, 23); + setTextureOffset("RotatingPart2.Shape11", 0, 0); + setTextureOffset("RotatingPart2.Shape12", 0, 0); + setTextureOffset("RotatingPart3Halo.Shape13", 32, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = false; + Base.addBox("Shape1", -7F, -7F, 7F, 14, 14, 1); + RotatingPart1 = new IHLModelRenderer(this, "RotatingPart1"); + RotatingPart1.setRotationPoint(0F, 16F, 0F); + setRotation(RotatingPart1, 0F, 0F, 0F); + RotatingPart1.mirror = false; + RotatingPart1.addBox("Shape3", 5F, -1F, -1F, 1, 2, 8); + RotatingPart1.addBox("Shape2", -6F, -1F, -1F, 1, 2, 8); + RotatingPart1.addBox("Shape4", -5F, -1F, 6F, 10, 2, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(0F, 16F, 0F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = false; + RotatingPart2.addBox("Shape5", -4F, -4F, -6F, 7, 1, 7); + RotatingPart2.addBox("Shape6", -4F, -4F, 1F, 8, 8, 1); + RotatingPart2.addBox("Shape7", -3F, 3F, -6F, 7, 1, 7); + RotatingPart2.addBox("Shape8", 3F, -4F, -6F, 1, 7, 7); + RotatingPart2.addBox("Shape9", -4F, -3F, -6F, 1, 7, 7); + RotatingPart2.addBox("Shape10", -3F, -3F, -5F, 6, 6, 1); + RotatingPart2.addBox("Shape11", 4F, -1F, -1F, 1, 2, 2); + RotatingPart2.addBox("Shape12", -5F, -1F, -1F, 1, 2, 2); + RotatingPart3Halo = new IHLModelRenderer(this, "RotatingPart3Halo"); + RotatingPart3Halo.setRotationPoint(0F, 16F, 0F); + setRotation(RotatingPart3Halo, 0F, 0F, 0F); + RotatingPart3Halo.mirror = false; + RotatingPart3Halo.addBox("Shape13", -8F, -8F, -6.1F, 16, 16, 0); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/enviroment/SpotlightRender.java b/ihl/enviroment/SpotlightRender.java new file mode 100644 index 0000000..e38e251 --- /dev/null +++ b/ihl/enviroment/SpotlightRender.java @@ -0,0 +1,109 @@ +package ihl.enviroment; +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; +import ihl.utils.IHLRenderUtils; + +public class SpotlightRender extends TileEntitySpecialRenderer{ +private SpotlightModel model = new SpotlightModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/spotlight.png"); +private final float scale=1F/16F; + + public SpotlightRender() {} + + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + SpotlightTileEntity cte = (SpotlightTileEntity)tile; + int rotation = 0; + int rotationz = 0; + if(tile.getWorldObj() != null) + { + switch (cte.getFacing()) + { + case 0: + rotationz = 1; + break; + case 1: + rotationz = 3; + break; + case 2: + rotation = 2; + break; + case 5: + rotation = 3; + break; + case 3: + rotation = 0; + break; + case 4: + rotation = 1; + break; + default: + rotation = 0; + } + } + else + { + return; + } + model.Base.rotateAngleY=(float) (rotation*Math.PI/2); + model.Base.rotateAngleX=(float) (rotationz*Math.PI/2); + model.RotatingPart1.rotateAngleY=(float) (rotation*Math.PI/2); + model.RotatingPart1.rotateAngleX=(float) (rotationz*Math.PI/2); + model.RotatingPart2.rotateAngleY=(float) (rotation*Math.PI/2); + model.RotatingPart2.rotateAngleX=(float) (rotationz*Math.PI/2); + model.RotatingPart3Halo.rotateAngleY=(float) (rotation*Math.PI/2); + model.RotatingPart3Halo.rotateAngleX=(float) (rotationz*Math.PI/2); + model.RotatingPart2.rotateAngleX+=cte.rotationPitch; + model.RotatingPart3Halo.rotateAngleX+=cte.rotationPitch; + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + bindTexture(tex); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1f, 1f, 1f, 1f); + model.Base.render(scale); + GL11.glTranslatef(model.RotatingPart1.rotationPointX*scale, model.RotatingPart1.rotationPointY*scale, model.RotatingPart1.rotationPointZ*scale); + switch(cte.getFacing()) + { + case 0: + GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + break; + case 1: + GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + break; + case 2: + GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + break; + case 3: + GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + break; + case 4: + GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + break; + case 5: + GL11.glRotatef(cte.rotationYaw * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + break; + } + GL11.glTranslatef(-model.RotatingPart1.rotationPointX*scale, -model.RotatingPart1.rotationPointY*scale, -model.RotatingPart1.rotationPointZ*scale); + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + if(cte.getActive()) + { + IHLRenderUtils.instance.enableAmbientLighting(); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + model.RotatingPart3Halo.render(scale); + IHLRenderUtils.instance.disableAmbientLighting(); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/ihl/enviroment/SpotlightTileEntity.java b/ihl/enviroment/SpotlightTileEntity.java new file mode 100644 index 0000000..04b340b --- /dev/null +++ b/ihl/enviroment/SpotlightTileEntity.java @@ -0,0 +1,334 @@ +package ihl.enviroment; +import ic2.api.network.INetworkTileEntityEventListener; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.IHLModInfo; +import ihl.i_hate_liquids.XYZ; +import ihl.utils.IHLUtils; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Vec3; +import net.minecraftforge.common.util.ForgeDirection; + +public class SpotlightTileEntity extends LightBulbTileEntity implements INetworkTileEntityEventListener +{ + Vec3 directionVector=Vec3.createVectorHelper(1, 0, 0); + private static final int maxLightRange=128; + private final Set xyzGlowningAir = new HashSet(); + private static final Set lightSphereVectors = new HashSet(); + public float rotationPitch=0f; + public float rotationYaw=0f; + public float prevRotationPitch=0f; + public float prevRotationYaw=0f; + boolean needLightTargetUpdate=false; + + public static void createLightSphereVectors() + { + for(double y=-1d;y<=1d;y+=0.2d) + { + double sqr = 1-y*y; + double x,z; + for(double alpha=0;alpha getNetworkedFields() + { + List list = super.getNetworkedFields(); + list.add("rotationPitch"); + list.add("rotationYaw"); + return list; + } + + public void setLightOn() + { + Iterator gai = xyzGlowningAir.iterator(); + while(gai.hasNext()) + { + XYZ xyz = gai.next(); + Block block = worldObj.getBlock(xyz.x,xyz.y,xyz.z); + if(block==Blocks.air || block.isAir(this.worldObj, xyz.x,xyz.y,xyz.z)) + { + worldObj.setBlock(xyz.x, xyz.y, xyz.z, LightBulbBlock.glowningAir); + } + } + } + + public void setLightOff() + { + Iterator gai = xyzGlowningAir.iterator(); + while(gai.hasNext()) + { + XYZ xyz = gai.next(); + Block block = worldObj.getBlock(xyz.x,xyz.y,xyz.z); + if(block == LightBulbBlock.glowningAir) + { + worldObj.setBlockToAir(xyz.x, xyz.y, xyz.z); + } + } + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(needLightTargetUpdate) + { + this.generateGlowningAirList(); + this.updateLightState(); + needLightTargetUpdate=false; + } + if(this.prevRotationPitch!=this.rotationPitch) + { + IC2.network.get().updateTileEntityField(this, "rotationPitch"); + this.prevRotationPitch=this.rotationPitch; + } + if(this.prevRotationYaw!=this.rotationYaw) + { + IC2.network.get().updateTileEntityField(this, "rotationYaw"); + this.prevRotationYaw=this.rotationYaw; + } + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("spotlight"); + } + + public void setDirectionVector(EntityLivingBase player) + { + ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); + Vec3 lookVec = player.getLookVec(); + if(lookVec.xCoord*dir.offsetX+lookVec.yCoord*dir.offsetY+lookVec.zCoord*dir.offsetZ<0) + { + double x=player.posX-this.xCoord-0.5D; + double y=player.posY+player.getEyeHeight()-this.yCoord-0.5D; + double z=player.posZ-this.zCoord-0.5D; + double d=Math.sqrt(x*x+y*y+z*z); + directionVector=Vec3.createVectorHelper(x/d, y/d, z/d); + } + else + { + directionVector=player.getLookVec(); + } + this.rotationPitch=this.getVectorPitchAngle(directionVector); + this.rotationYaw=this.getVectorYawAngle(directionVector); + this.needLightTargetUpdate=true; + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + + private void generateGlowningAirList() + { + this.setLightOff(); + xyzGlowningAir.clear(); + Iterator lvi = lightSphereVectors.iterator(); + while(lvi.hasNext()) + { + traceVectorToLastAirBlock(lvi.next()); + } + } + + private void traceVectorToLastAirBlock(Vec3 vector) + { + double dx=directionVector.xCoord; + double dy=directionVector.yCoord; + double dz=directionVector.zCoord; + double dx1=vector.xCoord; + double dy1=vector.yCoord; + double dz1=vector.zCoord; + if(2*dx*dx1+dx1*dx1+2*dy*dy1+dy1*dy1+2*dz*dz1+dz1*dz1>0d) + { + double x1=xCoord+0.5d; + double y1=yCoord+0.5d; + double z1=zCoord+0.5d; + int xi1=xCoord; + int yi1=yCoord; + int zi1=zCoord; + int airx=xCoord; + int airy=yCoord; + int airz=zCoord; + for(int i=0;i=0) + { + return (float)(Math.acos(x/Math.sqrt(x*x+z*z))-Math.PI/2); + } + else + { + return (float)(-Math.acos(x/Math.sqrt(x*x+z*z))-Math.PI/2); + } + case 1: + if(z>=0) + { + return (float)(Math.acos(x/Math.sqrt(x*x+z*z))-Math.PI/2); + } + else + { + return (float)(-Math.acos(x/Math.sqrt(x*x+z*z))-Math.PI/2); + } + case 2: + if(y>=0) + { + return (float)(-Math.acos(x/Math.sqrt(x*x+y*y))-Math.PI/2); + } + else + { + return (float)(Math.acos(x/Math.sqrt(x*x+y*y))-Math.PI/2); + } + case 3: + if(y>=0) + { + return (float)(-Math.acos(x/Math.sqrt(x*x+y*y))-Math.PI/2); + } + else + { + return (float)(Math.acos(x/Math.sqrt(x*x+y*y))-Math.PI/2); + } + case 4: + if(y>=0) + { + return (float)(-Math.acos(z/Math.sqrt(z*z+y*y))-Math.PI/2); + } + else + { + return (float)(Math.acos(z/Math.sqrt(z*z+y*y))-Math.PI/2); + } + case 5: + if(y>=0) + { + return (float)(-Math.acos(z/Math.sqrt(z*z+y*y))-Math.PI/2); + } + else + { + return (float)(Math.acos(z/Math.sqrt(z*z+y*y))-Math.PI/2); + } + default: + return 0f; + } + } + + @Override + public void onNetworkEvent(int event) + { + this.worldObj.playSound(xCoord+0.5d, yCoord+0.5d, zCoord+0.5d, IHLModInfo.MODID+":spotlightRotating", 10F, 1f, true); + } +} + + +/* -Y DOWN(0, -1, 0) 0 +/* +Y UP(0, 1, 0) 1 +/* -Z NORTH(0, 0, -1) 2 +/* +Z SOUTH(0, 0, 1) 3 +/* -X WEST(-1, 0, 0), 4 +/* +X EAST(1, 0, 0), 5 +//VALID_DIRECTIONS = {DOWN, UP, NORTH, SOUTH, WEST, EAST};*/ diff --git a/ihl/flexible_cable/AnchorBlock.java b/ihl/flexible_cable/AnchorBlock.java new file mode 100644 index 0000000..7c12b49 --- /dev/null +++ b/ihl/flexible_cable/AnchorBlock.java @@ -0,0 +1,215 @@ +package ihl.flexible_cable; +import ic2.core.IC2; +import ic2.core.item.tool.ItemToolWrench; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.enviroment.LightBulbTileEntity; +import ihl.utils.IHLUtils; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class AnchorBlock extends Block implements ITileEntityProvider { + + private String unlocalizedName; + private IIcon blockIconSide; + + public AnchorBlock(String unlocalizedName1) + { + super(Material.circuits); + this.setBlockName(unlocalizedName1); + GameRegistry.registerBlock(this, unlocalizedName1); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @Override + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) + { + if(!world.isRemote) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te!=null && te instanceof AnchorTileEntity) + { + AnchorTileEntity ate = (AnchorTileEntity) te; + ate.invalidate(); + for(short i=0;i<6;i++) + { + ate.energyNetNodes[i].removeAttachedChains(); + } + } + } + super.onBlockPreDestroy(world, x, y, z, meta); + } + + @Override + public TileEntity createNewTileEntity(World arg0, int arg1) { + return new AnchorTileEntity(); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag){} + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + public int getRenderType() + { + return -2; + } + + @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) + { + AnchorTileEntity tebh = (AnchorTileEntity) te; + facing=tebh.getFacing(); + } + + switch (mask[facing*6+side]) + { + case 0: + return this.blockIcon; + case 1: + return this.blockIconSide; + case 2: + return this.blockIconSide; + case 3: + return this.blockIconSide; + case 4: + return this.blockIconSide; + case 5: + return this.blockIconSide; + default: + return this.blockIconSide; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + + switch(side) + { + case 0: + return this.blockIconSide; + case 1: + return this.blockIconSide; + case 2: + return this.blockIconSide; + case 3: + return this.blockIcon; + case 4: + return this.blockIconSide; + case 5: + return this.blockIconSide; + default: + return this.blockIconSide; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":junctionBoxFront"); + this.blockIconSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":junctionBox"); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) + { + TileEntity te = iBlockAccess.getTileEntity(x, y, z); + if(te!=null && te instanceof AnchorTileEntity) + { + AnchorTileEntity ate = (AnchorTileEntity) te; + float portSize=0.1f; + boolean firstBB=false; + float bbMinX = 1f; + float bbMaxX = 0f; + float bbMinY = 1f; + float bbMaxY = 0f; + float bbMinZ = 1f; + float bbMaxZ = 0f; + for(short i=0;i<6;i++) + { + if(ate.hasCableOnSide[i]) + { + float pMinX = (float) (ate.energyNetNodes[i].getPortPos(null)[0]-portSize-x); + float pMaxX = (float) (ate.energyNetNodes[i].getPortPos(null)[0]+portSize-x); + float pMinY = (float) (ate.energyNetNodes[i].getPortPos(null)[1]-portSize-y); + float pMaxY = (float) (ate.energyNetNodes[i].getPortPos(null)[1]+portSize-y); + float pMinZ = (float) (ate.energyNetNodes[i].getPortPos(null)[2]-portSize-z); + float pMaxZ = (float) (ate.energyNetNodes[i].getPortPos(null)[2]+portSize-z); + bbMinX=Math.min(pMinX,bbMinX); + bbMaxX=Math.max(pMaxX,bbMaxX); + bbMinY=Math.min(pMinY,bbMinY); + bbMaxY=Math.max(pMaxY,bbMaxY); + bbMinZ=Math.min(pMinZ,bbMinZ); + bbMaxZ=Math.max(pMaxZ,bbMaxZ); + } + } + this.setBlockBounds(bbMinX, bbMinY, bbMinZ, bbMaxX, bbMaxY, bbMaxZ); + } + } + /* + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z){ + TileEntity te = world.getTileEntity(x,y,z); + if(IC2.platform.isSimulating()) + { + AnchorTileEntity ate = (AnchorTileEntity) te; + short facing = IHLUtils.getFacingFromPlayerView(player, true); + System.out.println(ate.energyNetNodes[facing].getGridID()); + System.out.println(ate.getOfferedEnergy()); + } + return false; + }*/ + +} diff --git a/ihl/flexible_cable/AnchorTileEntity.java b/ihl/flexible_cable/AnchorTileEntity.java new file mode 100644 index 0000000..b9057ba --- /dev/null +++ b/ihl/flexible_cable/AnchorTileEntity.java @@ -0,0 +1,446 @@ +package ihl.flexible_cable; + +import ic2.api.energy.EnergyNet; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.energy.tile.IEnergySource; +import ic2.core.ExplosionIC2; +import ic2.core.IC2; +import ic2.core.block.TileEntityBlock; +import ihl.IHLMod; +import ihl.interfaces.ICableHolder; +import ihl.interfaces.IEnergyNetNode; +import ihl.interfaces.IMultiPowerCableHolder; +import ihl.utils.IHLUtils; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import net.minecraft.entity.EntityLivingBase; +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.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +public class AnchorTileEntity extends TileEntityBlock implements IEnergySink, IEnergySource, IMultiPowerCableHolder +{ + public boolean addedToEnergyNet=false; + public final Set sacrifices = new HashSet(); + public SubAnchorEnergyNetNode[] energyNetNodes = new SubAnchorEnergyNetNode[6]; + public boolean[] hasCableOnSide=new boolean [] {false,false,false,false,false,false}; + public int checksum=-1; + public boolean checkCables=true; + + public AnchorTileEntity() + { + super(); + for(short i=0;i<6;i++) + { + energyNetNodes[i] = new SubAnchorEnergyNetNode(this, i); + } + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("hasCableOnSide"); + return fields; + } + + @Override + public void onLoaded() + { + super.onLoaded(); + for(short i=0;i<6;i++) + { + energyNetNodes[i].onLoaded(); + } + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public void onUnloaded() + { + if (IC2.platform.isSimulating()) + { + if(this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + } + } + + @Override + public boolean wrenchCanRemove(EntityPlayer var1) + { + return false; + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + if(!sacrifices.isEmpty()) + { + Iterator victimIterator = sacrifices.iterator(); + while(victimIterator.hasNext()) + { + TileEntity sacrifice = victimIterator.next(); + ExplosionIC2 explosion = new ExplosionIC2(this.worldObj, null, sacrifice.xCoord+0.5D, sacrifice.yCoord+0.5D, sacrifice.zCoord+0.5D, 3F, 0.3F, ExplosionIC2.Type.Normal, null, 0); + explosion.doExplosion(); + sacrifices.remove(sacrifice); + } + + } + int newchecksum=0; + for(short i=0;i<6;i++) + { + if(this.hasCableOnSide[i]) + { + newchecksum++; + } + } + if(newchecksum!=checksum) + { + IC2.network.get().updateTileEntityField(this, "hasCableOnSide"); + checksum=newchecksum; + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + NBTTagList energyNetNodeNBTList = new NBTTagList(); + for(SubAnchorEnergyNetNode node:this.energyNetNodes) + { + energyNetNodeNBTList.appendTag(node.writeToNBT()); + } + nbt.setTag("energyNetNodes", energyNetNodeNBTList); + nbt.setBoolean("checkCables", this.checkCables); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + if(!nbt.hasKey("energyNetNodes")) + { + short facing = nbt.getShort("facing"); + int gridID=nbt.getInteger("gridID"); + this.energyNetNodes[facing].setGrid(gridID); + NBTTagList cableNBTList=nbt.getTagList("cableList", 10); + for(int i=0;i500D) + { + Set teset = new HashSet(); + ForgeDirection direction = ForgeDirection.getOrientation(i).getOpposite(); + TileEntity te = EnergyNet.instance.getNeighbor(this, direction); + teset.add(te); + TileEntity te1 = this.getSink(te, teset); + if(te1 instanceof IEnergyNetNode) + { + if(((IEnergyNetNode)te1).getMaxAllowableVoltage()>=voltage) + { + return; + } + } + if(te1!=null) + { + sacrifices.add(te1); + } + } + if(amount<=0d) + { + break; + } + } + } + + @Override + public int getSourceTier() { + return 4; + } + + @Override + public double getDemandedEnergy() + { + double amount=0d; + for(short i=0;i<6;i++) + { + amount+=energyNetNodes[i].getDemandedEnergy(); + } + return amount; + } + + @Override + public int getSinkTier() { + return 4; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) + { + switch(directionFrom) + { + case UP: + return this.energyNetNodes[0].injectEnergyToGrid(amount); + case DOWN: + return this.energyNetNodes[1].injectEnergyToGrid(amount); + case SOUTH: + return this.energyNetNodes[2].injectEnergyToGrid(amount); + case NORTH: + return this.energyNetNodes[3].injectEnergyToGrid(amount); + case EAST: + return this.energyNetNodes[4].injectEnergyToGrid(amount); + case WEST: + return this.energyNetNodes[5].injectEnergyToGrid(amount); + default: + return amount; + } + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return null; + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return !this.wrenchCanRemove(entityPlayer); + } + + public TileEntity getSink(TileEntity te, Set teset) + { + teset.add(te); + while(te!=null && !(te instanceof IEnergySink)) + { + TileEntity te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.NORTH); + if(te1==null || teset.contains(te1)) + { + te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.SOUTH); + } + else + { + TileEntity te2 = this.getSink(te1, teset); + if(te2!=null) + { + return te2; + } + } + if(te1==null || teset.contains(te1)) + { + te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.UP); + } + else + { + TileEntity te2 = this.getSink(te1, teset); + if(te2!=null) + { + return te2; + } + } + if(te1==null || teset.contains(te1)) + { + te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.DOWN); + } + else + { + TileEntity te2 = this.getSink(te1, teset); + if(te2!=null) + { + return te2; + } + } + if(te1==null || teset.contains(te1)) + { + te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.WEST); + } + else + { + TileEntity te2 = this.getSink(te1, teset); + if(te2!=null) + { + return te2; + } + } + if(te1==null || teset.contains(te1)) + { + te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.EAST); + } + else + { + TileEntity te2 = this.getSink(te1, teset); + if(te2!=null) + { + return te2; + } + } + if(te1!=null) + { + teset.add(te1); + } + te=te1; + } + if(te instanceof IEnergySink) + { + return te; + } + else + { + return null; + } + } + + public void checkIfNoCablesLeft() + { + boolean noCables=true; + for(SubAnchorEnergyNetNode sen:energyNetNodes) + { + if(!sen.getCableList().isEmpty()) + { + noCables=false; + } + } + if(noCables) + { + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } + } + + public boolean isCableRemoved(int chainUniqueID) + { + if(!checkCables) + { + return false; + } + for(SubAnchorEnergyNetNode sen:energyNetNodes) + { + if(!sen.isCableRemoved(chainUniqueID)) + { + return false; + } + } + return true; + } + + @Override + public IEnergyNetNode getEnergyNetNode(short facing) + { + return energyNetNodes[facing]; + } + + @Override + public short getSide(EntityPlayer player) + { + return IHLUtils.getFacingFromPlayerView(player, true); + } + + @Override + public void removeAttachedChains() + { + for(short i=0;i<6;i++) + { + energyNetNodes[i].removeAttachedChains(); + } + + } +} diff --git a/ihl/flexible_cable/BatterySwitchUnitModel.java b/ihl/flexible_cable/BatterySwitchUnitModel.java new file mode 100644 index 0000000..7919950 --- /dev/null +++ b/ihl/flexible_cable/BatterySwitchUnitModel.java @@ -0,0 +1,48 @@ +package ihl.flexible_cable; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +// Date: 07.04.2015 18:24:15 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +public class BatterySwitchUnitModel extends ModelBase +{ + //fields + IHLModelRenderer Piece1; + + public BatterySwitchUnitModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Piece1.Shape1", 0, 0); + setTextureOffset("Piece1.ConeUp01", 0, 0); + setTextureOffset("Piece1.PipeUp", 54, 0); + setTextureOffset("Piece1.ConeUp02", 0, 0); + setTextureOffset("Piece1.Shape27", 0, 0); + setTextureOffset("Piece1.ConeUp04", 0, 0); + + Piece1 = new IHLModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = true; + Piece1.addBox("Shape1", -8F, -8F, -8F, 16, 16, 16); + Piece1.addTube("ConeUp01", -2F, -16F, -2F, 4, 2, 4, 0f, 0.5f, ForgeDirection.DOWN); + Piece1.addTube("PipeUp", -0.5F, -17F, -0.5F, 1, 1, 1, 0f, 1f, ForgeDirection.DOWN); + Piece1.addTube("ConeUp02", -2F, -14F, -2F, 4, 2, 4, 0f, 0.5f, ForgeDirection.DOWN); + Piece1.addTube("Shape27", -2F, -12F, -2F, 4, 2, 4, 0f, 0.5f, ForgeDirection.DOWN); + Piece1.addTube("ConeUp04", -2F, -10F, -2F, 4, 2, 4, 0f, 0.5f, ForgeDirection.DOWN); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/flexible_cable/BatterySwitchUnitTileEntity.java b/ihl/flexible_cable/BatterySwitchUnitTileEntity.java new file mode 100644 index 0000000..375cb21 --- /dev/null +++ b/ihl/flexible_cable/BatterySwitchUnitTileEntity.java @@ -0,0 +1,302 @@ +package ihl.flexible_cable; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySource; +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.core.ExplosionIC2; +import ic2.core.IC2; +import ic2.core.block.TileEntityBlock; +import ihl.IHLMod; +import ihl.flexible_cable.IHLGrid; +import ihl.flexible_cable.NodeEntity; +import ihl.interfaces.IEnergyNetNode; +import ihl.utils.IHLUtils; +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.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +public class BatterySwitchUnitTileEntity extends FlexibleCableHolderBaseTileEntity implements INetworkClientTileEntityEventListener, IEnergySource{ + + public short progress; + protected short operationLength=200; + public boolean isGuiScreenOpened=false; + protected final double energyConsume=128D; + public double energy; + public int maxStorage=65536; + private boolean addedToEnergyNet=false; + public byte mode = 0; + private Set batteryChain = new HashSet(); + private BatterySwitchUnitTileEntity batteryChainMaster; + private boolean chargingMode=true; + + public BatterySwitchUnitTileEntity() + { + super(); + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public void onUnloaded() + { + if (IC2.platform.isSimulating()&&this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + super.onUnloaded(); + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("batterySwitchUnit"); + } + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return this.getFacing()!=(short)side; + } + + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + nbt.setShort("progress", this.progress); + nbt.setDouble("energy", this.energy); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.progress = nbt.getShort("progress"); + this.energy=nbt.getDouble("energy"); + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + switch(event) + { + case 0: + this.isGuiScreenOpened=false; + break; + } + } + + @Override + public void updateEntityServer() + { + { + if(this.chargingMode && this.gridID!=-1 && this.energy0D) + { + if(this.getGrid().getSinkVoltage(this)/this.batteryChain.size()>410D) + { + this.energy+=energyConsume; + this.getGrid().drawEnergy(energyConsume, this); + if(this.getGrid().getSinkVoltage(this)/this.batteryChain.size()>500D) + { + this.createChainOfExplosions(); + } + } + } + } + if(this.chargingMode && this.batteryChainMaster!=null && this.gridID==-1) + { + if(this.batteryChainMaster.gridID!=-1 && this.batteryChainMaster.energy>0D && this.energy410D) + { + this.energy+=energyConsume; + this.batteryChainMaster.drawEnergy(energyConsume); + } + } + } + if(this.chargingMode && this.gridID!=-1 && MinecraftServer.getServer().getTickCounter() % 40==0) + { + this.checkBatteryChain(); + } + if(this.energy>=this.maxStorage) + { + this.chargingMode=false; + } + if(!this.chargingMode) + { + this.energy-=0.01D; + if(this.energy batteryChainIterator = this.batteryChain.iterator(); + while(batteryChainIterator.hasNext()) + { + BatterySwitchUnitTileEntity bsu = batteryChainIterator.next(); + ExplosionIC2 explosion = new ExplosionIC2(bsu.worldObj, null, bsu.xCoord+0.5D, bsu.yCoord+0.5D, bsu.zCoord+0.5D, 2F, 0.3F, ExplosionIC2.Type.Normal, null, 0); + explosion.doExplosion(); + } + } + + private boolean checkBatteryChain() + { + boolean allright=true; + if(!this.batteryChain.isEmpty()) + { + Iterator sectionsIterator = this.batteryChain.iterator(); + while(sectionsIterator.hasNext()) + { + BatterySwitchUnitTileEntity section = sectionsIterator.next(); + if(section==null || section.isInvalid()) + { + allright=false; + } + } + } + else + { + allright=false; + } + if(allright) + { + return true; + } + else + { + this.batteryChain.clear(); + boolean checking = true; + int x=xCoord; + int z=zCoord; + List xs = new ArrayList(); + List zs = new ArrayList(); + xs.add(xCoord); + zs.add(zCoord); + this.batteryChain.add(this); + while(checking) + { + if(!xs.isEmpty() && !zs.isEmpty()) + { + x=xs.remove(0); + z=zs.remove(0); + } + else + { + checking=false; + break; + } + int[] xz = new int[] {0,1,0,-1,0}; + for(int i=0;i500D) + { + this.createChainOfExplosions(); + } + } + +} diff --git a/ihl/flexible_cable/BlastEntityFX.java b/ihl/flexible_cable/BlastEntityFX.java new file mode 100644 index 0000000..49e2a36 --- /dev/null +++ b/ihl/flexible_cable/BlastEntityFX.java @@ -0,0 +1,68 @@ +package ihl.flexible_cable; + +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +public class BlastEntityFX extends EntityFX { + + public BlastEntityFX(World world, double x, double y, double z) + { + super(world, x, y, z); + this.renderDistanceWeight = 5.0D; + } + + public BlastEntityFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + this.particleScale *= par14; + this.particleMaxAge = 3; + this.particleAge=0; + this.noClip = false; + this.renderDistanceWeight = 6.0D; + } + + @Override + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float var8 = this.particleTextureIndexX / 2.0F; + float var9 = var8 + 0.5f; + float var10 = this.particleTextureIndexY / 2.0F; + float var11 = var10 + 0.5f; + float var12 = 0.1F * this.particleScale; + float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX); + float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY); + float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ); + par1Tessellator.addVertexWithUV(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12, var9, var11); + par1Tessellator.addVertexWithUV(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12, var9, var10); + par1Tessellator.addVertexWithUV(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12, var8, var10); + par1Tessellator.addVertexWithUV(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12, var8, var11); + } + + @Override + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + this.setParticleTextureIndex(this.particleAge * 3 / this.particleMaxAge); + } + + @Override + public void setParticleTextureIndex(int par1) + { + this.particleTextureIndexX = par1 % 2; + this.particleTextureIndexY = par1 / 2; + } + +} diff --git a/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java b/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java new file mode 100644 index 0000000..ee8ebf7 --- /dev/null +++ b/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java @@ -0,0 +1,236 @@ +package ihl.flexible_cable; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySource; +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.core.ExplosionIC2; +import ic2.core.IC2; +import ic2.core.block.TileEntityBlock; +import ic2.core.block.TileEntityInventory; +import ihl.IHLMod; +import ihl.flexible_cable.IHLGrid; +import ihl.flexible_cable.NodeEntity; +import ihl.interfaces.IEnergyNetNode; +import ihl.utils.IHLUtils; +import net.minecraft.entity.EntityLivingBase; +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.nbt.NBTTagList; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class FlexibleCableHolderBaseTileEntity extends TileEntityInventory implements IEnergyNetNode{ + + protected double connectionX; + protected double connectionY; + protected double connectionZ; + protected int gridID=-1; + protected final Set cableList; + public boolean checkCables=true; + + public FlexibleCableHolderBaseTileEntity() + { + super(); + cableList=new HashSet(); + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if(gridID!=-1) + { + IHLGrid grid = IHLMod.enet.getGrid(gridID); + grid.add(this); + } + } + + @Override + public void setFacing(short facing1) + { + short facing2 = (short) Math.max(facing1, 2); + double range = 2D; + AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(connectionX-range,connectionY-range,connectionZ-range,connectionX+range,connectionY+range,connectionZ+range); + List nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea); + super.setFacing(facing2); + setConnectionX(this.xCoord+0.5D); + setConnectionY(this.yCoord+1.5D); + setConnectionZ(this.zCoord+0.5D); + if(!nodeList.isEmpty()) + { + Iterator ei = nodeList.iterator(); + while(ei.hasNext()) + { + NodeEntity ne=(NodeEntity) ei.next(); + if((ne.prevAnchorEntity==null||ne.nextAnchorEntity==null) && this.cableListContains(ne.getChainUniqueID())) + { + ne.setVirtualNodePos(connectionX, connectionY, connectionZ); + } + } + } + } + + protected boolean cableListContains(int chainUniqueID) { + Iterator cli = this.getCableList().iterator(); + while(cli.hasNext()) + { + NBTTagCompound c = cli.next(); + if(c.getInteger("chainUID")==chainUniqueID) + { + return true; + } + } + return false; + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return this.getFacing()!=(short)side; + } + + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + NBTTagList cableNBTList = new NBTTagList(); + for(NBTTagCompound cable:this.cableList) + { + cableNBTList.appendTag(cable); + } + nbt.setTag("cableList", cableNBTList); + nbt.setDouble("connectionX", this.connectionX); + nbt.setDouble("connectionY", this.connectionY); + nbt.setDouble("connectionZ", this.connectionZ); + nbt.setInteger("gridID", this.gridID); + nbt.setBoolean("checkCables", this.checkCables); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + NBTTagList cableNBTList=nbt.getTagList("cableList", 10); + for(int i=0;i getCableList() { + return cableList; + } + + @Override + public void setGrid(int newGridID) + { + if(newGridID!=-1) + { + this.gridID=newGridID; + IHLGrid newGrid = IHLMod.enet.getGrid(newGridID); + IHLMod.enet.getGrid(newGridID).add(this); + } + else + { + this.gridID=-1; + } + } + + @Override + public int getGridID() + { + return this.gridID; + } + + @Override + public IHLGrid getGrid() + { + return IHLMod.enet.getGrid(gridID); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + + @Override + public void remove(NBTTagCompound cable) + { + if(this.cableList.remove(cable)) + { + IHLUtils.removeChain(cable, this); + } + } + + + @Override + public boolean isCableRemoved(int chainUniqueID) + { + if(!checkCables) + { + return false; + } + for(NBTTagCompound cable:this.cableList) + { + if(cable.getInteger("chainUID")==chainUniqueID) + { + return false; + } + } + return true; + } + + @Override + public void setCableCheck(boolean b) + { + this.checkCables=b; + } +} diff --git a/ihl/flexible_cable/IHLENet.java b/ihl/flexible_cable/IHLENet.java new file mode 100644 index 0000000..2429aa7 --- /dev/null +++ b/ihl/flexible_cable/IHLENet.java @@ -0,0 +1,164 @@ +package ihl.flexible_cable; + +import ihl.IHLMod; +import ihl.interfaces.IEnergyNetNode; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import net.minecraft.nbt.NBTTagCompound; + +public class IHLENet { + + public Map grids = new HashMap(); + public Map cablesToGrids = new HashMap(); + + private int griduid=0; + + public IHLENet() + { + } + + public int getNewUniqueGridID() + { + for(int i=0;i tei = grids.get(gridID2).telist.iterator(); + while(tei.hasNext()) + { + IEnergyNetNode te = tei.next(); + te.setGrid(gridID); + } + grids.remove(gridID2); + return gridID; + } + return gridID2; + } + + + public IHLGrid getGrid(int gridID) + { + if(this.grids.get(gridID)==null) + { + IHLGrid cgrid; + cgrid=new IHLGrid(); + grids.put(gridID, cgrid); + return cgrid; + } + else + { + return this.grids.get(gridID); + } + } + + public void splitGrids(int gridID, IEnergyNetNode exclude) + { + Set telist = this.grids.get(gridID).telist; + telist.remove(exclude); + Iterator atei = telist.iterator(); + while(atei.hasNext()) + { + IEnergyNetNode cte = atei.next(); + cte.getCableList().removeAll(exclude.getCableList()); + cte.setGrid(-1); + } + Iterator atei2 = telist.iterator(); + while(atei2.hasNext()) + { + IEnergyNetNode cte = atei2.next(); + if(cte.getGridID()==-1)//Warning! Potential future bugs are hidden here! + { + Iterator atei3 = telist.iterator(); + while(atei3.hasNext()) + { + IEnergyNetNode cte2 = atei3.next(); + if(cte2!=cte && hasSame(cte.getCableList(),cte2.getCableList())) + { + int result=this.mergeGrids(cte.getGridID(), cte2.getGridID()); + cte.setGrid(result); + cte2.setGrid(result); + break; + } + } + } + } + } + + public void removeCableAndSplitGrids(int gridID, NBTTagCompound cable) + { + this.grids.get(gridID).removeCableAndSplitGrids(cable); + } + + public boolean hasSame(Set set, Set set2) + { + Iterator i1 = set.iterator(); + while(i1.hasNext()) + { + NBTTagCompound num1=i1.next(); + if(set2.contains(num1)) + { + return true; + } + } + return false; + } + + public void setOnFire(NBTTagCompound cable) + { + Set cs = IHLMod.proxy.nodeEntityRegistry.get(cable.getInteger("chainUID")); + if(cs!=null) + { + for(NodeEntity ne:cs) + { + ne.setFire(10); + } + } + } + + 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(); + } + } + } + cablesToGrids.remove(uid); + } +} \ No newline at end of file diff --git a/ihl/flexible_cable/IHLGrid.java b/ihl/flexible_cable/IHLGrid.java new file mode 100644 index 0000000..04a9d4c --- /dev/null +++ b/ihl/flexible_cable/IHLGrid.java @@ -0,0 +1,300 @@ +package ihl.flexible_cable; + +import ihl.IHLMod; +import ihl.interfaces.IEnergyNetNode; +import ihl.utils.IHLUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; + +public class IHLGrid +{ + private static final double powerLossLimitPerMeter=1.6D; + public final Set telist = new HashSet(); + public double energy=0D; + private IEnergyNetNode sink; + private IEnergyNetNode source; + private double voltage; + private short frequency=0; + private double lastVoltage; + public boolean isGridValid=true; + private double total20TicksEU; + private int lastTickCounter=0; + private int tickCounterFireStart=0; + public final List calculatedSinks = new ArrayList(); + public final List calculatedSources = new ArrayList(); + public final Set cablesOnFire = new HashSet(); + private final Map energyLossSinkMap = new HashMap(); + private final Map voltageSinkMap = new HashMap(); + private double averageEUTransfered; + private double lastAverageEUTransfered=0D; + + public void drawEnergy(double amount, IEnergyNetNode sink1) + { + this.energy-=amount; + if(energyLossSinkMap.get(sink1)!=null) + { + this.energy-=energyLossSinkMap.get(sink1)*amount*amount; + } + else + { + this.telist.add(sink1); + } + this.sink=sink1; + } + + public void injectEnergy(double amount, double voltage1, IEnergyNetNode source1) + { + this.energy+=amount; + this.voltage=voltage1; + this.source=source1; + this.total20TicksEU+=amount; + int tickCounter = MinecraftServer.getServer().getTickCounter(); + if(tickCounter-lastTickCounter<0) + { + lastTickCounter=tickCounter; + this.total20TicksEU=0D; + } + Iterator i = telist.iterator(); + while(this.energy>1d && i.hasNext()) + { + IEnergyNetNode eNode = i.next(); + if(eNode.getEnergyAmountThisNodeWant()>0d) + { + double powerToInject = Math.min(energy,eNode.getEnergyAmountThisNodeWant()); + eNode.injectEnergyInThisNode(powerToInject, this.getSinkVoltage(eNode)); + this.energy-=powerToInject; + if(energyLossSinkMap.get(eNode)!=null) + { + this.energy-=energyLossSinkMap.get(eNode)*powerToInject*powerToInject; + } + else + { + this.sink=eNode; + } + } + } + int d=tickCounter-lastTickCounter; + if(d>=200) + { + this.averageEUTransfered=this.total20TicksEU/d; + lastTickCounter=tickCounter; + this.total20TicksEU=0D; + if(IHLMod.config.enableFlexibleCablesGridPowerLossCalculations && isGridValid && this.averageEUTransfered>1D) + { + this.telist.add(source1); + this.updateGrid(); + } + } + d=tickCounter-tickCounterFireStart; + if(d>=200 && !this.cablesOnFire.isEmpty()) + { + for(NBTTagCompound cable:this.cablesOnFire) + { + this.removeCableAndSplitGrids(cable); + } + this.cablesOnFire.clear(); + } + + } + + public void removeCableAndSplitGrids(NBTTagCompound cable) + { + IHLUtils.removeChain(cable,null); + Iterator atei = this.telist.iterator(); + while(atei.hasNext()) + { + IEnergyNetNode cte = atei.next(); + cte.setGrid(-1); + } + IHLMod.enet.removeCableEntities(cable); + Iterator atei2 = telist.iterator(); + while(atei2.hasNext()) + { + IEnergyNetNode cte = atei2.next(); + if(cte.getGridID()==-1)//Warning! Potential future bugs are hidden here! + { + Iterator atei3 = telist.iterator(); + while(atei3.hasNext()) + { + IEnergyNetNode cte2 = atei3.next(); + if(cte2!=cte && IHLMod.enet.hasSame(cte.getCableList(),cte2.getCableList())) + { + int result=IHLMod.enet.mergeGrids(cte.getGridID(), cte2.getGridID()); + cte.setGrid(result); + cte2.setGrid(result); + break; + } + } + + } + } + } + + private void updateGrid() + { + if(this.source!=null && + this.sink!=null && + this.source!=this.sink && + !this.sink.getCableList().isEmpty() && + !this.source.getCableList().isEmpty() && + (!this.calculatedSources.contains(this.source) || + !this.calculatedSinks.contains(this.sink) || + this.averageEUTransfered>this.lastAverageEUTransfered || + this.voltage!=this.lastVoltage)) + { + Map map = new HashMap(); + Set templist = new HashSet(); + Set processlist = new HashSet(); + Set templist2 = new HashSet(); + templist.addAll(telist); + processlist.add(sink); + int threads=0; + a: while(!templist.isEmpty()) + { + if(threads++>1000) + { + this.isGridValid=false; + return; + } + templist.removeAll(processlist); + templist2.clear(); + Iterator it1 = processlist.iterator(); + while(it1.hasNext()) + { + if(threads++>1000) + { + this.isGridValid=false; + return; + } + IEnergyNetNode ate1 = it1.next(); + Iterator it2 = templist.iterator(); + while(it2.hasNext()) + { + if(threads++>1000) + { + this.isGridValid=false; + return; + } + IEnergyNetNode ate2 = it2.next(); + if(ate1!=ate2) + { + NBTTagCompound cable = this.getSame(ate1.getCableList(), ate2.getCableList()); + if(cable!=null) + { + map.put(ate2, cable); + templist2.add(ate2); + if(ate2==source) + { + break a; + } + } + } + } + templist.removeAll(templist2); + } + processlist.clear(); + processlist.addAll(templist2); + } + IEnergyNetNode cursor=source; + { + double voltage1=this.voltage; + double euTransfered=this.averageEUTransfered; + double voltageLossPerMeter=0D; + double powerLossPerMeter=0D; + double powerLossPerSquaredEU=0D; + this.energyLossSinkMap.remove(sink); + this.voltageSinkMap.remove(sink); + while(cursor!=sink) + { + //System.out.println("cycle 4"); + NBTTagCompound cable = map.get(cursor); + voltageLossPerMeter=IHLUtils.getResistance(cable)/1000D*euTransfered/voltage1; + powerLossPerMeter=voltageLossPerMeter*euTransfered/voltage1; + euTransfered-=powerLossPerMeter*cable.getInteger("length"); + voltage1-=voltageLossPerMeter*cable.getInteger("length"); + powerLossPerSquaredEU+=IHLUtils.getResistance(cable)/1000d*cable.getInteger("length")/voltage1/voltage1; + //System.out.println("voltageLossPerMeter=" + voltageLossPerMeter); + //System.out.println("powerLossPerMeter=" + powerLossPerMeter); + //System.out.println("euTransfered=" + euTransfered); + //System.out.println("voltage1=" + voltage1); + //System.out.println("powerLossPerSquaredEU=" + powerLossPerSquaredEU); + if(!this.cablesOnFire.contains(cable) && (powerLossPerMeter>IHLGrid.powerLossLimitPerMeter)) + { + IHLMod.enet.setOnFire(cable); + tickCounterFireStart=lastTickCounter; + this.cablesOnFire.add(cable); + } + cursor=this.getHasCable(cable, cursor); + } + this.energyLossSinkMap.put(sink, powerLossPerSquaredEU); + this.voltageSinkMap.put(sink, voltage1); + } + this.calculatedSources.add(this.source); + this.calculatedSinks.add(this.sink); + this.lastAverageEUTransfered=this.averageEUTransfered; + this.lastVoltage=this.voltage; + } + } + + private NBTTagCompound getSame(Set set, Set set2) + { + Iterator i1 = set.iterator(); + while(i1.hasNext()) + { + NBTTagCompound cable=i1.next(); + if(set2.contains(cable)) + { + return cable; + } + } + return null; + } + + public double getSinkVoltage(IEnergyNetNode node) + { + if(this.voltageSinkMap.containsKey(node)) + { + return this.voltageSinkMap.get(node); + } + else + { + return this.voltage; + } + } + + private IEnergyNetNode getHasCable(NBTTagCompound cable, IEnergyNetNode exclude) + { + Iterator it1 = this.telist.iterator(); + while(it1.hasNext()) + { + IEnergyNetNode ate1 = it1.next(); + if(ate1!=exclude && ate1.getCableList().contains(cable)) + { + return ate1; + } + } + return null; + } + + public void add(IEnergyNetNode e) + { + this.telist.add(e); + this.isGridValid=true; + if(!e.getCableList().isEmpty()) + { + for(NBTTagCompound cable:e.getCableList()) + { + IHLMod.enet.cablesToGrids.put(cable.getInteger("chainUID"), this); + } + } + } +} diff --git a/ihl/flexible_cable/InvSlotOutputInProgress.java b/ihl/flexible_cable/InvSlotOutputInProgress.java new file mode 100644 index 0000000..2b5bfda --- /dev/null +++ b/ihl/flexible_cable/InvSlotOutputInProgress.java @@ -0,0 +1,93 @@ +package ihl.flexible_cable; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class InvSlotOutputInProgress extends IronWorkbenchInvSlot{ + public short[] slotRecipe; + private int size; + public InvSlotOutputInProgress(IronWorkbenchTileEntity base1, String name1, int oldStartIndex1, int count) { + super(base1, name1, oldStartIndex1, Access.NONE, count); + slotRecipe = new short[count]; + size=count; + for(int i=0;i outputs) + { + short slot=this.getFirstEmptySlot(); + if(slot!=-1 && outputs!=null && !outputs.isEmpty() && slot<=this.size()-outputs.size()) + { + for(int i=0;i getRecipeOutputs(int currentSlot) + { + int slotRecipeIndex=this.slotRecipe[currentSlot]; + List list = new ArrayList(); + for(int i=0;i materials, int multiplier) + { + Iterator i1 = materials.iterator(); + while(i1.hasNext()) + { + IRecipeInput is1 = i1.next(); + for(int i=0;i materials) + { + int m = Integer.MAX_VALUE; + for(int i=0;i tools) + { + if(tools!=null && !tools.isEmpty()) + { + for(int i=0;i i1 = tools.iterator(); + while(i1.hasNext()) + { + IRecipeInput is1 = i1.next(); + if(is!=null && (is1.matches(is))) + { + if(!is.attemptDamageItem(1, IC2.random)) + { + if(is.stackTagCompound!=null && is.stackTagCompound.hasKey("GT.ToolStats")) + { + IHLUtils.damageItemViaNBTTag(is, 1); + } + } + if(is.stackSize<=0) + { + this.put(i,null); + } + } + } + } + } + } + + @Override + public void put(int index, ItemStack content) + { + super.put(index, content); + if(IC2.platform.isSimulating() && ((IronWorkbenchTileEntity)this.base).container!=null) + { + ((IronWorkbenchTileEntity)this.base).resetOutput(); + ((IronWorkbenchTileEntity)this.base).container.detectAndSendChanges(); + } + } + + @Override + public boolean accepts(ItemStack itemStack) + { + if (itemStack != null && (itemStack.getItem() instanceof ItemUpgradeModule || itemStack.getItem() instanceof IWire|| itemStack.getItem()==Ic2Items.rubber.getItem())) + { + return false; + } + else + { + return true; + } + } + + public boolean contain(ItemStack is1) + { + for(int i=0;i workspaceElements2) + { + Iterator iterator = workspaceElements2.iterator(); + while(iterator.hasNext()) + { + ItemStack rWorkspaceElementItemStack = iterator.next(); + boolean presence=false; + for(int i=1;i workspaceElements2) + { + Iterator iterator = workspaceElements2.iterator(); + while(iterator.hasNext()) + { + ItemStack rWorkspaceElementItemStack = iterator.next(); + boolean presence=false; + for(int i=1;i 0) + { + int progressLevel=Math.min(Math.round(this.container.tileEntity.progress*16.0F/this.container.tileEntity.maxProgress),16); + int frameNum=0; + short slotRecipeNum=this.container.tileEntity.output.slotRecipe[0]; + for(int row = 0;row<6;row++) + { + for (int col = 0; col<3; ++col) + { + if(slotRecipeNum!=this.container.tileEntity.output.slotRecipe[col+row*3]) + { + frameNum++; + slotRecipeNum=this.container.tileEntity.output.slotRecipe[col+row*3]; + } + if(this.container.tileEntity.currentSlot==slotRecipeNum) + { + int i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176, 72,i1,18); + this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176+getFrameX(frameNum), getFrameY(frameNum),18,18); + } + } + } + } + else + { + int frameNum=0; + short slotRecipeNum=this.container.tileEntity.output.slotRecipe[0]; + for(int row = 0;row<6;row++) + { + for (int col = 0;col<3; ++col) + { + if(slotRecipeNum!=this.container.tileEntity.output.slotRecipe[col+row*3]) + { + frameNum++; + slotRecipeNum=this.container.tileEntity.output.slotRecipe[col+row*3]; + } + if(this.container.tileEntity.output.get(col+row*3)!=null) + { + this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176+getFrameX(frameNum), getFrameY(frameNum),18,18); + } + } + } + } + for(int row = 1;row<6;row++) + { + if(!this.container.tileEntity.workspaceElements.ready[row]) + { + this.drawTexturedModalRect(20+x, 9+y+row*18, 194, 74,3,14); + } + } + } + + @Override + public void onGuiClosed() + { + super.onGuiClosed(); + this.container.tileEntity.isGuiScreenOpened=false; + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 16); + } + + @Override + public void handleMouseClick(Slot slot,int slotNumber,int mouseButton/*0=left 1=right*/,int arg3) + { + if(miniGui==null && slot!=null && slot.slotNumber>=outputslotoffset && slot.slotNumber>2) & 3)*18; + } + +} \ No newline at end of file diff --git a/ihl/flexible_cable/IronWorkbenchInvSlot.java b/ihl/flexible_cable/IronWorkbenchInvSlot.java new file mode 100644 index 0000000..830f9b4 --- /dev/null +++ b/ihl/flexible_cable/IronWorkbenchInvSlot.java @@ -0,0 +1,30 @@ +package ihl.flexible_cable; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import ic2.core.block.invslot.InvSlot; + +public class IronWorkbenchInvSlot extends InvSlot { + + public IronWorkbenchInvSlot(IronWorkbenchTileEntity base1, String name1, + int oldStartIndex1, Access access1, int count) { + super(base1, name1, oldStartIndex1, access1, count); + } + + public List getItemStackList() + { + List list = new ArrayList(); + for(int i=0; i recipes = new ArrayList(); + public int progress; + 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; + private EntityPlayer crafter; + public ContainerBase container; + private Map slotRecipeMap = new HashMap(); + + 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() + { + return "ironWorkbench"; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("ironWorkbench"); + } + + @Override + public void updateEntityServer() + { + if(this.isGuiScreenOpened) + { + if(this.output.isEmpty() && !outputDefined) + { + this.workspaceElements.reset(); + 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)) + { + List newOutputs = recipe.outputs; + for(IRecipeInput rinput:recipe.tools) + { + if(rinput instanceof RecipeInputDie) + { + newOutputs = ((RecipeInputDie)rinput).transformOutput(this.getMatchedItemStack(rinput),recipe.outputs); + } + } + int slot = this.output.put(newOutputs); + if(slot<0)break; + slotRecipeMap.put(slot, recipe); + this.startProcess=false; + } + } + } + List processingMaterials = new ArrayList(); + 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})); + int slot = this.output.put(recipe.outputs); + if(slot<0)break; + slotRecipeMap.put(slot, recipe); + this.startProcess=false; + break; + } + } + outputDefined=true; + } + else if(!this.output.isEmpty()) + { + List 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(); + this.crafter.inventory.mainInventory[slot]=stack.copy(); + if(stack.getItem() instanceof IWire) + { + System.out.println(multiplier); + this.crafter.inventory.mainInventory[slot]=IHLUtils.getWireItemStackCopyWithLengthMultiplied(stack,multiplier); + } + else + { + this.crafter.inventory.mainInventory[slot]=stack.copy(); + this.crafter.inventory.mainInventory[slot].stackSize*=multiplier; + } + } + this.crafter.inventoryContainer.detectAndSendChanges(); + this.inputMaterial.substract(crecipe.materials, multiplier); + 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)) + { + return tool; + } + } + for(ItemStack material:this.inputMaterial.getItemStackList()) + { + if(rinput.matches(material)) + { + return material; + } + } + + return null; + } + + private List getCrafterEmptyInventorySlotsList() + { + List list = new ArrayList(); + 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 getGuiContainer(EntityPlayer player) { + resetOutput(); + this.isGuiScreenOpened=true; + this.crafter=player; + container = new IronWorkbenchContainer(player, this); + return container; + } + + @Override + 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; + 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())) + { + resetOutput(); + } + else + { + this.currentSlot=i; + this.startProcess=true; + return; + } + } + } + } + + public void resetOutput() + { + this.output.clear(); + this.slotRecipeMap.clear(); + this.progress=0; + this.startProcess=false; + this.currentSlot=-1; + this.outputDefined=false; + } + + + public void dropContents() { + for(int i=0;i recipeOutputsItems) + { + Iterator ri = recipes.iterator(); + while(ri.hasNext()) + { + IronWorkbenchRecipe recipe = ri.next(); + boolean removeEntry=false; + Iterator roi = recipe.outputs.iterator(); + while(roi.hasNext()) + { + if(IHLUtils.isItemStacksIsEqual(recipeOutputsItems.get(0), roi.next(), true)) + { + removeEntry=true; + } + } + if(removeEntry) + { + ri.remove(); + } + } + + } + + 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()) + { + IronWorkbenchRecipe recipe = ri.next(); + if(recipe.isCanBeCrafted(recipeInputsTools, recipeInputsItems, recipeInputsMachines)) + { + ri.remove(); + } + } + + } + +} diff --git a/ihl/flexible_cable/NodeEntity.java b/ihl/flexible_cable/NodeEntity.java new file mode 100644 index 0000000..623c9a1 --- /dev/null +++ b/ihl/flexible_cable/NodeEntity.java @@ -0,0 +1,617 @@ +package ihl.flexible_cable; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import ihl.IHLMod; +import ihl.IHLModInfo; +import ihl.interfaces.ICableHolder; +import ihl.interfaces.IDataCableHolder; +import ihl.interfaces.IEnergyNetNode; +import ihl.interfaces.IMultiPowerCableHolder; +import ihl.interfaces.INetworkListener; +import ihl.items_blocks.FlexibleCableItem; +import ihl.utils.IHLUtils; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; +import io.netty.buffer.ByteBufOutputStream; +import io.netty.buffer.Unpooled; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +public class NodeEntity extends Entity implements INetworkListener{ + + public NodeEntity prevAnchorEntity; + public Entity nextAnchorEntity; + private int anchorX; + private int anchorY; + private int anchorZ; + private short anchorFacing; + private int anchorDimensionId; + public boolean shouldFollowPlayer=false; + protected int chainUniqueID=-2; + public int chainArrangeNumber=-2; + protected int checkTimer=201; + public int colorIndex=16777215; + public int renderEvery=1; + public int type=1;//0 - uninsulated wire; 1 - insulated cable; 2 - data cable + public float dx0=0; + public float dy0=0; + public float dz0=0; + public final int n=48; + public final float[] rotationPitchArray = new float[n+1]; + public final float[] rotationYawArray = new float[n+1]; + public final float[] translationX = new float[n+1]; + public final float[] translationY = new float[n+1]; + public final float[] translationZ = new float[n+1]; + public double virtualNodePosX; + public double virtualNodePosY; + public double virtualNodePosZ; + public double renderPosX; + public double renderPosY; + public double renderPosZ; + public double lastTickRenderPosX; + public double lastTickRenderPosY; + public double lastTickRenderPosZ; + private boolean alreadyRegistered=false; + private boolean shouldUpdateRender=true; + + public NodeEntity(World world) + { + super(world); + if(world.isRemote) + { + IHLMod.proxy.addEntityToList(this); + this.setSize(2f, 0.2f); + } + else + { + IHLMod.proxy.addEntityToServerList(this); + this.setSize(0.5F, 0.1F); + } + this.renderDistanceWeight = 5.0D; + this.yOffset+=0.15F; + this.virtualNodePosX=this.posX; + this.virtualNodePosY=this.posY; + this.virtualNodePosZ=this.posZ; + this.motionX=0D; + this.motionY=0D; + this.motionZ=0D; + } + + @Override + public void setInPortal(){} + + @Override + public void travelToDimension(int dimensionId){} + + public void setSize(float width, float heigth) + { + super.setSize(width, heigth); + } + + public void setVirtualNodePos(double d,double e, double f) + { + virtualNodePosX=d; + virtualNodePosY=e; + virtualNodePosZ=f; + this.registerAndSendData(null); + } + + public void registerAndSendData(EntityPlayerMP player) + { + if(!worldObj.isRemote) + { + if(!alreadyRegistered) + { + Set nes; + if(IHLMod.proxy.nodeEntityRegistry.containsKey(this.getChainUniqueID())) + { + nes=IHLMod.proxy.nodeEntityRegistry.get(this.getChainUniqueID()); + } + else + { + nes=new HashSet(); + IHLMod.proxy.nodeEntityRegistry.put(this.getChainUniqueID(),nes); + } + nes.add(this); + alreadyRegistered=true; + } + ByteBuf bb = Unpooled.buffer(30); + ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb); + try + { + byteBufOutputStream.write(1); + byteBufOutputStream.writeInt(this.getEntityId()); + byteBufOutputStream.writeInt(this.getChainUniqueID()); + byteBufOutputStream.writeInt(this.chainArrangeNumber); + byteBufOutputStream.writeByte(this.type); + byteBufOutputStream.writeInt(this.colorIndex); + byteBufOutputStream.writeDouble(this.virtualNodePosX); + byteBufOutputStream.writeDouble(this.virtualNodePosY); + byteBufOutputStream.writeDouble(this.virtualNodePosZ); + byteBufOutputStream.writeBoolean(this.shouldFollowPlayer); + if(player==null) + { + IHLMod.proxy.sendFromServerToAll(new FMLProxyPacket(byteBufOutputStream.buffer(), IHLModInfo.MODID)); + } + else + { + IHLMod.proxy.sendFromServerToPlayer(new FMLProxyPacket(byteBufOutputStream.buffer(), IHLModInfo.MODID),player); + } + byteBufOutputStream.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } + + @Override + public void onUpdate() + { + super.onUpdate(); + if(this.checkTimer==201) + { + if(worldObj.isRemote) + { + IHLMod.proxy.recieveDelayedDataPacket(this); + } + else + { + this.registerAndSendData(null); + } + } + if(prevAnchorEntity==null||(nextAnchorEntity==null || nextAnchorEntity instanceof EntityPlayer || nextAnchorEntity instanceof EntityItem)) + { + double range = 16D; + AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.posX-range,this.posY-range,this.posZ-range,this.posX+range,this.posY+range,this.posZ+range); + List eItemsList = this.worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea); + if(!eItemsList.isEmpty()) + { + Iterator ei = eItemsList.iterator(); + while(ei.hasNext()) + { + NodeEntity node=(NodeEntity) ei.next(); + if(node.getChainUniqueID()==this.getChainUniqueID()) + { + if(node.chainArrangeNumber==this.chainArrangeNumber-1) + { + this.prevAnchorEntity=node; + node.nextAnchorEntity=this; + node.shouldFollowPlayer=false; + } + else if(node.chainArrangeNumber==this.chainArrangeNumber+1) + { + this.nextAnchorEntity=node; + this.shouldFollowPlayer=false; + node.prevAnchorEntity=this; + } + } + if(prevAnchorEntity!=null && nextAnchorEntity!=null) + { + break; + } + } + } + } + if(this.shouldFollowPlayer && (this.nextAnchorEntity == null || this.nextAnchorEntity.isDead)) + { + double range = 16D; + AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.posX-range,this.posY-range,this.posZ-range,this.posX+range,this.posY+range,this.posZ+range); + List eItemsList = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, searchArea); + if(!eItemsList.isEmpty()) + { + Iterator ei = eItemsList.iterator(); + while(ei.hasNext()) + { + EntityPlayer player=(EntityPlayer) ei.next(); + if(this.playerHasItemStack(player)) + { + this.nextAnchorEntity=player; + } + + } + } + } + if(this.shouldFollowPlayer && this.nextAnchorEntity instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) this.nextAnchorEntity; + if(!this.playerHasItemStack(player)) + { + double range = 16D; + AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.posX-range,this.posY-range,this.posZ-range,this.posX+range,this.posY+range,this.posZ+range); + List eItemsList = this.worldObj.getEntitiesWithinAABB(EntityItem.class, searchArea); + if(!eItemsList.isEmpty()) + { + Iterator ei = eItemsList.iterator(); + while(ei.hasNext()) + { + EntityItem eitem = ei.next(); + if(this.isItemHasSameChainId(eitem.getEntityItem())) + { + this.nextAnchorEntity=eitem; + break; + } + } + } + } + } + if(nextAnchorEntity!=null && this.getDistanceSqToEntity(nextAnchorEntity)>2D) + { + this.nextAnchorEntity.addVelocity((this.posX-this.nextAnchorEntity.posX)*0.02D, (this.posY-this.nextAnchorEntity.posY)*0.02D, (this.posZ-this.nextAnchorEntity.posZ)*0.02D); + } + if(!worldObj.isRemote) + { + double x0,x2,y0,y2,z0,z2; + x2=x0=this.virtualNodePosX; + y2=y0=this.virtualNodePosY; + z2=z0=this.virtualNodePosZ; + if(nextAnchorEntity!=null) + { + x2=nextAnchorEntity.posX; + y2=nextAnchorEntity.posY; + z2=nextAnchorEntity.posZ; + } + if(prevAnchorEntity!=null) + { + x0=prevAnchorEntity.posX; + y0=prevAnchorEntity.posY; + z0=prevAnchorEntity.posZ; + } + double d1 = (x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)+(z0-z2)*(z0-z2); + if(d1>4D) + { + this.motionX+=(x0+x2)*0.05D-this.posX*0.1D; + this.motionY+=(y0+y2)*0.05D-this.posY*0.1D; + this.motionZ+=(z0+z2)*0.05D-this.posZ*0.1D; + } + else + { + double d2 = this.getDistanceSq(x2,y2,z2); + if(d2>1D) + { + this.motionX+=(x2-this.posX)*0.01D; + this.motionY+=(y2-this.posY)*0.01D; + this.motionZ+=(z2-this.posZ)*0.01D; + } + double d3 = this.getDistanceSq(x0,y0,z0); + if(d3>1D) + { + this.motionX+=(x0-this.posX)*0.01D; + this.motionY+=(y0-this.posY)*0.01D; + this.motionZ+=(z0-this.posZ)*0.01D; + } + } + this.motionY-=0.005D; + this.motionX*=0.8D; + this.motionY*=0.8D; + this.motionZ*=0.8D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + } + if(this.onGround) + { + this.motionY *= -0.5D; + } + if(worldObj.isRemote) + { + this.lastTickRenderPosX=this.renderPosX; + this.lastTickRenderPosY=this.renderPosY; + this.lastTickRenderPosZ=this.renderPosZ; + this.renderPosX=(float) this.prevPosX; + this.renderPosY=(float) this.prevPosY; + this.renderPosZ=(float) this.prevPosZ; + shouldUpdateRender= + Math.abs(this.lastTickRenderPosX-this.renderPosX)+ + Math.abs(this.lastTickRenderPosY-this.renderPosY)+ + Math.abs(this.lastTickRenderPosZ-this.renderPosZ)>0.01f; + + float xi,yi,zi; + float x0=xi=(float)this.prevPosX; + float y0=yi=(float)this.prevPosY; + float z0=zi=(float)this.prevPosZ; + float dx0=this.dx0; + float dy0=this.dy0; + float dz0=this.dz0; + float dx1=(float) (this.virtualNodePosX-xi); + float dy1=(float) (this.virtualNodePosY-yi); + float dz1=(float) (this.virtualNodePosZ-zi); + if(this.nextAnchorEntity!=null) + { + dx1=(float) (this.nextAnchorEntity.prevPosX-xi); + dy1=(float) (this.nextAnchorEntity.prevPosY-yi); + dz1=(float) (this.nextAnchorEntity.prevPosZ-zi); + } + if(this.prevAnchorEntity==null) + { + this.renderPosX=this.virtualNodePosX; + this.renderPosY=this.virtualNodePosY; + this.renderPosZ=this.virtualNodePosZ; + x0=xi=(float) this.virtualNodePosX; + y0=yi=(float) this.virtualNodePosY; + z0=zi=(float) this.virtualNodePosZ; + } + if(this.nextAnchorEntity instanceof NodeEntity) + { + shouldUpdateRender=this.shouldUpdateRender || ((NodeEntity)this.nextAnchorEntity).shouldUpdateRender; + if(((NodeEntity)this.nextAnchorEntity).nextAnchorEntity!=null) + { + Entity nne = ((NodeEntity)this.nextAnchorEntity).nextAnchorEntity; + dx1=(float) (nne.prevPosX-xi); + dy1=(float) (nne.prevPosY-yi); + dz1=(float) (nne.prevPosZ-zi); + } + else + { + dx1=(float) (((NodeEntity) this.nextAnchorEntity).virtualNodePosX-xi); + dy1=(float) (((NodeEntity) this.nextAnchorEntity).virtualNodePosY-yi); + dz1=(float) (((NodeEntity) this.nextAnchorEntity).virtualNodePosZ-zi); + } + } + if(shouldUpdateRender) + { + float x1=(float) this.virtualNodePosX; + float y1=(float) this.virtualNodePosY; + float z1=(float) this.virtualNodePosZ; + if(this.nextAnchorEntity!=null) + { + if(nextAnchorEntity instanceof NodeEntity) + { + x1=(float) ((NodeEntity) nextAnchorEntity).renderPosX; + y1=(float) ((NodeEntity) nextAnchorEntity).renderPosY; + z1=(float) ((NodeEntity) nextAnchorEntity).renderPosZ; + } + else + { + x1=(float) nextAnchorEntity.posX; + y1=(float) nextAnchorEntity.posY; + z1=(float) nextAnchorEntity.posZ; + } + } + float d = (x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)+(z0-z1)*(z0-z1); + if(d>2f) + { + renderEvery=1; + }/* + else if(d>0.5f) + { + renderEvery=2; + } + else + { + renderEvery=4; + }*/ + int i1=0; + for(float i=1f/n;i<=1f+1f/n;i+=((float)renderEvery)/n,i1+=renderEvery) + { + float dxi = xi; + float dyi = yi; + float dzi = zi; + xi=(dx1-2*x1+2*dx0+2*x0-dx0)*i*i*i+(3*x1-dx1-3*dx0-3*x0+dx0)*i*i+dx0*i+x0; + yi=(dy1-2*y1+2*dy0+2*y0-dy0)*i*i*i+(3*y1-dy1-3*dy0-3*y0+dy0)*i*i+dy0*i+y0; + zi=(dz1-2*z1+2*dz0+2*z0-dz0)*i*i*i+(3*z1-dz1-3*dz0-3*z0+dz0)*i*i+dz0*i+z0; + int blockX=(int)xi; + int blockY=(int)yi; + int blockZ=(int)zi; + dxi-=xi; + dyi-=yi; + dzi-=zi; + double var7 = MathHelper.sqrt_double(dxi * dxi + dzi * dzi); + float var9 = (float)(Math.atan2(dzi, dxi) * 180.0D / Math.PI) - 90.0F; + float var10 = (float)(-(Math.atan2(dyi, var7) * 180.0D / Math.PI)); + float rotationPitch = (float) Math.atan2(dxi, dzi); + float rotationYaw = (float) (-Math.atan2(dyi, var7)); + rotationPitchArray[i1]=rotationPitch; + rotationYawArray[i1]=rotationYaw; + translationX[i1]=dxi; + translationY[i1]=dyi; + translationZ[i1]=dzi; + } + if(this.nextAnchorEntity instanceof NodeEntity) + { + NodeEntity next = (NodeEntity) this.nextAnchorEntity; + next.dx0=dx1; + next.dy0=dy1; + next.dz0=dz1; + } + } + } + if(--this.checkTimer<=0) + { + if(!worldObj.isRemote) + { + WorldServer world = MinecraftServer.getServer().worldServerForDimension(this.anchorDimensionId); + TileEntity te = world.getTileEntity(this.anchorX, this.anchorY, this.anchorZ); + if(te==null || !(te instanceof ICableHolder || te instanceof IMultiPowerCableHolder)) + { + this.setDead(); + } + else + { + if(te instanceof ICableHolder) + { + if(((ICableHolder)te).isCableRemoved(this.chainUniqueID)) + { + this.setDead(); + } + } + if(te instanceof IMultiPowerCableHolder) + { + if(((IMultiPowerCableHolder)te).isCableRemoved(this.chainUniqueID)) + { + this.setDead(); + } + } + } + } + this.checkTimer=200; + } + } + + @Override + protected void readEntityFromNBT(NBTTagCompound nbt) + { + this.setChainUniqueID(nbt.getInteger("chainUniqueID")); + this.chainArrangeNumber=nbt.getInteger("chainArrangeNumber"); + this.anchorX=nbt.getInteger("anchorX"); + this.anchorY=nbt.getInteger("anchorY"); + this.anchorZ=nbt.getInteger("anchorZ"); + this.anchorFacing=nbt.getShort("anchorFacing"); + this.anchorDimensionId=nbt.getInteger("anchorDimensionId"); + this.type=nbt.getInteger("type"); + this.colorIndex=nbt.getInteger("colorIndex"); + this.shouldFollowPlayer=nbt.getBoolean("shouldFollowPlayer"); + if(nbt.hasKey("width")) + { + this.setSize(nbt.getFloat("width"), nbt.getFloat("height")); + } + this.virtualNodePosX=nbt.getDouble("virtualNodePosX"); + this.virtualNodePosY=nbt.getDouble("virtualNodePosY"); + this.virtualNodePosZ=nbt.getDouble("virtualNodePosZ"); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbt) + { + nbt.setFloat("width", this.width); + nbt.setFloat("height", this.height); + nbt.setInteger("chainUniqueID", this.getChainUniqueID()); + nbt.setInteger("chainArrangeNumber", this.chainArrangeNumber); + nbt.setInteger("anchorX", this.anchorX); + nbt.setInteger("anchorY", this.anchorY); + nbt.setInteger("anchorZ", this.anchorZ); + nbt.setShort("anchorFacing",this.anchorFacing); + nbt.setInteger("anchorDimensionId",this.anchorDimensionId); + nbt.setInteger("type", this.type); + nbt.setInteger("colorIndex", this.colorIndex); + nbt.setBoolean("shouldFollowPlayer",this.shouldFollowPlayer); + nbt.setDouble("virtualNodePosX",this.virtualNodePosX); + nbt.setDouble("virtualNodePosY",this.virtualNodePosY); + nbt.setDouble("virtualNodePosZ",this.virtualNodePosZ); + } + + public void setAnchor(int x, int y, int z, short facing, int dimensionId) + { + this.anchorX=x; + this.anchorY=y; + this.anchorZ=z; + this.anchorFacing=facing; + this.anchorDimensionId=dimensionId; + } + + public boolean playerHasItemStack(EntityPlayer player) + { + int var2; + for (var2 = 0; var2 < player.inventory.mainInventory.length; ++var2) + { + if(this.isItemHasSameChainId(player.inventory.mainInventory[var2])) + { + return true; + } + } + return false; + } + + private boolean isItemHasSameChainId(ItemStack itemStack) + { + if(itemStack!=null) + { + if(itemStack.getItem() instanceof FlexibleCableItem) + { + return itemStack.stackTagCompound.getInteger("chainUID") == this.chainUniqueID; + } + } + return false; + } + + public int getChainUniqueID() { + return chainUniqueID; + } + + public void setChainUniqueID(int chainUniqueID) { + this.chainUniqueID = chainUniqueID; + } + + @Override + public int getId() + { + return this.getEntityId(); + } + + @Override + public void recieveData(ByteBufInputStream byteBufInputStream) + { + try + { + this.setChainUniqueID(byteBufInputStream.readInt()); + this.chainArrangeNumber=byteBufInputStream.readInt(); + this.type=byteBufInputStream.readByte(); + this.colorIndex=byteBufInputStream.readInt(); + this.virtualNodePosX=byteBufInputStream.readDouble(); + this.virtualNodePosY=byteBufInputStream.readDouble(); + this.virtualNodePosZ=byteBufInputStream.readDouble(); + this.shouldFollowPlayer=byteBufInputStream.readBoolean(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + @Override + protected void entityInit() {} + + @Override + public boolean isInvalid() + { + return this.isDead; + } + + public void setVirtualNodePosToNearestPortal() + { + int x0 = (int)this.posX; + int y0 = (int)this.posY; + int z0 = (int)this.posZ; + for(int xi=x0-2;xi<=x0+2;xi++) + { + for(int yi=y0-2;yi<=y0+2;yi++) + { + for(int zi=z0-2;zi<=z0+2;zi++) + { + Block block = worldObj.getBlock(xi, yi, zi); + if(block==Blocks.portal||block==Blocks.end_portal) + { + this.setVirtualNodePos(xi+0.5d, yi+0.5d, zi+0.5d); + return; + } + } + } + } + + } +} diff --git a/ihl/flexible_cable/NodeRender.java b/ihl/flexible_cable/NodeRender.java new file mode 100644 index 0000000..61c272b --- /dev/null +++ b/ihl/flexible_cable/NodeRender.java @@ -0,0 +1,85 @@ +package ihl.flexible_cable; + +import ihl.IHLModInfo; +import ihl.model.IHLModelRenderer; +import ihl.model.ModelTube; +import ihl.utils.IHLMathUtils; +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBox; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +public class NodeRender extends Render +{ + + private ModelTube model; + private ModelTube modelThin; + private ResourceLocation tex; + private float scale; + private boolean firstTick=true; + + public NodeRender() + { + super(); + scale = 1F/16F; + model=new ModelTube(null, 0, 0, -4F, -4F, -3F, 8, 8, 6,0f, 0.5f,0.99f, ForgeDirection.NORTH); + modelThin=new ModelTube(null, 0, 0, -1F, -1F, -3F, 2, 2, 6,0f, 0f,0.99f, ForgeDirection.NORTH); + tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/junctionBox.png"); + } + + @Override + public void doRender(Entity entity, double x1, double y1, double z1, float rotationYaw, float iFrame) + { + bindTexture(tex); + GL11.glPushMatrix(); + NodeEntity ne = (NodeEntity) entity; + float x = (float) (ne.lastTickRenderPosX + (ne.renderPosX-ne.lastTickRenderPosX)*iFrame-RenderManager.renderPosX); + float y = (float) (ne.lastTickRenderPosY + (ne.renderPosY-ne.lastTickRenderPosY)*iFrame-RenderManager.renderPosY); + float z = (float) (ne.lastTickRenderPosZ + (ne.renderPosZ-ne.lastTickRenderPosZ)*iFrame-RenderManager.renderPosZ); + GL11.glTranslatef(x, y, z); + GL11.glScalef(0.25F, -0.25F, -0.25F); + int red = ne.colorIndex>>16; + int green = (ne.colorIndex>>8) & 255; + int blue = ne.colorIndex & 255; + for(int i=0;i cableList; + private NBTTagCompound cable; + private double soundRange=10d; + private final static float groundConductivity=0.005f; + private int lastCheckTimer=0; + + public PowerCableNodeEntity(World world) + { + super(world); + } + + @Override + public boolean canBeCollidedWith() + { + return !worldObj.isRemote && !this.noClip; + } + + @Override + public boolean canBePushed() + { + return !worldObj.isRemote && !this.noClip; + } + + public void onUpdate() + { + super.onUpdate(); + if(!worldObj.isRemote) + { + IHLGrid grid = IHLMod.enet.cablesToGrids.get(this.chainUniqueID); + if(grid!=null && grid.energy>0d) + { + double voltage = grid.getSinkVoltage(this); + if(this.onGround && voltage>=10d && this.getMaxAllowableVoltage() 10) + { + for(Object player:worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, AxisAlignedBB.getBoundingBox(this.posX-soundRange,this.posY-soundRange,this.posZ-soundRange, this.posX+soundRange,this.posY+soundRange,this.posZ+soundRange))) + { + if(player instanceof EntityPlayerMP) + { + EntityPlayerMP playerMP = (EntityPlayerMP)player; + playerMP.playerNetServerHandler.sendPacket(new S2APacketParticles("largesmoke",(float)this.posX,(float)this.posY,(float)this.posZ,worldObj.rand.nextFloat()*0.1f-0.05f,0.1f,worldObj.rand.nextFloat()*0.1f-0.05f,0.1f,4)); + } + } + lastCheckTimer=checkTimer; + } + } + if(this.nextAnchorEntity!=null) + { + List entityList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(4d, 4d,4d)); + for(EntityLivingBase elb:entityList) + { + if(elb.boundingBox!=null) + { + if(IHLUtils.isSegmentInsideAABB(elb.boundingBox,this.posX,this.posY,this.posZ,this.nextAnchorEntity.posX,this.nextAnchorEntity.posY,this.nextAnchorEntity.posZ)) + { + this.applyEntityCollision(elb); + } + } + } + } + } + } + } + + @Override + public AxisAlignedBB getCollisionBox(Entity entity) + { + return boundingBox; + } + + + @Override + public void applyEntityCollision(Entity entity) + { + super.applyEntityCollision(entity); + IHLGrid grid = IHLMod.enet.cablesToGrids.get(this.chainUniqueID); + if(entity instanceof EntityLivingBase && grid!=null && grid.energy>=1d) + { + double voltage = grid.getSinkVoltage(this); + if(this.getMaxAllowableVoltage()1000) + { + sendSound(); + IHLMod.proxy.spawnParticleFromServer(3,worldObj, (float)this.posX,(float)this.posY,(float)this.posZ,0f,0f,0f,10f); + } + } + } + } + } + + @Override + protected void readEntityFromNBT(NBTTagCompound nbt) + { + super.readEntityFromNBT(nbt); + if(nbt.hasKey("cable")) + { + this.addCable(nbt.getCompoundTag("cable")); + } + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbt) + { + super.writeEntityToNBT(nbt); + if(this.cable!=null) + { + nbt.setTag("cable",this.cable); + } + } + + @Override + public IHLGrid getGrid() + { + return IHLMod.enet.cablesToGrids.get(this.chainUniqueID); + } + + @Override + public int getGridID() + { + return 0; + } + + @Override + public void setGrid(int newGridID) {} + + @Override + public double getMaxAllowableVoltage() + { + if(this.cable!=null) + { + return this.cable.getInteger("maxVoltage"); + } + else + { + return Integer.MAX_VALUE; + } + } + + @Override + public boolean addCable(NBTTagCompound cable1) + { + this.cable=cable1; + return true; + } + + @Override + public Set getCableList() { + if(cableList==null) + { + cableList=new HashSet(1); + if(this.cable!=null) + { + cableList.add(this.cable); + } + } + return cableList; + } + + @Override + public void removeAttachedChains() {} + + public void sendSound() + { + for(Object player:worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, AxisAlignedBB.getBoundingBox(this.posX-soundRange,this.posY-soundRange,this.posZ-soundRange, this.posX+soundRange,this.posY+soundRange,this.posZ+soundRange))) + { + if(player instanceof EntityPlayerMP) + { + EntityPlayerMP playerMP = (EntityPlayerMP)player; + playerMP.playerNetServerHandler.sendPacket(new S29PacketSoundEffect(IHLModInfo.MODID+":electrocution",this.posX,this.posY,this.posZ,1f,1f)); + } + } + } + + @Override + public double[] getPortPos(EntityLivingBase player) + { + return new double[3]; + } + + @Override + public void remove(NBTTagCompound cable) + { + this.cableList.remove(cable); + } + + @Override + public boolean isCableRemoved(int chainUniqueID) + { + return false; + } + + @Override + public void setCableCheck(boolean b) {} + + @Override + public double getEnergyAmountThisNodeWant() + { + return 0; + } + + @Override + public void injectEnergyInThisNode(double amount, double voltage) {} + +} diff --git a/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java b/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java new file mode 100644 index 0000000..1d13d0a --- /dev/null +++ b/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java @@ -0,0 +1,333 @@ +package ihl.flexible_cable; + +import java.util.Iterator; +import java.util.List; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.core.IC2; +import ic2.core.block.TileEntityBlock; +import ic2.core.block.TileEntityInventory; +import ihl.IHLMod; +import ihl.flexible_cable.IHLGrid; +import ihl.flexible_cable.NodeEntity; +import ihl.interfaces.IEnergyNetNode; +import ihl.interfaces.IMultiPowerCableHolder; +import ihl.utils.IHLUtils; +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.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +public class RectifierTransformerUnitTileEntity extends TileEntityInventory implements INetworkClientTileEntityEventListener, IEnergySink, IMultiPowerCableHolder { + + public boolean addedToEnergyNet=false; + public SubRTUEnergyNetNode[] energyNetNodes = new SubRTUEnergyNetNode[2]; + public float mode = 1f; + public static float modeMultiplier = 2f; + public static float modeMax = 128f; + public static float modeMin = 1/modeMax; + public AxisAlignedBB aabb1;// Input zone "0" + public AxisAlignedBB aabb2;// Output zone "1" + public AxisAlignedBB aabb1_1; + public AxisAlignedBB aabb2_1; + public boolean checkCables=true; + + public RectifierTransformerUnitTileEntity() + { + super(); + for(short i=0;i<2;i++) + { + energyNetNodes[i] = new SubRTUEnergyNetNode(this, i); + } + aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord+1d, this.zCoord, this.xCoord+0.5d, this.yCoord+1.1d, this.zCoord+1d); + aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord+0.5d, this.yCoord+1d, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d); + aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.2d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.3d, this.yCoord+1.5d, this.zCoord+0.55d); + aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.7d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.8d, this.yCoord+1.5d, this.zCoord+0.55d); + } + + @Override + public void onLoaded() + { + super.onLoaded(); + for(short i=0;i<2;i++) + { + energyNetNodes[i].onLoaded(); + } + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + this.setupInteractingSpots(this.getFacing()); + } + + @Override + public void onUnloaded() + { + if (IC2.platform.isSimulating() && this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + super.onUnloaded(); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("mode"); + return fields; + } + + @Override + public void setFacing(short facing1) + { + this.removeAttachedChains(); + short facing2 = (short) Math.max(facing1, 2); + super.setFacing(facing2); + this.setupInteractingSpots(facing2); + } + + public void setupInteractingSpots(short facing2) + { + double yStart=this.yCoord+0.98d; + switch (facing2) + { + case 2: + aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+0.5d, this.yCoord+1.1d, this.zCoord+1d); + aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord+0.5d, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d); + aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.2d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.3d, this.yCoord+1.5d, this.zCoord+0.55d); + aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.7d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.8d, this.yCoord+1.5d, this.zCoord+0.55d); + break; + case 5: + aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+0.5d); + aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord+0.5d, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d); + aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.45d, this.yCoord+1.4d, this.zCoord+0.2d, this.xCoord+0.55d, this.yCoord+1.5d, this.zCoord+0.3d); + aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.45d, this.yCoord+1.4d, this.zCoord+0.7d, this.xCoord+0.55d, this.yCoord+1.5d, this.zCoord+0.8d); + break; + case 3: + aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+0.5d, this.yCoord+1.1d, this.zCoord+1d); + aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.5d, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d); + aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.2d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.3d, this.yCoord+1.5d, this.zCoord+0.55d); + aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.7d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.8d, this.yCoord+1.5d, this.zCoord+0.55d); + break; + case 4: + aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+0.5d); + aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord+0.5d, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d); + aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.45d, this.yCoord+1.4d, this.zCoord+0.2d, this.xCoord+0.55d, this.yCoord+1.5d, this.zCoord+0.3d); + aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.45d, this.yCoord+1.4d, this.zCoord+0.7d, this.xCoord+0.55d, this.yCoord+1.5d, this.zCoord+0.8d); + break; + default: + aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+0.5d, this.yCoord+1.1d, this.zCoord+1d); + aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord+0.5d, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d); + aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.2d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.3d, this.yCoord+1.5d, this.zCoord+0.55d); + aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.7d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.8d, this.yCoord+1.5d, this.zCoord+0.55d); + break; + } + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("rectifierTransformerUnit"); + } + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return this.getFacing()!=(short)side; + } + + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + NBTTagList energyNetNodeNBTList = new NBTTagList(); + for(SubRTUEnergyNetNode node:this.energyNetNodes) + { + energyNetNodeNBTList.appendTag(node.writeToNBT()); + } + nbt.setTag("energyNetNodes", energyNetNodeNBTList); + nbt.setFloat("mode",this.mode); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + NBTTagList energyNetNodeNBTList=nbt.getTagList("energyNetNodes", 10); + for(int i=0;i<2;i++) + { + this.energyNetNodes[i].readFromNBT(energyNetNodeNBTList.getCompoundTagAt(i)); + } + this.mode=nbt.getFloat("mode"); + this.mode=this.mode==0f?1f:this.mode; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + switch(event) + { + case 0: + break; + } + } + + public void switchModeUp() + { + if(this.mode=1d) + { + this.energyNetNodes[1].getGrid().injectEnergy(0, 400d*this.mode, this.energyNetNodes[1]); + } + } + IC2.network.get().updateTileEntityField(this, "mode"); + } + } + + public void switchModeDown() + { + if(this.mode>modeMin) + { + this.mode/=modeMultiplier;; + if(this.energyNetNodes[1].getGridID()!=-1) + { + if(this.energyNetNodes[0].getGridID()!=-1) + { + this.energyNetNodes[1].getGrid().injectEnergy(0, this.energyNetNodes[0].getGrid().getSinkVoltage(this.energyNetNodes[0])*this.mode, this.energyNetNodes[1]); + } + else if(this.energyNetNodes[1].getGrid().energy>=1d) + { + this.energyNetNodes[1].getGrid().injectEnergy(0, 400d*this.mode, this.energyNetNodes[1]); + } + } + IC2.network.get().updateTileEntityField(this, "mode"); + } + } + + @Override + public void onNetworkUpdate(String field) + { + if (field.equals("facing") && this.prevFacing != this.getFacing()) + { + this.setupInteractingSpots(this.getFacing()); + } + super.onNetworkUpdate(field); + } + + + @Override + public void updateEntityServer() + { + + } + + @Override + public String getInventoryName() + { + return "RTU"; + } + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter,ForgeDirection direction) + { + return !direction.equals(ForgeDirection.UP); + } + + @Override + public double getDemandedEnergy() + { + if(this.energyNetNodes[1].getGridID()!=-1 && this.energyNetNodes[1].getGrid().energy<1D) + { + return Integer.MAX_VALUE; + } + else + { + return 0d; + } + } + + @Override + public int getSinkTier() + { + return 4; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) + { + if(getDemandedEnergy()>0d) + { + this.energyNetNodes[1].getGrid().injectEnergy(amount, 400d*this.mode, this.energyNetNodes[1]); + return 0d; + } + return amount; + } + + public boolean isCableRemoved(int chainUniqueID) + { + if(!checkCables) + { + return false; + } + for(SubRTUEnergyNetNode sen:energyNetNodes) + { + if(!sen.isCableRemoved(chainUniqueID)) + { + return false; + } + } + return true; + } + + @Override + public IEnergyNetNode getEnergyNetNode(short facing) + { + return this.energyNetNodes[facing]; + } + + @Override + public short getSide(EntityPlayer player) + { + if(IHLUtils.isPlayerLookingAt(player, aabb1)) + { + return 0; + } + else if(IHLUtils.isPlayerLookingAt(player, aabb2)) + { + return 1; + } + else + { + return -1; + } + } + + @Override + public void removeAttachedChains() + { + for(short i=0;i<2;i++) + { + energyNetNodes[i].removeAttachedChains(); + } + + } + + +} diff --git a/ihl/flexible_cable/SetOfDiesMiniGUI.java b/ihl/flexible_cable/SetOfDiesMiniGUI.java new file mode 100644 index 0000000..c00a19b --- /dev/null +++ b/ihl/flexible_cable/SetOfDiesMiniGUI.java @@ -0,0 +1,87 @@ +package ihl.flexible_cable; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.regex.Pattern; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import ihl.IHLMod; +import ihl.interfaces.ItemMiniGUI; +import ihl.utils.IHLUtils; + +public class SetOfDiesMiniGUI extends ItemMiniGUI +{ + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIIronWorkbench.png"); + private int transverseSectionValue; + private GuiTextField transverseSectionTextField; + private boolean leftMouseButtonPressed=false; + private int xPos; + private int yPos; + + 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)); + 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); + this.transverseSectionTextField.drawTextBox(); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("mm\u00B2"), xPos+110, yPos+4, 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)); + } + if(mouseX>=xPos+78 && mouseX<=xPos+78+28 && mouseY>=yPos+3 && mouseY<=yPos+3+11) + { + this.transverseSectionTextField.setFocused(true); + } + return mouseX>=xPos && mouseX<=xPos+202 && mouseY>=yPos && mouseY<=yPos+25; + } + + @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)); + 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); + } + +} diff --git a/ihl/flexible_cable/SubAnchorEnergyNetNode.java b/ihl/flexible_cable/SubAnchorEnergyNetNode.java new file mode 100644 index 0000000..6b84dd8 --- /dev/null +++ b/ihl/flexible_cable/SubAnchorEnergyNetNode.java @@ -0,0 +1,337 @@ +package ihl.flexible_cable; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import ic2.api.energy.EnergyNet; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergyConductor; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.energy.tile.IEnergySource; +import ic2.core.IC2; +import ihl.IHLMod; +import ihl.interfaces.IEnergyNetNode; +import ihl.utils.IHLUtils; + +public class SubAnchorEnergyNetNode implements IEnergyNetNode{ + + private AnchorTileEntity base; + private short facing; + private int gridID=-1; + private Set cableList = new HashSet(); + + public SubAnchorEnergyNetNode(AnchorTileEntity base1, short facing1) + { + base=base1; + facing=facing1; + } + + @Override + public double[] getPortPos(EntityLivingBase player) + { + double d=0.5D; + double f=-0.05D; + switch(facing) + { + case 0: + return new double[]{ + (base.xCoord+d), + (base.yCoord+1D-f), + (base.zCoord+0.5D)}; + case 1: + return new double[]{ + (base.xCoord+d), + (base.yCoord+f), + (base.zCoord+0.5D)}; + case 2: + return new double[]{ + (base.xCoord+0.5D), + (base.yCoord+d), + (base.zCoord+1D-f)}; + case 3: + return new double[]{ + (base.xCoord+0.5D), + (base.yCoord+d), + (base.zCoord+f)}; + case 4: + return new double[]{ + (base.xCoord+1D-f), + (base.yCoord+d), + (base.zCoord+0.5D)}; + case 5: + return new double[]{ + (base.xCoord+f), + (base.yCoord+d), + (base.zCoord+0.5D)}; + default: + return new double[]{ + (base.xCoord+f), + (base.yCoord+d), + (base.zCoord+0.5D)}; + } + } + + @Override + public IHLGrid getGrid() + { + if(gridID!=-1) + { + return IHLMod.enet.getGrid(gridID); + } + else + { + return null; + } + } + + @Override + public int getGridID() + { + return gridID; + } + + @Override + public void setGrid(int newgridID) + { + if(IC2.platform.isSimulating()&& base.addedToEnergyNet && base.getWorldObj()!=null) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(base)); + base.addedToEnergyNet = false; + } + if(newgridID!=-1) + { + this.gridID=newgridID; + IHLMod.enet.getGrid(newgridID).add(this); + } + else + { + this.gridID=-1; + } + if (IC2.platform.isSimulating()&& !base.addedToEnergyNet && base.getWorldObj()!=null) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(base)); + base.addedToEnergyNet = true; + } + } + + @Override + public double getMaxAllowableVoltage() + { + return 64000d; + } + + @Override + public boolean addCable(NBTTagCompound cable) + { + base.hasCableOnSide[this.facing]=true; + return this.cableList.add(cable); + } + + @Override + public Set getCableList() { + return cableList; + } + + @Override + public void removeAttachedChains() + { + IHLUtils.removeChains(this,this.base.getWorldObj()); + } + + public void onLoaded() + { + if(gridID!=-1) + { + IHLGrid grid = IHLMod.enet.getGrid(gridID); + grid.add(this); + } + } + + public NBTTagCompound writeToNBT() + { + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagList cableNBTList = new NBTTagList(); + for(NBTTagCompound cable:this.cableList) + { + cableNBTList.appendTag(cable); + } + nbt.setTag("cableList", cableNBTList); + nbt.setInteger("gridID", this.gridID); + return nbt; + } + + public void readFromNBT(NBTTagCompound nbt) { + NBTTagList cableNBTList=nbt.getTagList("cableList", 10); + for(int i=0;i0d) + { + double drainedEnergy = Math.min(amount, this.getGrid().energy); + this.getGrid().drawEnergy(drainedEnergy, this); + return drainedEnergy; + } + return 0D; + } + + public double getVoltage() + { + if(this.gridID==-1) + { + return 0D; + } + else + { + return this.getGrid().getSinkVoltage(this); + } + } + + @Override + public void remove(NBTTagCompound cable) + { + if(this.cableList.remove(cable)) + { + IHLUtils.removeChain(cable, this); + } + if(this.cableList.isEmpty()) + { + base.hasCableOnSide[this.facing]=false; + base.checkIfNoCablesLeft(); + } + } + + public double injectEnergyToGrid(double amount) + { + if(this.gridID==-1) + { + return amount; + } + else + { + this.getGrid().injectEnergy(amount, 400d, this); + return 0d; + } + } + + @Override + public boolean isCableRemoved(int chainUniqueID) { + for(NBTTagCompound cable:this.cableList) + { + if(cable.getInteger("chainUID")==chainUniqueID) + { + return false; + } + } + return true; + } + + @Override + public void setCableCheck(boolean b) + { + base.checkCables=b; + } + + @Override + public double getEnergyAmountThisNodeWant() + { + Set teset = new HashSet(); + ForgeDirection direction = ForgeDirection.getOrientation(this.facing).getOpposite(); + TileEntity te = EnergyNet.instance.getNeighbor(this.base, direction); + teset.add(te); + TileEntity te1 = this.base.getSink(te, teset); + if(te1==this.base) + { + return 0d; + } + if(te instanceof IEnergySink) + { + return ((IEnergySink)te).getDemandedEnergy(); + } + return 0d; + } + + public double getEnergyOfferedByGrid() + { + if(this.gridID==-1) + { + return 0D; + } + else + { + return Math.max(this.getGrid().energy,0d); + } + } + + @Override + public void injectEnergyInThisNode(double amount, double voltage) + { + Set teset = new HashSet(); + ForgeDirection direction = ForgeDirection.getOrientation(this.facing).getOpposite(); + TileEntity te = EnergyNet.instance.getNeighbor(this.base, direction); + teset.add(te); + TileEntity te1 = this.base.getSink(te, teset); + if(te1==this.base) + { + return; + } + if(te1!=null && voltage>500D) + { + if(te1 instanceof IEnergyNetNode) + { + if(((IEnergyNetNode)te1).getMaxAllowableVoltage() cableList = new HashSet(); + + public SubRTUEnergyNetNode(RectifierTransformerUnitTileEntity base1, short facing1) + { + base=base1; + side=facing1; + } + + @Override + public double[] getPortPos(EntityLivingBase player) + { + double d=0.5D; + double f=0.25D; + double h=1.45d; + switch(base.getFacing()) + { + case 0: + case 1: + case 2: + switch(side) + { + case 0: + return new double[]{ + (base.xCoord+f), + (base.yCoord+h), + (base.zCoord+d)}; + case 1: + return new double[]{ + (base.xCoord+1d-f), + (base.yCoord+h), + (base.zCoord+d)}; + } + case 3: + switch(side) + { + case 1: + return new double[]{ + (base.xCoord+f), + (base.yCoord+h), + (base.zCoord+d)}; + case 0: + return new double[]{ + (base.xCoord+1d-f), + (base.yCoord+h), + (base.zCoord+d)}; + } + case 4: + switch(side) + { + case 1: + return new double[]{ + (base.xCoord+d), + (base.yCoord+h), + (base.zCoord+f)}; + case 0: + return new double[]{ + (base.xCoord+d), + (base.yCoord+h), + (base.zCoord+1d-f)}; + } + case 5: + switch(side) + { + case 0: + return new double[]{ + (base.xCoord+d), + (base.yCoord+h), + (base.zCoord+f)}; + case 1: + return new double[]{ + (base.xCoord+d), + (base.yCoord+h), + (base.zCoord+1d-f)}; + } + default: + return new double[]{ + (base.xCoord+1d-f), + (base.yCoord+h), + (base.zCoord+d)}; + } + } + + @Override + public IHLGrid getGrid() + { + if(gridID!=-1) + { + return IHLMod.enet.getGrid(gridID); + } + else + { + return null; + } + } + + @Override + public int getGridID() + { + return gridID; + } + + @Override + public void setGrid(int newgridID) + { + if(IC2.platform.isSimulating()&& base.addedToEnergyNet && base.getWorldObj()!=null) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(base)); + base.addedToEnergyNet = false; + } + if(newgridID!=-1) + { + this.gridID=newgridID; + IHLMod.enet.getGrid(newgridID).add(this); + } + else + { + this.gridID=-1; + } + if (IC2.platform.isSimulating()&& !base.addedToEnergyNet && base.getWorldObj()!=null) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(base)); + base.addedToEnergyNet = true; + } + } + + @Override + public double getMaxAllowableVoltage() + { + return 64000d; + } + + @Override + public boolean addCable(NBTTagCompound cable) + { + return this.cableList.add(cable); + } + + @Override + public Set getCableList() { + return cableList; + } + + @Override + public void removeAttachedChains() + { + IHLUtils.removeChains(this,this.base.getWorldObj()); + } + + public void onLoaded() + { + if(gridID!=-1) + { + IHLGrid grid = IHLMod.enet.getGrid(gridID); + grid.add(this); + } + } + + public NBTTagCompound writeToNBT() + { + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagList cableNBTList = new NBTTagList(); + for(NBTTagCompound cable:this.cableList) + { + cableNBTList.appendTag(cable); + } + nbt.setTag("cableList", cableNBTList); + nbt.setInteger("gridID", this.gridID); + return nbt; + } + + public void readFromNBT(NBTTagCompound nbt) { + NBTTagList cableNBTList=nbt.getTagList("cableList", 10); + for(int i=0;i +{ + 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 new file mode 100644 index 0000000..343f522 --- /dev/null +++ b/ihl/guidebook/IHLGuidebookGui.java @@ -0,0 +1,288 @@ +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.client.renderer.texture.ITextureObject; +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 GuiInvisibleButton prevPageAreaButton; + private GuiInvisibleButton nextPageAreaButton; + 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 int textBlockNumberOnPageTurn=0; + private int stringNumberOnPageTurn=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 textRowInRightPage=0; + private int textBlockInRightPage=0; + 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; + prevPageAreaButton = new GuiInvisibleButton(0, x, y, xSize/2, 162, linksCoordinatesMap, buttonList); + nextPageAreaButton = 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 new file mode 100644 index 0000000..e616455 --- /dev/null +++ b/ihl/guidebook/IHLGuidebookItem.java @@ -0,0 +1,63 @@ +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 new file mode 100644 index 0000000..b945ae3 --- /dev/null +++ b/ihl/guidebook/IHLGuidebookSlot.java @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000..dc13ce2 --- /dev/null +++ b/ihl/handpump/AdvancedHandPump.java @@ -0,0 +1,354 @@ +package ihl.handpump; + +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.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +import ic2.api.item.ElectricItem; +import ic2.api.item.IC2Items; +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; + +public class AdvancedHandPump extends IHLHandPump { + + public AdvancedHandPump() + { + super(); + this.maxCharge=IHLMod.config.advancedHandpumpMaxCharge; + this.operationEUCost=IHLMod.config.advancedHandpumpOperationEUCost; + this.tier=IHLMod.config.advancedHandpumpTier; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) + { + MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world); + if(movingobjectposition!=null) + { + int x=movingobjectposition.blockX; + int y=movingobjectposition.blockY; + int z=movingobjectposition.blockZ; + Block block = world.getBlock(x, y, z); + if(!block.getMaterial().isLiquid()) + { + y++; + block = world.getBlock(x, y, z); + if(!block.getMaterial().isLiquid()) + { + return itemStack; + } + } + if(world.isRemote && ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer)) + { + entityPlayer.playSound(IHLModInfo.MODID+":handpumpOne", (float) (Math.random()*0.2D+0.6D), (float) (Math.random()*0.1D+0.9D)); + return itemStack; + } + else + { + BlockWithCoordinates blockXYZ = this.searchSource(world, x, y, z); + if(blockXYZ==null) + { + return itemStack; + } + block = blockXYZ.block; + FluidStack fluid1 = null; + if(block instanceof BlockFluidBase) + { + 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) + { + fluid1 = new FluidStack(FluidRegistry.WATER, 1000); + } + else if(block==Blocks.lava||block==Blocks.flowing_lava||block==IHLMod.flowing_lava) + { + fluid1 = new FluidStack(FluidRegistry.LAVA, 1000); + } + int amount2=0; + ItemStack stack = this.getItemStackContains(fluid1, entityPlayer); + if(stack!=null && fluid1 != null) + { + amount2 = LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, true); + } + if(amount2 >0) + { + if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer)) + { + fluid1.amount=Integer.MAX_VALUE; + int countFreeAmount = this.countAmountOfEmptyFluidCells(Ic2Items.FluidCell, fluid1, entityPlayer); + Set blockXYZSet = this.searchSourcesAndDestroyThem(world, blockXYZ, countFreeAmount/1000); + int countDestroedSources = blockXYZSet.size(); + this.destroyAllSources(world, blockXYZSet); + ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false); + this.fillUniversalFluidCells(fluid1, entityPlayer,countDestroedSources); + entityPlayer.inventoryContainer.detectAndSendChanges(); + } + return itemStack; + } + else if(entityPlayer.inventory.hasItemStack(IC2Items.getItem("cell"))) + { + if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer)) + { + int countCells = this.countEmptyCells(IC2Items.getItem("cell"), entityPlayer); + Set blockXYZSet = this.searchSourcesAndDestroyThem(world, blockXYZ, countCells); + int countDestroedSources = blockXYZSet.size(); + this.destroyAllSources(world, blockXYZSet); + ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false); + this.fillFluidCells(fluid1, entityPlayer, countDestroedSources); + entityPlayer.inventoryContainer.detectAndSendChanges(); + return itemStack; + } + } + } + } + return itemStack; + } + + private void destroyAllSources(World world,Set blockXYZSet) + { + Iterator iterator = blockXYZSet.iterator(); + while(iterator.hasNext()) + { + BlockWithCoordinates blockXYZ = iterator.next(); + blockXYZ.setMetadataOrDestroyBlock(world, 1, 7); + } + } + + private void fillUniversalFluidCells(FluidStack fluid1, EntityPlayer entityPlayer, + int countDestroedSources) { + fluid1.amount=countDestroedSources*1000; + //System.out.println("countDestroedSources="+countDestroedSources); + //System.out.println("fluidStackAmount="+fluid1.amount); + a:for (int i=0;i=1000 && entityPlayer.inventory.getStackInSlot(i).stackSize>=1 && amount2>0) + { + amount2 = LiquidUtil.fillContainerStack(entityPlayer.inventory.getStackInSlot(i), entityPlayer, fluid1, false); + fluid1.amount-=amount2; + } + if(fluid1.amount<1000) + { + break a; + } + } + } + } + } + + private void fillFluidCells(FluidStack fluid1, EntityPlayer player, int countDestroedSources) { + ItemStack cell = IHLFluid.getCell(fluid1.getFluid().getName()); + if(cell==null) + { + return; + } + ItemStack emptyCells = IC2Items.getItem("cell").copy(); + emptyCells.stackSize=player.inventory.clearInventory(IC2Items.getItem("cell").getItem(),0)-countDestroedSources; + cell.stackSize=countDestroedSources; + IHLUtils.addItemStackToInventory(player, cell); + if(emptyCells.stackSize>0) + { + IHLUtils.addItemStackToInventory(player, emptyCells); + } + } + + private Set searchSourcesAndDestroyThem(World world, BlockWithCoordinates blockXYZ, int countCells) + { + int startx = blockXYZ.x; + int starty = blockXYZ.y; + int startz = blockXYZ.z; + int currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz); + HashSet outputSet = new HashSet(); + for (int i=0; i<256;i++) + { + if(getFlowDecay(world, blockXYZ, startx, starty+1, startz)>=0) + { + starty++; + currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz); + } + + else if(getFlowDecay(world, blockXYZ, startx+1, starty+1, startz)>=0) + { + starty++; + startx++; + currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz); + } + + else if(getFlowDecay(world, blockXYZ, startx-1, starty+1, startz)>=0) + { + starty++; + startx--; + currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz); + } + + else if(getFlowDecay(world, blockXYZ, startx, starty+1, startz+1)>=0) + { + starty++; + startz++; + currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz); + } + + else if(getFlowDecay(world, blockXYZ, startx, starty+1, startz-1)>=0) + { + starty++; + startz--; + currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz); + } + //Start checking neighbor blocks to lower flow decay. + else if(getFlowDecay(world, blockXYZ, startx-1, starty, startz) xyzlist = new ArrayList(); + if(currentFlowDecay==0) + { + xyzlist.add(new XYZ(startx, starty, startz)); + outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0)); + int listPos=0; + for(int i=0;i<=countCells;i++) + { + if(getFlowDecay(world, blockXYZ, 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; + outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0)); + } + else if(getFlowDecay(world, blockXYZ, 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; + outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0)); + } + else if(getFlowDecay(world, blockXYZ, 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; + outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0)); + } + else if(getFlowDecay(world, blockXYZ, 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; + outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0)); + } + else + { + if(listPos>0) + { + listPos--; + XYZ xyz = xyzlist.get(listPos); + startx=xyz.x; + starty=xyz.y; + startz=xyz.z; + } + } + } + } + return outputSet; + } + + private int countEmptyCells(ItemStack fluidCell, EntityPlayer player) { + int num=0; + ItemStack[] inv = player.inventory.mainInventory; + for (int i=0;i<=35;i++) + { + if(inv[i]!=null) + { + if(inv[i].getItem() == fluidCell.getItem()) + { + if(FluidContainerRegistry.isEmptyContainer(inv[i])) + { + num+=inv[i].stackSize; + } + } + } + } + return num; + } + + private int countAmountOfEmptyFluidCells(ItemStack fluidCell, FluidStack fluid, EntityPlayer entityPlayer) { + int num=0; + for (int i=0;imaxMeta) + { + return world.setBlockToAir(x, y, z); + } + else if(isWaterBlock() && IHLMod.cccFiniteWater) + { + if(world.setBlock(x,y,z,Blocks.flowing_water,meta,3)) + { + world.scheduleBlockUpdate(x,y,z,Blocks.flowing_water,2); + return true; + } + 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)) + { + world.scheduleBlockUpdate(x,y,z,Blocks.flowing_lava,2); + return true; + } + return false; + } + return world.setBlockMetadataWithNotify(x, y, z, meta, 3); +} + +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; + } + else if(isLavaBlock()) + { + return block2==Blocks.lava||block2==Blocks.flowing_lava||block2==IHLMod.flowing_lava; + } + else + { + return block2==block; + } +} + +public boolean isWaterBlock() +{ + if(block==Blocks.water||block==Blocks.flowing_water||block==IHLMod.flowing_water) + { + return true; + } + return false; +} + +public boolean isLavaBlock() +{ + if(block==Blocks.lava||block==Blocks.flowing_lava||block==IHLMod.flowing_lava) + { + return true; + } + return false; +} + +@Override +public boolean equals(Object other) +{ + if(other instanceof BlockWithCoordinates) + { + BlockWithCoordinates bwc = (BlockWithCoordinates)other; + return bwc.block==this.block && bwc.x==this.x && bwc.y==this.y && bwc.z==this.z; + } + return false; +} + +} diff --git a/ihl/handpump/IHLHandPump.java b/ihl/handpump/IHLHandPump.java new file mode 100644 index 0000000..b04b3a0 --- /dev/null +++ b/ihl/handpump/IHLHandPump.java @@ -0,0 +1,350 @@ +package ihl.handpump; + +import java.util.LinkedList; +import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +import ic2.api.item.ElectricItem; +import ic2.api.item.IC2Items; +import ic2.api.item.IElectricItem; +import ic2.api.item.IBoxable; +import ic2.api.item.IItemHudInfo; +import ic2.core.item.resources.ItemCell; +import ic2.core.util.LiquidUtil; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.IHLMod; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; + +public class IHLHandPump extends Item implements IElectricItem, IBoxable, IItemHudInfo { + + protected int tier=1; + protected int maxCharge=30000; + protected int operationEUCost=600; + protected int transferLimit = 2000; + + public IHLHandPump() + { + super(); + this.setMaxDamage(27); + this.maxCharge=IHLMod.config.handpumpMaxCharge; + this.operationEUCost=IHLMod.config.handpumpOperationEUCost; + this.tier=IHLMod.config.handpumpTier; + this.setCreativeTab(IHLCreativeTab.tab); + this.maxStackSize=1; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) + { + MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world); + if(movingobjectposition!=null) + { + int x=movingobjectposition.blockX; + int y=movingobjectposition.blockY; + int z=movingobjectposition.blockZ; + Block block = world.getBlock(x, y, z); + if(!block.getMaterial().isLiquid()) + { + y++; + block = world.getBlock(x, y, z); + if(!block.getMaterial().isLiquid()) + { + return itemStack; + } + } + if(world.isRemote && ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer)) + { + entityPlayer.playSound(IHLModInfo.MODID+":handpumpOne", (float) (Math.random()*0.2D+0.6D), (float) (Math.random()*0.1D+0.9D)); + return itemStack; + } + else + { + BlockWithCoordinates blockXYZ = this.searchSource(world, x, y, z); + if(blockXYZ==null) + { + return itemStack; + } + block = blockXYZ.block; + FluidStack fluid1 = null; + if(block instanceof BlockFluidBase) + { + fluid1 = ((BlockFluidBase)block).drain(world, blockXYZ.x, blockXYZ.y, blockXYZ.z, false); + } + else if(blockXYZ.isWaterBlock()) + { + fluid1 = new FluidStack(FluidRegistry.WATER, 1000); + } + else if(blockXYZ.isLavaBlock()) + { + fluid1 = new FluidStack(FluidRegistry.LAVA, 1000); + } + int amount2=0; + ItemStack stack = this.getItemStackContains(fluid1, entityPlayer); + if(stack!=null && fluid1 != null) + { + amount2 = LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, true); + } + if(amount2 > 0) + { + if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer) && blockXYZ.setMetadataOrDestroyBlock(world, blockXYZ.meta+1,7)) + { + ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false); + LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, false); + entityPlayer.inventoryContainer.detectAndSendChanges(); + } + return itemStack; + } + else if(entityPlayer.inventory.hasItemStack(IC2Items.getItem("cell"))) + { + if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer) && blockXYZ.setMetadataOrDestroyBlock(world, blockXYZ.meta+1,7)) + { + ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false); + this.fillFluidCell(fluid1, entityPlayer); + entityPlayer.inventoryContainer.detectAndSendChanges(); + return itemStack; + } + } + } + } + return itemStack; + } + + + protected ItemStack getItemStackContains(FluidStack fluidStack, EntityPlayer player) { + for (int i=0;i 0) + { + return player.inventory.getStackInSlot(i); + } + } + } + } + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":itemElectricHandpump"); + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return false; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return this.maxCharge; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return this.transferLimit; + } + + @Override + public int getTier(ItemStack itemStack) { + return this.tier; + } + + @Override + public List getHudInfo(ItemStack itemStack) { + LinkedList info = new LinkedList(); + info.add(ElectricItem.manager.getToolTip(itemStack)); + info.add("Power Tier: " + this.tier); + return info; + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) + { + info.add("PowerTier: " + this.tier); + } + + @Override + public boolean canBeStoredInToolbox(ItemStack itemstack) { + return true; + } + + @Override + public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2) + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + 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; + } + + protected void fillFluidCell(FluidStack fluid1, EntityPlayer player) + { + ItemStack cell = IHLFluid.getCell(fluid1.getFluid().getName()); + if(cell==null) + { + return; + } + ItemStack[] inv = player.inventory.mainInventory; + for (int i=0;i<=35;i++) + { + if(inv[i]!=null) + { + if(inv[i].getItem() instanceof ItemCell) + { + if(inv[i].getItemDamage()==0) + { + if (IHLUtils.addItemStackToInventory(player, cell)) + { + if(inv[i].stackSize<=1) + { + ItemStack sourceItemStack = inv[i].copy(); + sourceItemStack.stackSize=player.inventory.clearInventory(sourceItemStack.getItem(),0)-1; + if(sourceItemStack.stackSize>0) + { + player.inventory.addItemStackToInventory(sourceItemStack); + } + } + else + { + inv[i].stackSize--; + } + return; + } + } + } + } + } + } + + protected BlockWithCoordinates searchSource(World world, int startx, int starty, int startz) + { + int currentFlowDecay=getFlowDecay(world, startx, starty, startz); + for (int i=0; i<256;i++) + { + if(getFlowDecay(world, startx, starty+1, startz)>=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)=7) + { + world.setBlockToAir(x,y,z); + return; + } + int meta2=16; + int fd; + Block block; + 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 new file mode 100644 index 0000000..d8a9943 --- /dev/null +++ b/ihl/i_hate_liquids/IHLBucketHandler.java @@ -0,0 +1,21 @@ +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 new file mode 100644 index 0000000..cd777ed --- /dev/null +++ b/ihl/i_hate_liquids/IHLEventHandler.java @@ -0,0 +1,59 @@ +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 new file mode 100644 index 0000000..88539dc --- /dev/null +++ b/ihl/i_hate_liquids/InvisibleMagicanEntity.java @@ -0,0 +1,570 @@ +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 timer=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()) + { + this.timer=0; + 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; + } + + private boolean writeLowestFlowPoint() + { + int startx = this.x0; + int starty = this.y0; + int startz = this.z0; + int currentFlowDecay=getFlowDecay(startx, starty, startz); + for (int i=0; i<64;i++) + { + //Go search up, if possible. + if(getFlowDecay(startx, starty+1, startz)>=0) + { + starty++; + currentFlowDecay=getFlowDecay(startx, starty, startz); + } + + else if(getFlowDecay(startx+1, starty+1, startz)>=0) + { + starty++; + startx++; + currentFlowDecay=getFlowDecay(startx, starty, startz); + } + + else if(getFlowDecay(startx-1, starty+1, startz)>=0) + { + starty++; + startx--; + currentFlowDecay=getFlowDecay(startx, starty, startz); + } + + else if(getFlowDecay(startx, starty+1, startz+1)>=0) + { + starty++; + startz++; + currentFlowDecay=getFlowDecay(startx, starty, startz); + } + + else if(getFlowDecay(startx, starty+1, startz-1)>=0) + { + starty++; + startz--; + currentFlowDecay=getFlowDecay(startx, starty, startz); + } + //Start checking neighbor blocks to lower flow decay. + else if(getFlowDecay(startx-1, starty, startz)=7) + { + this.worldObj.setBlockToAir(startx, starty, startz); + } + else + { + this.worldObj.setBlockMetadataWithNotify(startx, starty, startz, currentFlowDecay+1, 0); + } + return false; + } + + 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(); + list.clear(); + 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 new file mode 100644 index 0000000..287b11a --- /dev/null +++ b/ihl/i_hate_liquids/XYZ.java @@ -0,0 +1,26 @@ +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/ICableHolder.java b/ihl/interfaces/ICableHolder.java new file mode 100644 index 0000000..ba9922e --- /dev/null +++ b/ihl/interfaces/ICableHolder.java @@ -0,0 +1,10 @@ +package ihl.interfaces; + +import net.minecraft.entity.EntityLivingBase; + +public interface ICableHolder +{ + double[] getPortPos(EntityLivingBase player); + boolean isCableRemoved(int chainUniqueID); + void setCableCheck(boolean b); +} diff --git a/ihl/interfaces/IDataCableHolder.java b/ihl/interfaces/IDataCableHolder.java new file mode 100644 index 0000000..1bdaba1 --- /dev/null +++ b/ihl/interfaces/IDataCableHolder.java @@ -0,0 +1,18 @@ +package ihl.interfaces; + +import ihl.datanet.Contact; +import ihl.processing.invslots.InvSlotSignalProcessor; + +import java.util.Set; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +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 new file mode 100644 index 0000000..d13af00 --- /dev/null +++ b/ihl/interfaces/IDataNode.java @@ -0,0 +1,21 @@ +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/IEnergyNetNode.java b/ihl/interfaces/IEnergyNetNode.java new file mode 100644 index 0000000..ae99eaf --- /dev/null +++ b/ihl/interfaces/IEnergyNetNode.java @@ -0,0 +1,19 @@ +package ihl.interfaces; + +import java.util.Set; + +import net.minecraft.nbt.NBTTagCompound; +import ihl.flexible_cable.IHLGrid; + +public interface IEnergyNetNode extends ICableHolder{ + IHLGrid getGrid(); + int getGridID(); + void setGrid(int newGridID); + double getMaxAllowableVoltage(); + boolean addCable(NBTTagCompound cable); + Set getCableList(); + void removeAttachedChains(); + void remove(NBTTagCompound cable); + double getEnergyAmountThisNodeWant(); + void injectEnergyInThisNode(double amount, double voltage); +} diff --git a/ihl/interfaces/IHasTemperature.java b/ihl/interfaces/IHasTemperature.java new file mode 100644 index 0000000..7c4474d --- /dev/null +++ b/ihl/interfaces/IHasTemperature.java @@ -0,0 +1,4 @@ +package ihl.interfaces; +public interface IHasTemperature { +public int getTemperature(); +} diff --git a/ihl/interfaces/IItemHasMiniGUI.java b/ihl/interfaces/IItemHasMiniGUI.java new file mode 100644 index 0000000..ce7badf --- /dev/null +++ b/ihl/interfaces/IItemHasMiniGUI.java @@ -0,0 +1,13 @@ +package ihl.interfaces; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public interface IItemHasMiniGUI +{ + @SideOnly(Side.CLIENT) + ItemMiniGUI getMiniGUI(GuiContainer gui, Slot slot); +} diff --git a/ihl/interfaces/IMultiPowerCableHolder.java b/ihl/interfaces/IMultiPowerCableHolder.java new file mode 100644 index 0000000..a6b1eba --- /dev/null +++ b/ihl/interfaces/IMultiPowerCableHolder.java @@ -0,0 +1,11 @@ +package ihl.interfaces; + +import net.minecraft.entity.player.EntityPlayer; + +public interface IMultiPowerCableHolder +{ + IEnergyNetNode getEnergyNetNode(short facing); + short getSide(EntityPlayer player); + void removeAttachedChains(); + boolean isCableRemoved(int chainUniqueID); +} diff --git a/ihl/interfaces/INetworkListener.java b/ihl/interfaces/INetworkListener.java new file mode 100644 index 0000000..042177d --- /dev/null +++ b/ihl/interfaces/INetworkListener.java @@ -0,0 +1,13 @@ +package ihl.interfaces; + +import net.minecraft.entity.player.EntityPlayerMP; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; + +public interface INetworkListener +{ + void recieveData(ByteBufInputStream byteBufInputStream); + int getId(); + boolean isInvalid(); + void registerAndSendData(EntityPlayerMP player); +} diff --git a/ihl/interfaces/ISelectionBoxSpecialRenderer.java b/ihl/interfaces/ISelectionBoxSpecialRenderer.java new file mode 100644 index 0000000..2c27f32 --- /dev/null +++ b/ihl/interfaces/ISelectionBoxSpecialRenderer.java @@ -0,0 +1,10 @@ +package ihl.interfaces; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; + +public interface ISelectionBoxSpecialRenderer +{ + public void drawSelectionBox(EntityPlayer player, ItemStack currentItem, MovingObjectPosition movingObjectPosition, float partialTick); +} diff --git a/ihl/interfaces/IWire.java b/ihl/interfaces/IWire.java new file mode 100644 index 0000000..c2a9c0b --- /dev/null +++ b/ihl/interfaces/IWire.java @@ -0,0 +1,9 @@ +package ihl.interfaces; + +import net.minecraft.item.ItemStack; + +public interface IWire { + public String getTag(); + public String getTagSecondary(); + public boolean isSameWire(ItemStack stack1, ItemStack stack2); +} diff --git a/ihl/interfaces/IWorkspaceElement.java b/ihl/interfaces/IWorkspaceElement.java new file mode 100644 index 0000000..7f57ca7 --- /dev/null +++ b/ihl/interfaces/IWorkspaceElement.java @@ -0,0 +1,10 @@ +package ihl.interfaces; + +import ic2.api.tile.IWrenchable; + +public interface IWorkspaceElement extends IWrenchable +{ + boolean canBeUsed(); + void use(); + boolean getIsInvalid(); +} diff --git a/ihl/interfaces/ItemMiniGUI.java b/ihl/interfaces/ItemMiniGUI.java new file mode 100644 index 0000000..3b9a53d --- /dev/null +++ b/ihl/interfaces/ItemMiniGUI.java @@ -0,0 +1,24 @@ +package ihl.interfaces; + +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class ItemMiniGUI +{ + protected final GuiContainer guiBase; + protected final Slot slotBase; + + 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 void onGUIClosed(); +} diff --git a/ihl/items_blocks/ExplosiveBlock.java b/ihl/items_blocks/ExplosiveBlock.java new file mode 100644 index 0000000..225873f --- /dev/null +++ b/ihl/items_blocks/ExplosiveBlock.java @@ -0,0 +1,255 @@ +package ihl.items_blocks; + +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.processing.chemistry.ExplosiveTileEntity; +import ihl.processing.metallurgy.MuffleFurnanceTileEntity; +import java.util.List; + +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.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +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.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ExplosiveBlock extends Block implements ITileEntityProvider{ + + @SideOnly(Side.CLIENT) + IIcon textureSide, + textureBack, + textureTop; + + public ExplosiveBlock() + { + super(Material.tnt); + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName("ihlExplosive"); + this.setHardness(2F); + this.setResistance(1F); + } + + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + if(IC2.platform.isSimulating()) + { + } + } + + @Override + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) + { + ItemStack result = new ItemStack(item); + result.stackTagCompound=new NBTTagCompound(); + result.stackTagCompound.setInteger("explosionType", 0);//0 - IC2; 1- IHL + result.stackTagCompound.setInteger("explosionPower", 100000); + //itemList.add(result); + result = new ItemStack(item); + result.stackTagCompound=new NBTTagCompound(); + result.stackTagCompound.setInteger("explosionType", 1);//0 - IC2; 1- IHL + result.stackTagCompound.setInteger("explosionPower", Integer.MAX_VALUE);//31000 + itemList.add(result); + } + + @Override + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) + { + if(!world.isRemote) + { + TileEntity te = world.getTileEntity(x, y, z); + } + super.onBlockPreDestroy(world, x, y, z, meta); + } + + @Override + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBoundsForItemRender(); + } + + @Override + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) + { + int facing = 3; + TileEntity te = blockAccess.getTileEntity(x, y, z); + if(te!=null && te instanceof IWrenchable) + { + IWrenchable tebh = (IWrenchable) te; + facing=tebh.getFacing(); + } + super.setBlockBoundsBasedOnState(blockAccess, x, y, z); + } + + public static void init() + { + GameRegistry.registerBlock(new ExplosiveBlock(), IHLItemBlock.class,"ihlExplosive"); + GameRegistry.registerTileEntity(ExplosiveTileEntity.class, "explosiveTileEntity"); + ExplosiveType[] var1 = ExplosiveType.values(); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new ExplosiveTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenSide"); + this.textureBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenBack"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenSide"); + this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenTop"); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z){ + TileEntity te = world.getTileEntity(x,y,z); + if(IC2.platform.isSimulating() && te instanceof ExplosiveTileEntity) + { + ((ExplosiveTileEntity)te).createExplosion(player); + } + 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.readFromNBT(itemStack.stackTagCompound); + } + } + + @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, + 2,3,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 instanceof IWrenchable) + { + IWrenchable tebh = (IWrenchable) te; + facing=tebh.getFacing(); + } + return this.getIconFromFacing(facing, side); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + return this.getIconFromFacing(3, side); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromFacing(int facing, int side) + { + return this.textureSide; + } + + @Override + public boolean onBlockEventReceived(World world, int x, int y, int z, int metadata, int flag) + { + return true; + } + + public enum ExplosiveType + { + MuffleFurnace("muffleFurnance",MuffleFurnanceTileEntity.class, true, new ItemStack(Items.brick)); + ExplosiveType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1,ItemStack itemDroppedOnBlockDestroy1) + { + unlocalizedName=unlocalizedName1; + teclass=teclass1; + isNormalBlock=isNormalBlock1; + itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1; + } + String unlocalizedName; + Class teclass; + boolean isNormalBlock=true; + ItemStack itemDroppedOnBlockDestroy; + } + + @Override + public int getRenderType() + { + return 0; + } + + @Override + public boolean isOpaqueCube() + { + return true; + } + + @Override + public boolean renderAsNormalBlock() + { + return true; + } + + @SideOnly(Side.CLIENT) + public IIcon getInnerTextureForBlockRenderer() + { + return this.blockIcon; + } +} diff --git a/ihl/items_blocks/FiberItem.java b/ihl/items_blocks/FiberItem.java new file mode 100644 index 0000000..0682abb --- /dev/null +++ b/ihl/items_blocks/FiberItem.java @@ -0,0 +1,107 @@ +package ihl.items_blocks; + +import java.util.List; + +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.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.interfaces.IWire; + +public class FiberItem extends Item implements IWire { + + protected String info; + protected FiberMaterial material; + private String registryName; + + public FiberItem(FiberMaterial material1, int leadsNum1, String registryName1) + { + super(); + this.registryName=registryName1; + this.material=material1; + this.info=material.description; + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxStackSize(1); + this.setUnlocalizedName(registryName); + } + + public FiberItem() + { + super(); + } + + public static void init() + { + FiberMaterial[] var1 = FiberMaterial.values(); + for(int i=0;i yellowColoredWires = new HashSet(3); + public boolean isDataCable=false; + + public FlexibleCableItem() + { + super(); + yellowColoredWires.add("Gold"); + yellowColoredWires.add("Copper"); + yellowColoredWires.add("Bronze"); + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxStackSize(1); + this.setFull3D(); + instance=this; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tabs, List itemList) + { + itemList.add(IHLUtils.getUninsulatedWire("Copper", 160, 15)); + itemList.add(IHLUtils.getUninsulatedWire("Copper", 160, 240)); + itemList.add(IHLUtils.getUninsulatedWire("Steel", 160, 15)); + itemList.add(IHLUtils.getUninsulatedWire("Steel", 160, 240)); + itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 15,"RawRubber",100)); + itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 240,"RawRubber",100)); + itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 15,"RawRubber",100)); + itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 240,"RawRubber",100)); + itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 15,"Rubber",100)); + itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 240,"Rubber",100)); + itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 15,"Rubber",100)); + itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 240,"Rubber",100)); + } + + public static void init() + { + GameRegistry.registerItem(new FlexibleCableItem(),"copperWire"); + } + + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) + { + TileEntity t = world.getTileEntity(x, y, z); + short facing = IHLUtils.getFacingFromPlayerView(player, true); + if(!world.isRemote && t instanceof IEnergyTile && !(t instanceof IMultiPowerCableHolder) && !(t instanceof ICableHolder)) + { + ForgeDirection direction = ForgeDirection.getOrientation(facing); + x+=direction.offsetX; + y+=direction.offsetY; + z+=direction.offsetZ; + t=world.getTileEntity(x, y, z); + if(IHLUtils.isBlockCanBeReplaced(world, x,y,z)) + { + world.setBlock(x, y, z, IHLMod.cableAnchorBlock); + } + else if(!(t instanceof AnchorTileEntity)) + { + return false; + } + t=world.getTileEntity(x, y, z); + } + if(world.isRemote)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)) && + stack.stackTagCompound.getInteger("fullLength")>=1) + { + double ppx,ppy,ppz; + ICableHolder te; + if(t instanceof IMultiPowerCableHolder) + { + facing = ((IMultiPowerCableHolder)t).getSide(player); + if(facing==-1) + { + return false; + } + else + { + te = ((IMultiPowerCableHolder)t).getEnergyNetNode(facing); + } + } + else + { + te = (ICableHolder)t; + } + ppx=te.getPortPos(player)[0]; + ppy=te.getPortPos(player)[1]; + ppz=te.getPortPos(player)[2]; + if(stack.stackTagCompound.getBoolean("firstConnection")) + { + int x1 = stack.stackTagCompound.getInteger("connectorX"); + int y1 = stack.stackTagCompound.getInteger("connectorY"); + int z1 = stack.stackTagCompound.getInteger("connectorZ"); + int l1=stack.stackTagCompound.getInteger("fullLength"); + int l2=stack.stackTagCompound.getInteger("length"); + if(x==x1 && y==y1 && z==z1) + { + this.cleanUp(stack.stackTagCompound.getInteger("chainUID")); + stack.stackTagCompound.setBoolean("firstConnection", false); + stack.stackTagCompound.setInteger("length", l1); + return true; + } + int t2DimensionId = stack.stackTagCompound.getInteger("connectorDimensionId"); + short facing2 = stack.stackTagCompound.getShort("connectorFacing"); + TileEntity t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x1, y1, z1); + if(t2==null) + { + stack.stackTagCompound.setBoolean("firstConnection", false); + return false; + } + else + { + if(t2 instanceof IMultiPowerCableHolder) + { + te = ((IMultiPowerCableHolder)t).getEnergyNetNode(facing); + } + else + { + te = (ICableHolder)t; + } + te.setCableCheck(true); + } + this.connect(t,facing, t2, facing2, stack); + stack.stackTagCompound.setInteger("fullLength", l2); + if(l2<=0) + { + stack.stackSize--; + } + stack.stackTagCompound.setBoolean("firstConnection", false); + stack.stackTagCompound.setInteger("chainArrangeNumber",stack.stackTagCompound.getInteger("chainArrangeNumber")+1); + x=x1; + y=y1; + z=z1; + } + else + { + te.setCableCheck(false); + stack.stackTagCompound.setBoolean("firstConnection", true); + stack.stackTagCompound.setInteger("connectorX", x); + stack.stackTagCompound.setInteger("connectorY", y); + stack.stackTagCompound.setInteger("connectorZ", z); + stack.stackTagCompound.setShort("connectorFacing", facing); + stack.stackTagCompound.setInteger("connectorDimensionId", world.provider.dimensionId); + stack.stackTagCompound.setInteger("prevDimensionId", world.provider.dimensionId); + stack.stackTagCompound.setInteger("chainArrangeNumber",0); + stack.stackTagCompound.setInteger("chainUID",world.rand.nextInt()); + stack.stackTagCompound.setDouble("prevNodePosX",ppx); + stack.stackTagCompound.setDouble("prevNodePosY",ppy); + stack.stackTagCompound.setDouble("prevNodePosZ",ppz); + } + NodeEntity node = newNode(world, player.posX, player.posY, player.posZ, stack, stack.stackTagCompound.getInteger("chainArrangeNumber"),x,y,z); + node.virtualNodePosX=ppx; + node.virtualNodePosY=ppy; + node.virtualNodePosZ=ppz; + return true; + } + else + { + return false; + } + } + + protected void connect(TileEntity t1,short facing, TileEntity t2, short facing2, ItemStack stack) + { + IEnergyNetNode te; + IEnergyNetNode te1; + if(t1 instanceof IEnergyNetNode) + { + te = (IEnergyNetNode)t1; + } + else + { + te = ((IMultiPowerCableHolder)t1).getEnergyNetNode(facing); + } + if(t2 instanceof IEnergyNetNode) + { + te1 = (IEnergyNetNode)t2; + } + else + { + te1 = ((IMultiPowerCableHolder)t2).getEnergyNetNode(facing2); + } + int newGridID=IHLMod.enet.mergeGrids(te.getGridID(),te1.getGridID()); + int l1=stack.stackTagCompound.getInteger("fullLength"); + int l2=stack.stackTagCompound.getInteger("length"); + NBTTagCompound cable = (NBTTagCompound) stack.stackTagCompound.copy(); + cable.setInteger("length", l1-l2); + cable.setBoolean("firstConnection", false); + cable.setInteger("connectorX1", t1.xCoord); + cable.setInteger("connectorY1", t1.yCoord); + cable.setInteger("connectorZ1", t1.zCoord); + cable.setShort("connectorFacing1", facing); + cable.setInteger("connectorDimensionId1", t1.getWorldObj().provider.dimensionId); + if(te.addCable(cable) && te1.addCable(cable)) + { + te.setGrid(newGridID); + te1.setGrid(newGridID); + } + } + + private int getTransverseSection(ItemStack stack) + { + if(stack.stackTagCompound==null) + { + stack.stackTagCompound=new NBTTagCompound(); + } + return stack.stackTagCompound.getInteger("transverseSection"); + } + + public String getMaterial(ItemStack stack) + { + if(stack.stackTagCompound==null) + { + stack.stackTagCompound=new NBTTagCompound(); + } + return stack.stackTagCompound.getString("material"); + } + + public int getVoltageLimit(ItemStack stack) + { + if(stack.stackTagCompound==null) + { + stack.stackTagCompound=new NBTTagCompound(); + } + if(stack.stackTagCompound.hasKey("maxVoltage")) + { + return stack.stackTagCompound.getInteger("maxVoltage"); + } + return 0; + } + + private long getResistance(ItemStack stack) + { + if(stack.stackTagCompound==null) + { + stack.stackTagCompound=new NBTTagCompound(); + } + return IHLUtils.getResistance(stack.stackTagCompound); + } + + private void cleanUp(int uid) + { + Set cs = IHLMod.proxy.nodeEntityRegistry.get(uid); + if(cs!=null) + { + for(NodeEntity ne:cs) + { + if(ne!=null) + { + ne.setDead(); + } + } + } + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) + { + if(!world.isRemote && stack.stackTagCompound!=null) + { + if(stack.stackTagCompound.getBoolean("firstConnection")) + { + int leight = stack.stackTagCompound.getInteger("length"); + if(leight>0) + { + double pnpx = stack.stackTagCompound.getDouble("prevNodePosX"); + double pnpy = stack.stackTagCompound.getDouble("prevNodePosY"); + double pnpz = stack.stackTagCompound.getDouble("prevNodePosZ"); + double ppx=entity.posX; + double ppy=entity.posY; + double ppz=entity.posZ; + + if(pnpx!=0D && pnpy!=0D && pnpz!=0D) + { + double sqd = (ppx - pnpx)*(ppx - pnpx) + (ppy - pnpy)*(ppy - pnpy) + (ppz - pnpz)*(ppz - pnpz); + if(sqd>2D) + { + int can = stack.stackTagCompound.getInteger("chainArrangeNumber")+1; + int cx = stack.stackTagCompound.getInteger("connectorX"); + int cy = stack.stackTagCompound.getInteger("connectorY"); + int cz = stack.stackTagCompound.getInteger("connectorZ"); + NodeEntity node = newNode(world, ppx, ppy, ppz, stack, can,cx,cy,cz); + node.shouldFollowPlayer=true; + node.virtualNodePosX=ppx+(ppx - pnpx)*2; + node.virtualNodePosY=ppy+(ppy - pnpy)*2; + node.virtualNodePosZ=ppz+(ppz - pnpz)*2; + stack.stackTagCompound.setInteger("chainArrangeNumber",can); + stack.stackTagCompound.setDouble("prevNodePosX",ppx); + stack.stackTagCompound.setDouble("prevNodePosY",ppy); + stack.stackTagCompound.setDouble("prevNodePosZ",ppz); + stack.stackTagCompound.setInteger("length",--leight); + stack.stackTagCompound.setInteger("prevDimensionId", world.provider.dimensionId); + } + } + } + } + } + } + + + public void onPlayerTeleport(PlayerChangedDimensionEvent event) + { + EntityPlayer player = event.player; + for(ItemStack stack:player.inventory.mainInventory) + { + if(stack!=null && stack.getItem() instanceof FlexibleCableItem) + { + if(stack.stackTagCompound.getBoolean("firstConnection")) + { + int can = -1; + Set ns = IHLMod.proxy.nodeEntityRegistry.get(stack.stackTagCompound.getInteger("chainUID")); + if(ns!=null) + { + NodeEntity lastNode = null; + for(NodeEntity node:ns) + { + node.shouldFollowPlayer=false; + if(node.chainArrangeNumber>can) + { + lastNode=node; + can=node.chainArrangeNumber; + } + } + if(lastNode!=null) + { + lastNode.setVirtualNodePosToNearestPortal(); + } + } + double[] cc = IHLUtils.tracePlayerView(player); + can = stack.stackTagCompound.getInteger("chainArrangeNumber")+1; + int cx = stack.stackTagCompound.getInteger("connectorX"); + int cy = stack.stackTagCompound.getInteger("connectorY"); + int cz = stack.stackTagCompound.getInteger("connectorZ"); + int leight = stack.stackTagCompound.getInteger("length"); + NodeEntity node = newNode(MinecraftServer.getServer().worldServerForDimension(event.toDim), cc[0], player.posY, cc[2], stack, can,cx,cy,cz); + node.setVirtualNodePosToNearestPortal(); + stack.stackTagCompound.setInteger("chainArrangeNumber",can); + stack.stackTagCompound.setDouble("prevNodePosX",cc[0]); + stack.stackTagCompound.setDouble("prevNodePosY",cc[1]); + stack.stackTagCompound.setDouble("prevNodePosZ",cc[2]); + stack.stackTagCompound.setInteger("length",--leight); + stack.stackTagCompound.setInteger("prevDimensionId", event.toDim); + } + } + } + } + + + protected NodeEntity newNode(World world, double ppx, double ppy, double ppz, ItemStack stack, int can, int x, int y, int z) + { + PowerCableNodeEntity node = new PowerCableNodeEntity(world); + node.setPosition(ppx, ppy, ppz); + node.setChainUniqueID(stack.stackTagCompound.getInteger("chainUID")); + short facing = stack.stackTagCompound.getShort("connectorFacing"); + int dimensionId = stack.stackTagCompound.getInteger("connectorDimensionId"); + node.setAnchor(x, y, z,facing,dimensionId); + node.chainArrangeNumber=can; + node.colorIndex = this.getColor(stack); + node.addCable((NBTTagCompound) stack.stackTagCompound.copy()); + if(stack.stackTagCompound.hasKey("insulationMaterial")) + { + node.type=1; + } + else + { + node.type=0; + } + world.spawnEntityInWorld(node); + return node; + } + + private int getColor(ItemStack stack) + { + if(!stack.stackTagCompound.hasKey("insulationMaterial")) + { + if(yellowColoredWires.contains(this.getMaterial(stack))) + { + return 0xFF9900; + } + else + { + return 0xAAAABB; + } + } + return 0xFFFFFF; + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) + { + if(itemStack.stackTagCompound!=null) + { + info.add("Length: " + itemStack.stackTagCompound.getInteger("length") +" m"); + info.add("Wire material: " + this.getMaterial(itemStack)); + info.add("Resistivity: " + this.getResistance(itemStack)/1000F + " V^2/(EU*m)"); + info.add("Transverse section: " + this.getTransverseSection(itemStack)/10F + " sq. mm."); + if(itemStack.stackTagCompound.hasKey("insulationMaterial")) + { + info.add("Insulation material: "+this.getInsulationMaterial(itemStack)); + info.add("Insulation thickness: " + this.getInsulationThickness(itemStack)/10f+" mm"); + info.add("Insulation breakdown voltage: "+ this.getVoltageLimit(itemStack)/1000 + " kV"); + } + + } + } + + @Override + public String getTag() + { + return "length"; + } + + @Override + public String getTagSecondary() + { + return "fullLength"; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":copperWire"); + this.thickCopper = par1IconRegister.registerIcon(IHLModInfo.MODID + ":copperWire16x"); + this.thinIron = par1IconRegister.registerIcon(IHLModInfo.MODID + ":steelWire"); + this.thickIron = par1IconRegister.registerIcon(IHLModInfo.MODID + ":steelWire16x"); + this.insulatedIronRawruber = par1IconRegister.registerIcon(IHLModInfo.MODID + ":flexibleCableSteel2"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int i) + { + if(stack.stackTagCompound!=null) + { + if(this.getInsulationMaterial(stack).equals("null")) + { + if(this.getTransverseSection(stack)>=240) + { + if(yellowColoredWires.contains(this.getMaterial(stack))) + { + return this.thickCopper; + } + else + { + return this.thickIron; + } + } + else + { + if(yellowColoredWires.contains(this.getMaterial(stack))) + { + return this.itemIcon; + } + else + { + return this.thinIron; + } + } + } + else + { + return this.insulatedIronRawruber; + } + } + return this.itemIcon; + } + + @Override + public String getUnlocalizedName(ItemStack stack) + { + if(stack.stackTagCompound!=null && !this.getInsulationMaterial(stack).equals("null")) + { + return "cable"; + } + return "wire"; + } + + @Override + public boolean isSameWire(ItemStack stack1,ItemStack stack2) + { + if(stack1.getItem()==stack2.getItem() && stack1.getItemDamage()==stack2.getItemDamage()) + { + if(stack1.stackTagCompound!=null && stack2.stackTagCompound!=null) + { + return this.getMaterial(stack1).equals(this.getMaterial(stack2)) && + this.getTransverseSection(stack1)==this.getTransverseSection(stack2) && + this.getInsulationMaterial(stack1).equals(this.getInsulationMaterial(stack2)) && + this.getInsulationThickness(stack1)==this.getInsulationThickness(stack2); + } + } + return false; + } + + public String getInsulationMaterial(ItemStack stack) + { + if(stack.stackTagCompound.hasKey("insulationMaterial")) + { + return stack.stackTagCompound.getString("insulationMaterial"); + } + return "null"; + } + + public int getInsulationThickness(ItemStack stack) + { + if(stack.stackTagCompound.hasKey("insulationThickness")) + { + return stack.stackTagCompound.getInteger("insulationThickness"); + } + return 0; + } +} diff --git a/ihl/items_blocks/FlexiblePipeItem.java b/ihl/items_blocks/FlexiblePipeItem.java new file mode 100644 index 0000000..5de333f --- /dev/null +++ b/ihl/items_blocks/FlexiblePipeItem.java @@ -0,0 +1,128 @@ +package ihl.items_blocks; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.interfaces.IWire; +import ihl.utils.IHLUtils; + +public class FlexiblePipeItem extends Item implements IWire { + + private static Map iconMap = new HashMap(); + private static Map nameMap = new HashMap(); + private static Map infoMap = new HashMap(); + private static Map materialMap = new HashMap(); + + public FlexiblePipeItem() + { + super(); + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxStackSize(1); + this.setUnlocalizedName("flexiblePipe"); + } + + public static void init() + { + FlexiblePipeItem item = new FlexiblePipeItem(); + Type[] var1 = Type.values(); + GameRegistry.registerItem(item,item.getUnlocalizedName()); + for(int i=0;i removableBlockSet = new HashSet(); + + public GroundRemoverItem(String registryName1) + { + super(); + this.registryName=registryName1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxStackSize(1); + this.setUnlocalizedName(registryName); + removableBlockSet.add(Blocks.sandstone); + removableBlockSet.add(Blocks.sand); + removableBlockSet.add(Blocks.stone); + removableBlockSet.add(Blocks.flowing_water); + removableBlockSet.add(Blocks.flowing_lava); + removableBlockSet.add(Blocks.water); + removableBlockSet.add(Blocks.lava); + removableBlockSet.add(Blocks.clay); + removableBlockSet.add(Blocks.gravel); + removableBlockSet.add(Blocks.dirt); + } + + public GroundRemoverItem() + { + super(); + } + + public static void init() + { + //GameRegistry.registerItem(new GroundRemoverItem("groundRemover"),"groundRemover"); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) + { + info.add("Vanilla block remover tool"); + } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":vacuumSwitch"); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) + { + if(entity instanceof EntityPlayer && isCurrentItem && MinecraftServer.getServer().getTickCounter()%100==99) + { + int x = (int)entity.posX; + int y = (int)entity.posY; + int z = (int)entity.posZ; + for(int ix = x-16;ix < x+16;ix++) + { + for(int iz = z-16;iz < z+16;iz++) + { + for(int iy = 4;iy < y;iy++) + { + if(!(world.getBlock(ix, iy, iz) instanceof BlockOre || world.getBlock(ix, iy, iz) instanceof IHLFluidBlock)) + { + world.setBlockToAir(ix, iy, iz); + } + } + } + } + } + } +} diff --git a/ihl/items_blocks/IHLFluidBlock.java b/ihl/items_blocks/IHLFluidBlock.java new file mode 100644 index 0000000..29d2d99 --- /dev/null +++ b/ihl/items_blocks/IHLFluidBlock.java @@ -0,0 +1,120 @@ +package ihl.items_blocks; + +import ihl.IHLModInfo; +import cpw.mods.fml.common.registry.GameRegistry; +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.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; + +public class IHLFluidBlock extends BlockFluidClassic { + + private String textureName = "fluidRubberTreeSap"; + @SideOnly(Side.CLIENT) + protected IIcon stillIcon; + @SideOnly(Side.CLIENT) + protected IIcon flowingIcon; + private boolean flammable; + + public IHLFluidBlock(Fluid fluid, Material material, String textureName1, String registryName1) { + super(fluid, material); + textureName = textureName1; + GameRegistry.registerBlock(this, registryName1); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + return this.blockMaterial==Material.lava?15:0; + } + + public IHLFluidBlock setFlammable(boolean flammable) + { + this.flammable = flammable; + return this; + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable ? 300 : 0; + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable ? 5 : 0; + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return flammable; + } + + + @Override + public IIcon getIcon(int side, int meta) { + return (side == 0 || side == 1)? stillIcon : flowingIcon; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerBlockIcons(IIconRegister register) { + stillIcon = register.registerIcon(IHLModInfo.MODID + ":" + textureName + "Still"); + flowingIcon = register.registerIcon(IHLModInfo.MODID + ":" + textureName + "Flowing"); + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; + return super.displaceIfPossible(world, x, y, z); + } + + @Override + public int onBlockPlaced(World world, int x, int y, int z, int meta, float xF, float yF, float zF, int meta2) + { + int var = super.onBlockPlaced(world, x, y, z, meta, xF, yF, zF, meta2); + if(!world.isRemote && this.isAirCompound()) + { + world.setBlockToAir(x, y, z); + } + return var; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + super.onBlockPlacedBy(world, x, y, z, player, itemStack); + if(!world.isRemote && this.isAirCompound()) + { + world.setBlockToAir(x, y, z); + } + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + super.onNeighborBlockChange(world, x, y, z, block); + if(!world.isRemote && this.isAirCompound()) + { + world.setBlockToAir(x, y, z); + } + } + + private boolean isAirCompound() + { + return this.fluidName.equals("air") || this.fluidName.equals("nitrogen") || this.fluidName.equals("oxygen"); + } +} diff --git a/ihl/items_blocks/IHLItemBlock.java b/ihl/items_blocks/IHLItemBlock.java new file mode 100644 index 0000000..8ac81a2 --- /dev/null +++ b/ihl/items_blocks/IHLItemBlock.java @@ -0,0 +1,280 @@ +package ihl.items_blocks; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class IHLItemBlock extends ItemBlock{ + public Map nameMap = new HashMap(); + public IHLItemBlock(Block block1) + { + super(block1); + this.setFull3D(); + this.setHasSubtypes(true); + this.setCreativeTab(IHLCreativeTab.tab); + } + + @Override + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) + { + Block block = world.getBlock(x, y, z); + + if (block == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 7) < 1) + { + par7 = 1; + } + else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush) + { + if (par7 == 0) + { + --y; + } + + if (par7 == 1) + { + ++y; + } + + if (par7 == 2) + { + --z; + } + + if (par7 == 3) + { + ++z; + } + + if (par7 == 4) + { + --x; + } + + if (par7 == 5) + { + ++x; + } + } + + if (par1ItemStack.stackSize == 0) + { + return false; + } + else if (!player.canPlayerEdit(x, y, z, par7, par1ItemStack)) + { + return false; + } + else if (y == 255) + { + return false; + } + else if (world.canPlaceEntityOnSide(this.field_150939_a, x, y, z, false, par7, player, par1ItemStack)) + { + int metadata = par1ItemStack.getItemDamage(); + int var13 = this.field_150939_a.onBlockPlaced(world, x, y, z, par7, par8, par9, par10, metadata); + + if (world.setBlock(x, y, z, this.field_150939_a, var13, 3)) + { + if (world.getBlock(x, y, z) == this.field_150939_a) + { + 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; + int var6 = MathHelper.floor_double(player.rotationPitch * 4.0F / 360.0F + 0.5D) & 3; + int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + if(player.isSneaking()) + { + if(var6==1) + { + te.setFacing((short) 0); + } + else if(var6==3) + { + te.setFacing((short) 1); + } + else + { + + switch (l) + { + case 0: + te.setFacing((short)3); + break; + + case 1: + te.setFacing((short)4); + break; + + case 2: + te.setFacing((short)2); + break; + + case 3: + te.setFacing((short)5); + } + } + } + else + { + if(var6==1) + { + te.setFacing((short) 1); + } + else if(var6==3) + { + te.setFacing((short) 0); + } + else + { + + switch (l) + { + case 0: + te.setFacing((short)2); + break; + + case 1: + te.setFacing((short)5); + break; + + case 2: + te.setFacing((short)3); + break; + + case 3: + te.setFacing((short)4); + } } + } + } + } + + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "step.stone", 1.0F, 0.8F); + --par1ItemStack.stackSize; + } + + return true; + } + else + { + return false; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) { + this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":driverItem"); + } + + public Block getBlockContained() + { + return this.field_150939_a; + } + + @Override + public CreativeTabs getCreativeTab() + { + return IHLCreativeTab.tab; + } + + @Override + public String getUnlocalizedName(ItemStack stack) + { + if(!nameMap.isEmpty() && nameMap.containsKey(stack.getItemDamage())) + { + return nameMap.get(stack.getItemDamage()); + } + else + { + return this.field_150939_a.getUnlocalizedName(); + } + } + + @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; + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) + { + if(itemStack.stackTagCompound!=null && itemStack.stackTagCompound.hasKey("resultSuffix")) + { + info.add(StatCollector.translateToLocal("result_of_molding") + StatCollector.translateToLocal("ihl."+itemStack.stackTagCompound.getString("resultSuffix"))); + if(itemStack.stackTagCompound.hasKey("isContainStearin") && itemStack.stackTagCompound.getBoolean("isContainStearin")) + { + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 1: "+StatCollector.translateToLocal("remove_wax_using_muffle_furnace")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 2: "+StatCollector.translateToLocal("fill_from_top_with_molten_metal")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 3: "+StatCollector.translateToLocal("wait_for_10_seconds")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 4: "+StatCollector.translateToLocal("destroy_mold_to_get_results")); + + } + else + { + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 1: "+StatCollector.translateToLocal("fill_from_top_with_molten_metal")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 2: "+StatCollector.translateToLocal("wait_for_10_seconds")); + info.add(StatCollector.translateToLocal("ihl.tooltip.step")+" 3: "+StatCollector.translateToLocal("destroy_mold_to_get_results")); + } + } + } +} diff --git a/ihl/items_blocks/IHLTool.java b/ihl/items_blocks/IHLTool.java new file mode 100644 index 0000000..7ddf3fb --- /dev/null +++ b/ihl/items_blocks/IHLTool.java @@ -0,0 +1,431 @@ +package ihl.items_blocks; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.reactor.IReactor; +import ic2.core.Ic2Items; +import ihl.IHLCreativeTab; +import ihl.IHLMod; +import ihl.IHLModInfo; +import ihl.flexible_cable.SetOfDiesMiniGUI; +import ihl.interfaces.IHasTemperature; +import ihl.interfaces.IItemHasMiniGUI; +import ihl.interfaces.ItemMiniGUI; +import ihl.utils.IHLUtils; +public class IHLTool extends Item implements IItemHasMiniGUI{ + + private static Map iconMap = new HashMap(); + private static Map nameMap = new HashMap(); + private static Map hintMap = new HashMap(); + private static Map maxToolDamageMap = new HashMap(); + private static Map isWeaponMap = new HashMap(); + private static Map damageVersusEntityMap = new HashMap(); + public static Item instance; + + private IIcon dice240; + + public IHLTool() + { + super(); + this.setMaxDamage(0); + this.setNoRepair(); + this.setHasSubtypes(true); + this.setCreativeTab(IHLCreativeTab.tab); + this.setUnlocalizedName("ihlTool"); + this.setMaxStackSize(1); + instance=this; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) + { + if(itemStack.getItemDamage()!=19 || world.isRemote) + { + return itemStack; + } + MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world); + if(movingobjectposition!=null) + { + int x=movingobjectposition.blockX; + int y=movingobjectposition.blockY; + int z=movingobjectposition.blockZ; + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof IHasTemperature) + { + this.setThermometerTemperature(itemStack, entityPlayer, ((IHasTemperature)te).getTemperature()); + } + if(te instanceof IReactor) + { + this.setThermometerTemperature(itemStack, entityPlayer, ((IReactor)te).getHeat()+273); + } + } + return itemStack; + } + + @Override + public final ItemStack getContainerItem(ItemStack stack) + { + ItemStack outStack = stack.copy(); + IHLUtils.damageItemViaNBTTag(outStack, 100); + if(outStack.stackSize<=0) + { + return null; + } + else + { + return outStack; + } + } + + @Override + public final boolean doesContainerItemLeaveCraftingGrid(ItemStack aStack) + { + return false; + } + + @Override + public final boolean hasContainerItem(ItemStack aStack) + { + return true; + } + + public static void init() + { + if(IHLUtils.getFirstOreDictName(Ic2Items.bronzeAxe).equals("")) + { + OreDictionary.registerOre("craftingToolAxe", Ic2Items.bronzeAxe.getItem()); + } + if(IHLUtils.getFirstOreDictName(Ic2Items.bronzePickaxe).equals("")) + { + OreDictionary.registerOre("craftingToolPickaxe", Ic2Items.bronzePickaxe.getItem()); + } + IHLTool item = new IHLTool(); + GameRegistry.registerItem(item,item.getUnlocalizedName()); + Type[] var1 = Type.values(); + for(int i=0;i0) + { + for(int i1=0;i1=240) + { + return dice240; + } + } + return this.getIconFromDamage(stack.getItemDamage()); + } + + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int i) + { + return iconMap.get(i); + } + + public enum Type + { + Thermometer("mercuryThermometer",19,1,0.1f,false,null,(String[])null), + FiberGlassDie("fiberGlassDieSteel",18,20000,0.5f,false,null,(String[])null), + SharpenedCarvingKnifeBronze("sharpenedCarvingKnifeBronze",17,2000,3.5f, true, "ihl.mutton_drop_hint", "craftingToolBlade", "craftingToolKnife"), + GlassBlowingTube("glassBlowingTubeSteel",16,2000,0.5f,false,null,(String[])null), + PolishingPucks("polishingPucksSteel",15,2000,0.5f,false,null,(String[])null), + GravelSteel("graverSteelHardened",14,10,0.5f,false,null,(String[])null), + DiceM10Steel("diceM10x1SteelHardened",13,2000,0.5f,false,null,(String[])null), + TapM10("tapM10x1SteelHardened",12,2000,0.5f,false,null,(String[])null), + Vise("viseSteel",11,200000,0.5f,false,null,(String[])null), + SetOfFiles("setOfFilesSteel",10,20000,1.5f,false,null,"craftingToolFile"), + HandDrillBronze("handDrillBronze",9,20000,0.5f,false,null,(String[])null), + HackSawSteel("hackSawSteel",8,200,0.5f,false,null,"craftingToolSaw"), + DrillSteel("drillSteelHardened",7,200,0.5f,false,null,(String[])null), + NeedleFile("needleFile",6,2000,0.1f,false,null,(String[])null), + Chisel("chisel",5,2000,1.5f,false,null,"craftingToolChisel"), + Grindstone("grindstone",4,2000,0.5f,false,null,(String[])null), + Hammer("hammer",3,20000,2.5f,false,null,"craftingToolHardHammer","craftingToolForgeHammer"), + TinSnipsSteel("tinSnipsSteel",2,2000,0.5f,false,null,"craftingToolWireCutter"), + SetOfDies1_5sqmm("setOfDies1_5sqmm",0,2000,0.5f,false,null,(String[])null); + Type(String unlocalizedName1,int itemDamage1, int maxToolDamage1, float damageVersusEntity1, boolean isWeapon1, String hint1, String... oreDictName1) + { + unLocalizedName=unlocalizedName1; + itemDamage=itemDamage1; + maxToolDamage=maxToolDamage1; + damageVersusEntity=damageVersusEntity1; + isWeapon=isWeapon1; + hint=hint1; + oreDictName=oreDictName1; + } + public final String unLocalizedName; + public final String[] oreDictName; + public final int itemDamage; + public final int maxToolDamage; + public final float damageVersusEntity; + public final boolean isWeapon; + public final String hint; + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) + { + info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.durability") +EnumChatFormatting.GREEN + (IHLUtils.getMaxDamageValueViaNBTTag(itemStack) - IHLUtils.getDamageValueViaNBTTag(itemStack))+" / "+IHLUtils.getMaxDamageValueViaNBTTag(itemStack)); + info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.attack_damage") +EnumChatFormatting.DARK_BLUE + damageVersusEntityMap.get(itemStack.getItemDamage())); + if(hintMap.containsKey(itemStack.getItemDamage())) + { + info.add(EnumChatFormatting.DARK_RED+StatCollector.translateToLocal(hintMap.get(itemStack.getItemDamage()))); + } + if(itemStack.stackTagCompound.hasKey("transverseSection")) + { + info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.transversesection") +EnumChatFormatting.GREEN + (itemStack.stackTagCompound.getInteger("transverseSection")/10f)+" sq. mm."); + } + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) + { + IHLUtils.damageItemViaNBTTag(stack, 1); + if(target!=null && target instanceof EntitySheep && !target.isChild() && target.getHealth()<=0F) + { + target.entityDropItem(IHLUtils.getThisModItemStackWithSize("muttonLard", target.worldObj.rand.nextInt(2)+2), 1F); + } + return true; + } + + @Override//That was taken from Gregtech. I think Greg wouldn't mind. + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) + { + if (entity.canAttackWithItem() && !entity.hitByEntity(player)) + { + float tMagicDamage = entity instanceof EntityLivingBase ? EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLivingBase)entity) : 0.0F; + float tDamage = (float)player.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() + damageVersusEntityMap.get(stack.getItemDamage()); + + if (tDamage + tMagicDamage > 0.0F) + { + boolean tCriticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null && entity instanceof EntityLivingBase; + + if (tCriticalHit && tDamage > 0.0F) + { + tDamage *= 1.5F; + } + + tDamage += tMagicDamage; + + if (entity.attackEntityFrom(DamageSource.generic, tDamage)) + { + if (entity instanceof EntityLivingBase) + { + entity.setFire(EnchantmentHelper.getFireAspectModifier(player) * 4); + } + + int tKnockcack = (player.isSprinting() ? 1 : 0) + (entity instanceof EntityLivingBase ? EnchantmentHelper.getKnockbackModifier(player, (EntityLivingBase)entity) : 0); + + if (tKnockcack > 0) + { + entity.addVelocity(-MathHelper.sin(player.rotationYaw * (float)Math.PI / 180.0F) * tKnockcack * 0.5F, 0.1D, MathHelper.cos(player.rotationYaw * (float)Math.PI / 180.0F) * tKnockcack * 0.5F); + player.motionX *= 0.6D; + player.motionZ *= 0.6D; + player.setSprinting(false); + } + + if (tCriticalHit) + { + player.onCriticalHit(entity); + } + + if (tMagicDamage > 0.0F) + { + player.onEnchantmentCritical(entity); + } + + if (tDamage >= 18.0F) + { + player.triggerAchievement(AchievementList.overkill); + } + + player.setLastAttacker(entity); + + if (entity instanceof EntityLivingBase) + { + EnchantmentHelper.func_151384_a((EntityLivingBase)entity, player); + } + + EnchantmentHelper.func_151385_b(player, entity); + + if (entity instanceof EntityLivingBase) + { + player.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F)); + } + entity.hurtResistantTime = isWeaponMap.get(stack.getItemDamage())?0:1; + if(entity!=null && entity instanceof EntitySheep && !((EntityLivingBase) entity).isChild() && ((EntityLivingBase) entity).getHealth()<=0F && isWeaponMap.get(stack.getItemDamage())) + { + entity.entityDropItem(IHLUtils.getThisModItemStackWithSize("muttonLard", entity.worldObj.rand.nextInt(2)+1), 1F); + } + player.addExhaustion(0.3F); + IHLUtils.damageItemViaNBTTag(stack, 1); + } + } + } + if (stack.stackSize <= 0) + { + player.destroyCurrentEquippedItem(); + } + return true; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) + { + return true; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) + { + return ((double)IHLUtils.getDamageValueViaNBTTag(stack))/(double)IHLUtils.getMaxDamageValueViaNBTTag(stack); + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) + { + if(stack.stackTagCompound!=null && !world.isRemote) + { + if(stack.stackTagCompound.hasKey("showTemperature")) + { + byte timerDelay = stack.stackTagCompound.getByte("showTemperature"); + if(timerDelay>0) + { + timerDelay--; + if(Math.abs(stack.stackTagCompound.getDouble("playerPosX")-entity.prevPosX)>0.2d || + Math.abs(stack.stackTagCompound.getDouble("playerPosY")-entity.prevPosY)>0.2d || + Math.abs(stack.stackTagCompound.getDouble("playerPosZ")-entity.prevPosZ)>0.2d) + { + timerDelay=0; + } + stack.stackTagCompound.setByte("showTemperature",timerDelay); + if(timerDelay==0 && entity instanceof EntityPlayer) + { + ((EntityPlayer)entity).inventoryContainer.detectAndSendChanges(); + } + } + } + } + } + private void setThermometerTemperature(ItemStack itemStack, EntityPlayer entityPlayer, long l) + { + if(itemStack.stackTagCompound==null) + { + itemStack.stackTagCompound=new NBTTagCompound(); + } + itemStack.stackTagCompound.setLong("temperature", l); + itemStack.stackTagCompound.setByte("showTemperature", (byte) 60); + itemStack.stackTagCompound.setDouble("playerPosX", entityPlayer.prevPosX); + itemStack.stackTagCompound.setDouble("playerPosY", entityPlayer.prevPosY); + itemStack.stackTagCompound.setDouble("playerPosZ", entityPlayer.prevPosZ); + entityPlayer.inventoryContainer.detectAndSendChanges(); + + } + + @Override + @SideOnly(Side.CLIENT) + public ItemMiniGUI getMiniGUI(GuiContainer gui, Slot slot) + { + if(slot.getHasStack() && slot.getStack().getItemDamage()==0 && slot.getStack().stackTagCompound!=null) + { + return new SetOfDiesMiniGUI(gui, slot); + } + return null; + } +} diff --git a/ihl/items_blocks/ItemSubstance.java b/ihl/items_blocks/ItemSubstance.java new file mode 100644 index 0000000..bef37fa --- /dev/null +++ b/ihl/items_blocks/ItemSubstance.java @@ -0,0 +1,392 @@ +package ihl.items_blocks; + +import ic2.api.item.IC2Items; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.api.recipe.Recipes; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid.IHLFluidType; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemSubstance extends Item { + + private static Map iconMap = new HashMap(); + private static Map nameMap = new HashMap(); + private static Map descriptionMap = new HashMap(); + public static ItemSubstance instance; + + public ItemSubstance() + { + super(); + this.setMaxDamage(0); + this.setNoRepair(); + this.setHasSubtypes(true); + this.setCreativeTab(IHLCreativeTab.tab); + this.setUnlocalizedName("ihlSimpleItem"); + 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)); + ItemSubstance item = new ItemSubstance(); + GameRegistry.registerItem(item,item.getUnlocalizedName()); + Type[] var1 = Type.values(); + for(int i=0;i instances = new ArrayList(); + + @SideOnly(Side.CLIENT) + IIcon textureSide, + textureBack, + textureFrontMuffleFurnance, + textureTop, + textureTopAchesonFurnance, + textureTopGoldFurnace, + textureFrontGoldFurnace, + textureSideGoldFurnace, + textureFrontCryogenicDistiller, + textureTopCryogenicDistiller, + textureBackCryogenicDistiller, + textureFrontChemicalReactor, + textureLeftMachineCasing, + textureTopMachineCasing, + textureRightMachineCasing, + textureFrontMachineCasing, + textureFrontPaperMachine, + textureBackMachineCasing, + frequencyGeneratorBack, + frequencyGeneratorBottom, + frequencyGeneratorFront, + frequencyGeneratorLeft, + frequencyGeneratorRight, + frequencyGeneratorTop, + bronzeTubTop, + bronzeTubSide, + glassBoxTop, + glassBoxSide, + glassBoxBottom, + glassBoxInnerSide, + glassBoxInnerBottom, + vacuumInductionMeltingFurnaceFront, + vacuumInductionMeltingFurnaceBack, + vacuumInductionMeltingFurnaceLeft, + vacuumInductionMeltingFurnaceRight, + hydrotransportPulpRegeneratorFront, + hydrotransportPulpRegeneratorBack, + redstoneSignalConverterEmitterSide, + redstoneSignalConverterEmptySide, + redstoneSignalConverterSensorSide, + steel, + redPaint, + greenPaint, + rubberInsulatedCase, + powerPort; + + public MachineBaseBlock(MachineType type1) + { + super(Material.iron); + this.type=type1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName(type.unlocalizedName); + this.setHardness(2F); + this.setResistance(1F); + instances.add(this); + } + + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + if(IC2.platform.isSimulating()) + { + TileEntity te = world.getTileEntity(x,y,z); + if(world.getBlock(x, y+1, z)==Blocks.fire) + { + if(te instanceof DetonationSprayingMachineTileEntity) + { + ((DetonationSprayingMachineTileEntity)te).operate(); + world.setBlockToAir(x, y+1, z); + } + } + if(te instanceof RedstoneSignalConverterTileEntity) + { + RedstoneSignalConverterTileEntity rscte = (RedstoneSignalConverterTileEntity) te; + rscte.linksOrInventoryChanged=true; + } + } + } + + + @Override + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) + { + if(!world.isRemote) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te!=null) + { + if(te instanceof IEnergyNetNode) + { + IEnergyNetNode ate = (IEnergyNetNode) te; + ate.removeAttachedChains(); + } + if(te instanceof IMultiPowerCableHolder) + { + IMultiPowerCableHolder ate = (IMultiPowerCableHolder) te; + ate.removeAttachedChains(); + } + if(te instanceof IronWorkbenchTileEntity) + { + IronWorkbenchTileEntity iwb=(IronWorkbenchTileEntity) te; + iwb.dropContents(); + } + else if(te instanceof IInventory) + { + IInventory inventory = (IInventory)te; + for(int i = 0; i< inventory.getSizeInventory();i++) + { + if(inventory.getStackInSlot(i)!=null)world.spawnEntityInWorld(new EntityItem(world, x, y+1, z, inventory.getStackInSlot(i))); + } + } + if(te instanceof RedstoneSignalConverterTileEntity) + { + RedstoneSignalConverterTileEntity rsce = (RedstoneSignalConverterTileEntity)te; + rsce.removeAttachedChains(); + } + } + } + super.onBlockPreDestroy(world, x, y, z, meta); + } + + @Override + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) + { + switch(this.type) + { + case BronzeTub: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBoundsForItemRender(); + break; + case GlassBox: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBoundsForItemRender(); + break; + case RedstoneSignalConverter: + this.setBlockBounds(0.2F, 0.2F, 0.2F, 0.8F, 0.8F, 0.8F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + break; + default: + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + break; + } + } + + @Override + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) + { + int facing = 3; + TileEntity te = blockAccess.getTileEntity(x, y, z); + if(te!=null && te instanceof IWrenchable) + { + IWrenchable tebh = (IWrenchable) te; + facing=tebh.getFacing(); + } + switch(this.type) + { + case VacuumInductionMeltingFurnace: + switch(facing) + { + case 0: + this.setBlockBounds(-1.0F, -2.0F, 0.0F, 2.0F, 1.0F, 3.0F); + break; + case 1: + this.setBlockBounds(-1.0F, 0.0F, 0.0F, 2.0F, 3.0F, 3.0F); + break; + case 2: + this.setBlockBounds(-1.0F, 0.0F, -2.0F, 2.0F, 3.0F, 1.0F); + break; + case 3: + this.setBlockBounds(-1.0F, 0.0F, 0.0F, 2.0F, 3.0F, 3.0F); + break; + case 4: + this.setBlockBounds(-2.0F, 0.0F, -1.0F, 1.0F, 3.0F, 2.0F); + break; + case 5: + this.setBlockBounds(0.0F, 0.0F, -1.0F, 3.0F, 3.0F, 2.0F); + break; + default: + break; + } + break; + default: + super.setBlockBoundsBasedOnState(blockAccess, x, y, z); + break; + } + } + + public static void init() + { + MachineType[] var1 = MachineType.values(); + for(int i=0;i + */ +public class FluidRenderer { + + private static RenderBlocks renderBlocks = new RenderBlocks(); + private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; + private static final Map flowingRenderCache = new HashMap(); + private static final Map stillRenderCache = new HashMap(); + public static final int DISPLAY_STAGES = 100; + private static final RenderInfo liquidBlock = new RenderInfo(); + + static { + liquidBlock.texture = new IIcon[1]; + } + + public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) { + if (fluidStack == null) + return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + Fluid fluid = fluidStack.getFluid(); + if (fluid == null) + return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon(); + if(icon==null) + { + icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } + return icon; + } + + public static ResourceLocation getFluidSheet(FluidStack liquid) { + return BLOCK_TEXTURE; + } + + public static ResourceLocation setupFlowingLiquidTexture(FluidStack liquid, IIcon[] texArray) { + if (liquid == null || liquid.amount <= 0) + return null; + + Fluid fluid = liquid.getFluid(); + if (fluid == null) + return null; + IIcon top = fluid.getStillIcon(); + IIcon side = fluid.getFlowingIcon(); + texArray[0] = top; + texArray[1] = top; + texArray[2] = side; + texArray[3] = side; + texArray[4] = side; + texArray[5] = side; + return getFluidSheet(liquid); + } + + public static int[] getLiquidDisplayLists(FluidStack fluidStack) { + return getLiquidDisplayLists(fluidStack, false); + } + + public static int[] getLiquidDisplayLists(FluidStack fluidStack, boolean flowing) { + if (fluidStack == null) + return null; + Fluid fluid = fluidStack.getFluid(); + if (fluid == null) + return null; + Map cache = flowing ? flowingRenderCache : stillRenderCache; + int[] diplayLists = cache.get(fluid); + if (diplayLists != null) + return diplayLists; + + diplayLists = new int[DISPLAY_STAGES]; + + liquidBlock.texture[0] = null; + + if (fluid.getBlock() != null) { + liquidBlock.template = fluid.getBlock(); + liquidBlock.texture[0] = getFluidTexture(fluidStack, flowing); + } else { + liquidBlock.template = Blocks.water; + liquidBlock.texture[0] = getFluidTexture(fluidStack, flowing); + } + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_CULL_FACE); + for (int s = 0; s < DISPLAY_STAGES; ++s) { + diplayLists[s] = GLAllocation.generateDisplayLists(1); + GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/); + + liquidBlock.minX = 0.01f; + liquidBlock.minY = 0; + liquidBlock.minZ = 0.01f; + + liquidBlock.maxX = 0.99f; + liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES; + liquidBlock.maxZ = 0.99f; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + RenderInfo info = liquidBlock; + renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ); + + if (info.renderSide[0]) + renderBlocks.renderFaceYNeg(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(0)); + if (info.renderSide[1]) + renderBlocks.renderFaceYPos(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(1)); + if (info.renderSide[2]) + renderBlocks.renderFaceZNeg(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(2)); + if (info.renderSide[3]) + renderBlocks.renderFaceZPos(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(3)); + if (info.renderSide[4]) + renderBlocks.renderFaceXNeg(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(4)); + if (info.renderSide[5]) + renderBlocks.renderFaceXPos(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(5)); + tessellator.draw(); + GL11.glEndList(); + } + + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + + cache.put(fluid, diplayLists); + + return diplayLists; + } + +} diff --git a/ihl/model/IHLBlockRenderer.java b/ihl/model/IHLBlockRenderer.java new file mode 100644 index 0000000..35c6e6c --- /dev/null +++ b/ihl/model/IHLBlockRenderer.java @@ -0,0 +1,75 @@ +package ihl.model; + +import ihl.handpump.BlockWithCoordinates; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import org.lwjgl.opengl.GL11; +import net.minecraft.world.ChunkCache; +import net.minecraft.world.World; + +public class IHLBlockRenderer { + + private RenderBlocks renderBlocks; + private final Map renderCache = new HashMap(); + public static IHLBlockRenderer instance; + + public IHLBlockRenderer() + { + renderBlocks=RenderBlocks.getInstance(); + instance=this; + } + + public void refreshDisplayLists(int diplayLists, List bwc, ChunkCache iBlockAccess) + { + if (bwc==null || bwc.isEmpty()) + { + return; + } + renderBlocks.blockAccess=iBlockAccess; + GL11.glNewList(diplayLists, 4864 /*GL_COMPILE*/); + Iterator bwci = bwc.iterator(); + while(bwci.hasNext()) + { + BlockWithCoordinates bwce = bwci.next(); + renderBlock(bwce); + } + GL11.glEndList(); + } + + + public int getBlockDisplayLists(BlockWithCoordinates bwc, World world) { + if (bwc.block == null) + { + return -1; + } + if(renderCache.containsKey(bwc)) + { + return renderCache.get(bwc); + } + int diplayLists = GLAllocation.generateDisplayLists(1); + if(renderBlocks.blockAccess==null || !renderBlocks.blockAccess.equals(world)) + { + renderBlocks.blockAccess=world; + } + GL11.glNewList(diplayLists, 4864 /*GL_COMPILE*/); + renderBlock(bwc); + GL11.glEndList(); + renderCache.put(bwc, diplayLists); + return diplayLists; + } + + private void renderBlock(BlockWithCoordinates bwc) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + renderBlocks.renderBlockByRenderType(bwc.block, bwc.x, bwc.y, bwc.z); + tessellator.draw(); + } +} diff --git a/ihl/model/IHLModelRenderer.java b/ihl/model/IHLModelRenderer.java new file mode 100644 index 0000000..c9b1b77 --- /dev/null +++ b/ihl/model/IHLModelRenderer.java @@ -0,0 +1,366 @@ +package ihl.model; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.model.TextureOffset; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.Tessellator; +import net.minecraftforge.common.util.ForgeDirection; + +public class IHLModelRenderer { + /** The size of the texture file's width in pixels. */ + public float textureWidth; + + /** The size of the texture file's height in pixels. */ + public float textureHeight; + + /** The X offset into the texture used for displaying this model */ + private int textureOffsetX; + + /** The Y offset into the texture used for displaying this model */ + private int textureOffsetY; + public float rotationPointX; + public float rotationPointY; + public float rotationPointZ; + public float rotateAngleX; + public float rotateAngleY; + public float rotateAngleZ; + private boolean compiled; + + /** The GL display list rendered by the Tessellator for this model */ + private int displayList; + public boolean mirror; + public boolean showModel; + + /** Hides the model. */ + public boolean isHidden; + public List cubeList; + public List childModels; + public final String boxName; + private ModelBase baseModel; + public float offsetX; + public float offsetY; + public float offsetZ; + + public boolean drawFromInside=false; + private static final String __OBFID = "CL_00000874"; + + public IHLModelRenderer(ModelBase par1ModelBase, String par2Str) + { + this.textureWidth = 64.0F; + this.textureHeight = 32.0F; + this.showModel = true; + this.cubeList = new ArrayList(); + this.baseModel = par1ModelBase; + par1ModelBase.boxList.add(this); + this.boxName = par2Str; + this.setTextureSize(par1ModelBase.textureWidth, par1ModelBase.textureHeight); + } + + public IHLModelRenderer(ModelBase par1ModelBase) + { + this(par1ModelBase, (String)null); + } + + public IHLModelRenderer(ModelBase par1ModelBase, int par2, int par3) + { + this(par1ModelBase); + this.setTextureOffset(par2, par3); + } + + /** + * Sets the current box's rotation points and rotation angles to another box. + */ + public void addChild(ModelRenderer par1ModelRenderer) + { + if (this.childModels == null) + { + this.childModels = new ArrayList(); + } + + this.childModels.add(par1ModelRenderer); + } + + public IHLModelRenderer setTextureOffset(int par1, int par2) + { + this.textureOffsetX = par1; + this.textureOffsetY = par2; + return this; + } + + public IHLModelRenderer addBox(String par1Str, float par2, float par3, float par4, int par5, int par6, int par7, boolean inverted, boolean[] renderFace) + { + par1Str = this.boxName + "." + par1Str; + TextureOffset var8 = this.baseModel.getTextureOffset(par1Str); + this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY); + this.cubeList.add((new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5, par6, par7, 0.0F, inverted, renderFace)).func_78244_a(par1Str)); + return this; + } + + public IHLModelRenderer addBox(String par1Str, float par2, float par3, float par4, int par5, int par6, int par7, boolean inverted) + { + boolean[] renderFace={true,true,true,true,true,true}; + par1Str = this.boxName + "." + par1Str; + TextureOffset var8 = this.baseModel.getTextureOffset(par1Str); + this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY); + this.cubeList.add((new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5, par6, par7, 0.0F, inverted, renderFace)).func_78244_a(par1Str)); + return this; + } + + public IHLModelRenderer addBox(float par1, float par2, float par3, int par4, int par5, int par6, boolean inverted, boolean[] renderFace) + { + this.cubeList.add(new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F, inverted, renderFace)); + return this; + } + + public IHLModelRenderer addTube(String par1Str, float par1, float par2, float par3, int par4, int par5, int par6, float radius1, float radius2, ForgeDirection direction) + { + par1Str = this.boxName + "." + par1Str; + TextureOffset var8 = this.baseModel.getTextureOffset(par1Str); + this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY); + this.cubeList.add(new ModelTube(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F, radius1,radius2, direction)); + return this; + } + + public IHLModelRenderer addKnee(String par1Str, float par1, float par2, float par3, int par4, int par5, int par6, float radius1, float radius2, ForgeDirection direction, ForgeDirection direction2) + { + par1Str = this.boxName + "." + par1Str; + TextureOffset var8 = this.baseModel.getTextureOffset(par1Str); + this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY); + this.cubeList.add(new ModelKnee(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F, radius1,radius2, direction, direction2)); + return this; + } + + public IHLModelRenderer addBox(float par1, float par2, float par3, int par4, int par5, int par6) + { + boolean[] renderFace={true,true,true,true,true,true}; + this.cubeList.add(new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F, false, renderFace)); + return this; + } + + /** + * Creates a textured box. Args: originX, originY, originZ, width, height, depth, scaleFactor. + */ + public void addBox(float par1, float par2, float par3, int par4, int par5, int par6, float par7, boolean inverted, boolean[] renderFace) + { + this.cubeList.add(new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, par7, inverted, renderFace)); + } + + public void setRotationPoint(float par1, float par2, float par3) + { + this.rotationPointX = par1; + this.rotationPointY = par2; + this.rotationPointZ = par3; + } + + public void render(float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ); + int var2; + + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) + { + if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) + { + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (var2 = 0; var2 < this.childModels.size(); ++var2) + { + ((ModelRenderer)this.childModels.get(var2)).render(par1); + } + } + } + else + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (var2 = 0; var2 < this.childModels.size(); ++var2) + { + ((ModelRenderer)this.childModels.get(var2)).render(par1); + } + } + + GL11.glTranslatef(-this.rotationPointX * par1, -this.rotationPointY * par1, -this.rotationPointZ * par1); + } + } + else + { + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + } + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (var2 = 0; var2 < this.childModels.size(); ++var2) + { + ((ModelRenderer)this.childModels.get(var2)).render(par1); + } + } + + GL11.glPopMatrix(); + } + + GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ); + } + } + } + + public void renderWithRotation(float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + } + + GL11.glCallList(this.displayList); + GL11.glPopMatrix(); + } + } + } + + /** + * Allows the changing of Angles after a box has been rendered + */ + public void postRender(float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) + { + if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + } + } + else + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + } + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + } + } + } + } + + /** + * Compiles a GL display list for this model + */ + private void compileDisplayList(float par1) + { + this.displayList = GLAllocation.generateDisplayLists(1); + GL11.glNewList(this.displayList, GL11.GL_COMPILE); + Tessellator var2 = Tessellator.instance; + + for (int var3 = 0; var3 < this.cubeList.size(); ++var3) + { + if(this.cubeList.get(var3) instanceof ModelToplessBox) + { + ((ModelToplessBox)this.cubeList.get(var3)).render(var2, par1); + } + else if(this.cubeList.get(var3) instanceof ModelTube) + { + ((ModelTube)this.cubeList.get(var3)).render(var2, par1); + } + else if(this.cubeList.get(var3) instanceof ModelKnee) + { + ((ModelKnee)this.cubeList.get(var3)).render(var2, par1); + } + } + + GL11.glEndList(); + this.compiled = true; + } + + /** + * Returns the model renderer with the new texture parameters. + */ + public IHLModelRenderer setTextureSize(int par1, int par2) + { + this.textureWidth = par1; + this.textureHeight = par2; + return this; + } + + public void addBox(String string, float f, float g, float h, int i, int j, int k) { + this.addBox(string, f, g, h, i, j, k, false); + } + + +} diff --git a/ihl/model/IHLToolRenderer.java b/ihl/model/IHLToolRenderer.java new file mode 100644 index 0000000..6f2a30f --- /dev/null +++ b/ihl/model/IHLToolRenderer.java @@ -0,0 +1,83 @@ +package ihl.model; + +import ihl.items_blocks.IHLTool; +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; + +public class IHLToolRenderer implements IItemRenderer +{ + + @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 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)) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setNormal(0f, 0f, -1f); + double xStart=0d,yStart=0d; + double xEnd=16d,yEnd=16d; + double z = 0.001d; + tessellator.addVertexWithUV(xStart, yEnd, z, icon.getMinU(), icon.getMaxV()); + tessellator.addVertexWithUV(xEnd, yEnd, z, icon.getMaxU(), icon.getMaxV()); + tessellator.addVertexWithUV(xEnd, yStart, z, icon.getMaxU(), icon.getMinV()); + tessellator.addVertexWithUV(xStart, yStart, z, icon.getMinU(), icon.getMinV()); + tessellator.draw(); + GL11.glDisable(GL11.GL_BLEND); + } + else + { + ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + } + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack arg1, ItemRendererHelper arg2) + { + return type.equals(ItemRenderType.ENTITY); + } + +} diff --git a/ihl/model/ImpregnatingMachineBlockRender.java b/ihl/model/ImpregnatingMachineBlockRender.java new file mode 100644 index 0000000..cb125cf --- /dev/null +++ b/ihl/model/ImpregnatingMachineBlockRender.java @@ -0,0 +1,131 @@ +package ihl.model; + +import ihl.items_blocks.MachineBaseBlock; +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.util.IIcon; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class ImpregnatingMachineBlockRender implements ISimpleBlockRenderingHandler +{ + public static int renderId; + + public ImpregnatingMachineBlockRender() + { + 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(); + float var11 = 0.0625F; + IIcon innerSideIcon = block.getBlockTextureFromSide(0); + if(block instanceof MachineBaseBlock) + { + innerSideIcon = ((MachineBaseBlock)block).getAdditionalIconsForBlockRenderer(0); + } + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 1.0F - var11, innerSideIcon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, var11-1.0F, innerSideIcon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 1.0F - var11, 0.0D, 0.0D, innerSideIcon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, var11-1.0F, 0.0D, 0.0D, innerSideIcon); + tessellator.draw(); + IIcon innerBottomIcon = block.getBlockTextureFromSide(0); + if(block instanceof MachineBaseBlock) + { + innerBottomIcon = ((MachineBaseBlock)block).getAdditionalIconsForBlockRenderer(1); + } + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, var11-1.0F, 0.0D, innerBottomIcon); + 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) + { + blockRenderer.renderStandardBlock(block, x, y, z); + Tessellator var5 = Tessellator.instance; + var5.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z)); + int var6 = block.colorMultiplier(blockAccess, x, y, z); + float var7 = (var6 >> 16 & 255) / 255.0F; + float var8 = (var6 >> 8 & 255) / 255.0F; + float var9 = (var6 & 255) / 255.0F; + float var11; + var5.setColorOpaque_F(var7, var8, var9); + IIcon innerSideIcon = block.getBlockTextureFromSide(0); + if(block instanceof MachineBaseBlock) + { + innerSideIcon = ((MachineBaseBlock)block).getAdditionalIconsForBlockRenderer(0); + } + var11 = 0.0625F; + blockRenderer.renderFaceXPos(block, x - 1.0F + var11, y, z, innerSideIcon); + blockRenderer.renderFaceXNeg(block, x + 1.0F - var11, y, z, innerSideIcon); + blockRenderer.renderFaceZPos(block, x, y, z - 1.0F + var11, innerSideIcon); + blockRenderer.renderFaceZNeg(block, x, y, z + 1.0F - var11, innerSideIcon); + IIcon innerBottomIcon = block.getBlockTextureFromSide(0); + if(block instanceof MachineBaseBlock) + { + innerBottomIcon = ((MachineBaseBlock)block).getAdditionalIconsForBlockRenderer(1); + } + blockRenderer.renderFaceYPos(block, x, y - 1.0F + var11, z, innerBottomIcon); + return true; + } + + @Override + public boolean shouldRender3DInInventory(int arg0) + { + return true; + } +} diff --git a/ihl/model/IronWorkbenchBlockRender.java b/ihl/model/IronWorkbenchBlockRender.java new file mode 100644 index 0000000..43793ed --- /dev/null +++ b/ihl/model/IronWorkbenchBlockRender.java @@ -0,0 +1,111 @@ +package ihl.model; + +import ic2.api.tile.IWrenchable; +import ihl.items_blocks.MachineBaseBlock; +import ihl.utils.IHLRenderUtils; + +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 net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class IronWorkbenchBlockRender implements ISimpleBlockRenderingHandler +{ + public static int renderId; + + public IronWorkbenchBlockRender() + { + 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; + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + for(int i=0;i<=5;i++) + { + this.setBounds(i, renderblocks, block); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + } + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + renderblocks.clearOverrideBlockTexture(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta, RenderBlocks renderblocks) + { + Tessellator var5 = Tessellator.instance; + var5.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z)); + int var6 = block.colorMultiplier(blockAccess, x, y, z); + float var7 = (var6 >> 16 & 255) / 255.0F; + float var8 = (var6 >> 8 & 255) / 255.0F; + float var9 = (var6 & 255) / 255.0F; + var5.setColorOpaque_F(var7, var8, var9); + for(int i=0;i<=5;i++) + { + this.setBounds(i, renderblocks, block); + renderblocks.renderStandardBlock(block, x, y, z); + } + return true; + } + + private void setBounds(int index, RenderBlocks renderblocks, Block block) + { + double rt = 1/11d; + switch(index) + { + case 0: + renderblocks.setRenderBounds(0d, 10*rt, 0d, 1d, 1d, 1d); + break; + case 1: + renderblocks.setRenderBounds(rt*2, 4*rt, rt*2, 9*rt, 5*rt, 9*rt); + break; + case 2: + renderblocks.setRenderBounds(rt, 0d, rt, rt*3, rt*10, rt*3); + break; + case 3: + renderblocks.setRenderBounds(rt*8, 0d, rt, rt*10, rt*10, rt*3); + break; + case 4: + renderblocks.setRenderBounds(rt, 0d, rt*8, rt*3, rt*10, rt*10); + break; + case 5: + renderblocks.setRenderBounds(rt*8, 0d, rt*8, rt*10, rt*10, rt*10); + break; + } + } + + @Override + public boolean shouldRender3DInInventory(int arg0) + { + return true; + } +} diff --git a/ihl/model/ModelKnee.java b/ihl/model/ModelKnee.java new file mode 100644 index 0000000..c352431 --- /dev/null +++ b/ihl/model/ModelKnee.java @@ -0,0 +1,225 @@ +package ihl.model; + +import net.minecraft.client.model.PositionTextureVertex; +import net.minecraft.client.model.TexturedQuad; +import net.minecraft.client.renderer.Tessellator; +import net.minecraftforge.common.util.ForgeDirection; + +public class ModelKnee { + /** + * The (x,y,z) vertex positions and (u,v) texture coordinates for each of the 8 points on a cube + */ + private PositionTextureVertex[] vertexPositions; + + /** An array of 6 TexturedQuads, one for each face of a cube */ + private TexturedQuad[] quadList; + + /** X vertex coordinate of lower box corner */ + public final float posX1; + + /** Y vertex coordinate of lower box corner */ + public final float posY1; + + /** Z vertex coordinate of lower box corner */ + public final float posZ1; + + /** X vertex coordinate of upper box corner */ + public final float posX2; + + /** Y vertex coordinate of upper box corner */ + public final float posY2; + + /** Z vertex coordinate of upper box corner */ + public final float posZ2; + public String field_78247_g; + private ForgeDirection direction1; + private ForgeDirection direction2; + + public ModelKnee(IHLModelRenderer par1ModelRenderer, int par2, int par3, float x1, float y1, float z1, int par7, int par8, int par9, float par10, float radius1, float radius2, ForgeDirection direction1_1) + { + this(par1ModelRenderer, par2, par3, x1, y1, z1, par7, par8, par9, par10, radius1, radius2, direction1_1, direction1_1); + } + + + public ModelKnee(IHLModelRenderer par1ModelRenderer, int par2, int par3, float x1, float y1, float z1, int par7, int par8, int par9, float par10, float radius1, float radius2, ForgeDirection direction1_1, ForgeDirection direction2_1) + { + this.direction1=direction1_1; + this.direction2=direction2_1; + this.posX1 = x1; + this.posY1 = y1; + this.posZ1 = z1; + this.posX2 = x1 + par7; + this.posY2 = y1 + par8; + this.posZ2 = z1 + par9; + this.vertexPositions = new PositionTextureVertex[32]; + this.quadList = new TexturedQuad[32]; + float x2 = x1 + par7; + float y2 = y1 + par8; + float z2 = z1 + par9; + x1 -= par10; + y1 -= par10; + z1 -= par10; + x2 += par10; + y2 += par10; + z2 += par10; + + if (par1ModelRenderer.mirror) + { + float var14 = x2; + x2 = x1; + x1 = var14; + } + float dx = x2-x1 ; + float dy = y2-y1; + float dz = z2-z1; + PositionTextureVertex[] outervertexes1 = new PositionTextureVertex[8]; + PositionTextureVertex[] innervertexes1 = new PositionTextureVertex[8]; + PositionTextureVertex[] outervertexes2 = new PositionTextureVertex[8]; + PositionTextureVertex[] innervertexes2 = new PositionTextureVertex[8]; + int i=0; + for(i=0;i<8;i++) + { + switch(direction1) + { + case UP: + outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.25F*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case DOWN: + outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F-dz*0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F-dz*0.25F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case SOUTH: + outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case NORTH: + outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case EAST: + outervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.25F*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case WEST: + outervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.52F*radius2*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + default: + outervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.52F*radius2*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + } + + switch(direction2) + { + case UP: + outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case DOWN: + outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case WEST: + outervertexes2[i] = new PositionTextureVertex(x2, y1+dy*0.5F+dy*0.25F*(float)Math.cos(2D*Math.PI/8D*i), z1+dz*0.5F-dz*0.25F*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes2[i] = new PositionTextureVertex(x2, y1+dy*0.5F+dy*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), z1+dz*0.5F-dz*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case EAST: + outervertexes2[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*(float)Math.cos(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.25F*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes2[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case NORTH: + outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+z2-dz*0.5F-dz*0.25F*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+z2-dz*0.5F-dz*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + case SOUTH: + outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*(float)Math.sin(2D*Math.PI/8D*i), z1, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + default: + outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + break; + } + } + for(i=0;i<32;i++) + { + if(i<8) + { + this.vertexPositions[i]=outervertexes1[i]; + } + else if(i<16) + { + this.vertexPositions[i]=innervertexes1[i-8]; + } + else if(i<24) + { + this.vertexPositions[i]=outervertexes2[i-16]; + } + else + { + this.vertexPositions[i]=innervertexes2[i-24]; + } + } + for(i=0;i<32;i++) + { + if(i<7) + { + this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i],outervertexes1[i+1],innervertexes1[i+1],innervertexes1[i]},par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + } + else if(i==7) + { + this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i],outervertexes1[0],innervertexes1[0],innervertexes1[i]},par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + } + else if(i<15) + { + this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes2[i-8],innervertexes2[i+1-8],outervertexes2[i+1-8],outervertexes2[i-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + } + else if(i==15) + { + this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes2[i-8],innervertexes2[0],outervertexes2[0],outervertexes2[i-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + } + else if(i<23) + { + this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[i-16+1],outervertexes1[i-16+1]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + } + else if(i==23) + { + this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[0],outervertexes1[0]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + } + else if(i<31) + { + this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[i-24+1],innervertexes2[i-24+1], innervertexes2[i-24], innervertexes1[i-24]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + } + else if(i==31) + { + this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[0],innervertexes2[0],innervertexes2[i-24],innervertexes1[i-24]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + } + } + if (par1ModelRenderer.mirror) + { + for (int var22 = 0; var22 < this.quadList.length; ++var22) + { + this.quadList[var22].flipFace(); + } + } + } + + /** + * Draw the six sided box defined by this ModelBox + */ + public void render(Tessellator par1Tessellator, float par2) + { + for(int i=0;i> 16 & 255) / 255.0F; + float var8 = (var6 >> 8 & 255) / 255.0F; + float var9 = (var6 & 255) / 255.0F; + float var11; + var5.setColorOpaque_F(var7, var8, var9); + return true; + } + + @Override + public boolean shouldRender3DInInventory(int arg0) + { + return true; + } +} diff --git a/ihl/model/RectifierTransformerUnitBlockRender.java b/ihl/model/RectifierTransformerUnitBlockRender.java new file mode 100644 index 0000000..081db7a --- /dev/null +++ b/ihl/model/RectifierTransformerUnitBlockRender.java @@ -0,0 +1,414 @@ +package ihl.model; + +import ic2.api.tile.IWrenchable; +import ihl.items_blocks.MachineBaseBlock; +import ihl.utils.IHLRenderUtils; + +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 net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class RectifierTransformerUnitBlockRender implements ISimpleBlockRenderingHandler +{ + public static int renderId; + + public RectifierTransformerUnitBlockRender() + { + 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; + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + for(int i=0;i<=43;i++) + { + this.setBounds(i, renderblocks, block); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0)); + } + + + this.setBounds(44, renderblocks, block); + renderblocks.renderFaceXNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceXPos(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceZNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceZPos(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceYNeg(block,0, 0, 0, block.getIcon(5, 0)); + + this.setBounds(45, renderblocks, block); + renderblocks.renderFaceXNeg(block,0, 0, 0, block.getIcon(5, 0)); + renderblocks.renderFaceXPos(block,0, 0, 0, block.getIcon(5, 0)); + renderblocks.renderFaceZNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceZPos(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceYNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceYPos(block,0, 0, 0, block.getIcon(0, 0)); + + this.setBounds(46, renderblocks, block); + renderblocks.renderFaceXNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceXPos(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceZNeg(block,0, 0, 0, block.getIcon(5, 0)); + renderblocks.renderFaceZPos(block,0, 0, 0, block.getIcon(5, 0)); + renderblocks.renderFaceYNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceYPos(block,0, 0, 0, block.getIcon(0, 0)); + + this.setBounds(47, renderblocks, block); + renderblocks.renderFaceXNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceXPos(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceZNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceZPos(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceYNeg(block,0, 0, 0, block.getIcon(0, 0)); + renderblocks.renderFaceYPos(block,0, 0, 0, block.getIcon(4, 0)); + + + IHLRenderUtils.instance.setPosition(0, 0, 0); + IHLRenderUtils.instance.setRotationPoint(0F, 16F, 0F); + IHLRenderUtils.instance.setRotation(0F, 0f, 0F); + + IIcon icon = block.getIcon(1, 0); + IHLRenderUtils.instance.drawPipe(-6F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-6F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-6F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + IHLRenderUtils.instance.drawPipe(2F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(2F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(2F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + icon = block.getIcon(2, 0); + IHLRenderUtils.instance.drawPipe(-4.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + icon = block.getIcon(3, 0); + IHLRenderUtils.instance.drawPipe(3.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + renderblocks.clearOverrideBlockTexture(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta, RenderBlocks renderblocks) + { + Tessellator var5 = Tessellator.instance; + var5.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z)); + int var6 = block.colorMultiplier(blockAccess, x, y, z); + float var7 = (var6 >> 16 & 255) / 255.0F; + float var8 = (var6 >> 8 & 255) / 255.0F; + float var9 = (var6 & 255) / 255.0F; + var5.setColorOpaque_F(var7, var8, var9); + for(int i=0;i<=43;i++) + { + this.setBounds(i, renderblocks, block); + renderblocks.renderStandardBlock(block, x, y, z); + } + + this.setBounds(44, renderblocks, block); + renderblocks.renderFaceXNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceXPos(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceZNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceZPos(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceYNeg(block, x, y, z, block.getIcon(5, 0)); + + this.setBounds(45, renderblocks, block); + renderblocks.renderFaceXNeg(block, x, y, z, block.getIcon(5, 0)); + renderblocks.renderFaceXPos(block, x, y, z, block.getIcon(5, 0)); + renderblocks.renderFaceZNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceZPos(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceYPos(block, x, y, z, block.getIcon(0, 0)); + + this.setBounds(46, renderblocks, block); + renderblocks.renderFaceXNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceXPos(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceZNeg(block, x, y, z, block.getIcon(5, 0)); + renderblocks.renderFaceZPos(block, x, y, z, block.getIcon(5, 0)); + renderblocks.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceYPos(block, x, y, z, block.getIcon(0, 0)); + + this.setBounds(47, renderblocks, block); + renderblocks.renderFaceXNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceXPos(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceZNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceZPos(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0)); + renderblocks.renderFaceYPos(block, x, y, z, block.getIcon(4, 0)); + + IHLRenderUtils.instance.setPosition(x, y, z); + IHLRenderUtils.instance.setRotationPoint(0F, 16F, 0F); + IHLRenderUtils.instance.setRotation(0F, 0f, 0F); + + IIcon icon = block.getIcon(1, 0); + + TileEntity tile = blockAccess.getTileEntity(x, y, z); + if(tile!=null && tile.getWorldObj() != null) + { + switch (((IWrenchable)tile).getFacing()) + { + case 2: + IHLRenderUtils.instance.drawPipe(-6F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-6F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-6F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + IHLRenderUtils.instance.drawPipe(2F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(2F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(2F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + icon = block.getIcon(2, 0); + IHLRenderUtils.instance.drawPipe(-4.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + icon = block.getIcon(3, 0); + IHLRenderUtils.instance.drawPipe(3.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + break; + case 5: + IHLRenderUtils.instance.drawPipe(-2F, -14F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -12F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -10F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + IHLRenderUtils.instance.drawPipe(-2F, -14F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -12F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -10F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + icon = block.getIcon(2, 0); + IHLRenderUtils.instance.drawPipe(-0.5F, -16F, -4.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + icon = block.getIcon(3, 0); + IHLRenderUtils.instance.drawPipe(-0.5F, -16F, 3.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + break; + case 3: + IHLRenderUtils.instance.drawPipe(-6F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-6F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-6F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + IHLRenderUtils.instance.drawPipe(2F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(2F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(2F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + icon = block.getIcon(3, 0); + IHLRenderUtils.instance.drawPipe(-4.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + icon = block.getIcon(2, 0); + IHLRenderUtils.instance.drawPipe(3.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + break; + case 4: + IHLRenderUtils.instance.drawPipe(-2F, -14F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -12F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -10F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + IHLRenderUtils.instance.drawPipe(-2F, -14F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -12F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -10F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + icon = block.getIcon(3, 0); + IHLRenderUtils.instance.drawPipe(-0.5F, -16F, -4.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + icon = block.getIcon(2, 0); + IHLRenderUtils.instance.drawPipe(-0.5F, -16F, 3.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + break; + default: + IHLRenderUtils.instance.drawPipe(-6F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-6F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-6F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + IHLRenderUtils.instance.drawPipe(2F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(2F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(2F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon); + + icon = block.getIcon(2, 0); + IHLRenderUtils.instance.drawPipe(-4.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + icon = block.getIcon(3, 0); + IHLRenderUtils.instance.drawPipe(3.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon); + break; + } + } + return true; + } + + private void setBounds(int index, RenderBlocks renderblocks, Block block) + { + double rt = 1/11d; + switch(index) + { + case 0: + renderblocks.setRenderBounds(rt, 0d, 0d, rt*2, 1d, rt); + break; + case 1: + renderblocks.setRenderBounds(rt*3, rt*8, 0d, rt*4, 1d, rt); + break; + case 2: + renderblocks.setRenderBounds(rt*5, rt*8, 0d, rt*6, 1d, rt); + break; + case 3: + renderblocks.setRenderBounds(rt*7, rt*8, 0d, rt*8, 1d, rt); + break; + case 4: + renderblocks.setRenderBounds(rt*3, 0d, 0d, rt*4, rt*3, rt); + break; + case 5: + renderblocks.setRenderBounds(rt*5, 0d, 0d, rt*6, rt*3, rt); + break; + case 6: + renderblocks.setRenderBounds(rt*7, 0d, 0d, rt*8, rt*3, rt); + break; + case 7: + renderblocks.setRenderBounds(rt*9, 0d, 0d, rt*10, 1d, rt); + break; + + case 8: + renderblocks.setRenderBounds(rt, 0d, rt*10, rt*2, 1d, 1d); + break; + case 9: + renderblocks.setRenderBounds(rt*3, rt*8, rt*10, rt*4, 1d, 1d); + break; + case 10: + renderblocks.setRenderBounds(rt*5, rt*8, rt*10, rt*6, 1d, 1d); + break; + case 11: + renderblocks.setRenderBounds(rt*7, rt*8, rt*10, rt*8, 1d, 1d); + break; + case 12: + renderblocks.setRenderBounds(rt*3, 0d, rt*10, rt*4, rt*3, 1d); + break; + case 13: + renderblocks.setRenderBounds(rt*5, 0d, rt*10, rt*6, rt*3, 1d); + break; + case 14: + renderblocks.setRenderBounds(rt*7, 0d, rt*10, rt*8, rt*3, 1d); + break; + case 15: + renderblocks.setRenderBounds(rt*9, 0d, rt*10, rt*10, 1d, 1d); + break; + + case 16: + renderblocks.setRenderBounds(0d, 0d, rt, rt, 1d, rt*2); + break; + case 17: + renderblocks.setRenderBounds(0d,rt*8, rt*3,rt,1d, rt*4); + break; + case 18: + renderblocks.setRenderBounds(0d,rt*8, rt*5,rt, 1d, rt*6); + break; + case 19: + renderblocks.setRenderBounds(0d,rt*8, rt*7,rt,1d, rt*8); + break; + case 20: + renderblocks.setRenderBounds(0d,0d, rt*3, rt, rt*3,rt*4); + break; + case 21: + renderblocks.setRenderBounds(0d,0d, rt*5,rt, rt*3, rt*6); + break; + case 22: + renderblocks.setRenderBounds(0d,0d, rt*7, rt,rt*3, rt*8); + break; + case 23: + renderblocks.setRenderBounds(0d,0d, rt*9,rt,1d, rt*10); + break; + + case 24: + renderblocks.setRenderBounds(rt*10, 0d, rt, 1d, 1d, rt*2); + break; + case 25: + renderblocks.setRenderBounds(rt*10, rt*8, rt*3, 1d, 1d, rt*4); + break; + case 26: + renderblocks.setRenderBounds(rt*10, rt*8, rt*5,1d, 1d, rt*6); + break; + case 27: + renderblocks.setRenderBounds(rt*10, rt*8, rt*7, 1d, 1d, rt*8); + break; + case 28: + renderblocks.setRenderBounds(rt*10, 0d, rt*3, 1d, rt*3, rt*4); + break; + case 29: + renderblocks.setRenderBounds(rt*10, 0d, rt*5,1d, rt*3, rt*6); + break; + case 30: + renderblocks.setRenderBounds(rt*10, 0d, rt*7,1d, rt*3, rt*8); + break; + case 31: + renderblocks.setRenderBounds(rt*10, 0d, rt*9, 1d, 1d, rt*10); + break; + + case 32: + renderblocks.setRenderBounds(rt, 0d, rt*3, rt*3, rt, rt*4); + break; + case 33: + renderblocks.setRenderBounds(rt, 0d, rt*5, rt*3, rt, rt*6); + break; + case 34: + renderblocks.setRenderBounds(rt, 0d, rt*7, rt*3, rt, rt*8); + break; + case 35: + renderblocks.setRenderBounds(rt*8, 0d, rt*3, rt*10, rt, rt*4); + break; + case 36: + renderblocks.setRenderBounds(rt*8, 0d, rt*5, rt*10, rt, rt*6); + break; + case 37: + renderblocks.setRenderBounds(rt*8, 0d, rt*7, rt*10, rt, rt*8); + break; + + case 38: + renderblocks.setRenderBounds(rt*3, 0d, rt, rt*4, rt, rt*3); + break; + case 39: + renderblocks.setRenderBounds(rt*5, 0d, rt, rt*6, rt, rt*3); + break; + case 40: + renderblocks.setRenderBounds(rt*7, 0d, rt, rt*8, rt, rt*3); + break; + case 41: + renderblocks.setRenderBounds(rt*3, 0d, rt*8, rt*4, rt, rt*10); + break; + case 42: + renderblocks.setRenderBounds(rt*5, 0d, rt*8, rt*6, rt, rt*10); + break; + case 43: + renderblocks.setRenderBounds(rt*7, 0d, rt*8, rt*8, rt, rt*10); + break; + + case 44: + renderblocks.setRenderBounds(rt*3, 0d, rt*3, rt*8, rt, rt*8); + break; + + case 45: + renderblocks.setRenderBounds(0d, rt*3, rt*3, 1d, rt*8, rt*8); + break; + + case 46: + renderblocks.setRenderBounds(rt*3, rt*3, 0d, rt*8, rt*8, 1d); + break; + + case 47: + renderblocks.setRenderBounds(rt, rt, rt, rt*10, 1d, rt*10); + break; + + } + } + + @Override + public boolean shouldRender3DInInventory(int arg0) + { + return true; + } +} diff --git a/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java b/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java new file mode 100644 index 0000000..6e3e944 --- /dev/null +++ b/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java @@ -0,0 +1,54 @@ +package ihl.model; + +import ic2.api.tile.IWrenchable; +import ihl.flexible_cable.AnchorTileEntity; +import ihl.flexible_cable.RectifierTransformerUnitTileEntity; +import ihl.interfaces.ISelectionBoxSpecialRenderer; +import ihl.utils.IHLUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; + +import org.lwjgl.opengl.GL11; + +public class RectifierTransformerUnitSelectionBoxSpecialRenderer implements ISelectionBoxSpecialRenderer +{ + public void drawSelectionBox(EntityPlayer player, ItemStack currentItem, MovingObjectPosition movingObjectPosition, float partialTick) + { + double offsetX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTick; + double offsetY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTick; + double offsetZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTick; + RectifierTransformerUnitTileEntity tile = (RectifierTransformerUnitTileEntity) Minecraft.getMinecraft().theWorld.getTileEntity(movingObjectPosition.blockX, movingObjectPosition.blockY, movingObjectPosition.blockZ); + if(tile!=null && tile.getWorldObj() != null) + { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glLineWidth(2.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(false); + short side = tile.getSide(player); + if(side==0) + { + GL11.glColor4f(0.0F, 1.0F, 0.0F, 0.8F); + RenderGlobal.drawOutlinedBoundingBox(tile.aabb1.getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + RenderGlobal.drawOutlinedBoundingBox(tile.aabb1_1.getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + } + else if(side==1) + { + GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.8F); + RenderGlobal.drawOutlinedBoundingBox(tile.aabb2.getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + RenderGlobal.drawOutlinedBoundingBox(tile.aabb2_1.getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + } + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + } + } +} diff --git a/ihl/model/RefluxCondenserBlockRender.java b/ihl/model/RefluxCondenserBlockRender.java new file mode 100644 index 0000000..7d78c27 --- /dev/null +++ b/ihl/model/RefluxCondenserBlockRender.java @@ -0,0 +1,123 @@ +package ihl.model; + +import ic2.api.tile.IWrenchable; +import ihl.utils.IHLRenderUtils; + +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 net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; + +public class RefluxCondenserBlockRender implements ISimpleBlockRenderingHandler +{ + public static int renderId; + + public RefluxCondenserBlockRender() + { + renderId = RenderingRegistry.getNextAvailableRenderId(); + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks) + { + Tessellator tessellator = Tessellator.instance; + IHLRenderUtils.instance.reset(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + IIcon icon = block.getIcon(0, 0); + IHLRenderUtils.instance.setPosition(0, 0, 0); + IHLRenderUtils.instance.setRotationPoint(0F, 16F, 0F); + IHLRenderUtils.instance.setRotation(0F, 0f, 0F); + IHLRenderUtils.instance.drawPipe(-2F, 7F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawKnee(-8F, 2F, -3F, 5, 6, 6, .8F, 1F, ForgeDirection.UP, ForgeDirection.EAST,icon); + IHLRenderUtils.instance.drawPipe(3.5F, -7F, -1.5F, 4, 3, 3, 0.8f, 1f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(7F, -7.5F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(7F, 3F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(-3F, 3.5F, -1.5F, 10, 3, 3, .8F, 1F, ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(-2F, -8F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-1.5F, -7F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-1.5F, 5F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -2F, -8F, 4, 4, 1, 0.6f, 1f,ForgeDirection.NORTH,icon); + IHLRenderUtils.instance.drawPipe(-1.5F, -1.5F, -7F, 3, 3, 7, 0.8f, 1f,ForgeDirection.NORTH,icon); + IHLRenderUtils.instance.setRotationPoint(3F, 16F, 0F); + IHLRenderUtils.instance.setRotation(0F, 0f, -0.5F); + IHLRenderUtils.instance.drawPipe(1F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(-9F, -4F, -4F, 10, 8, 8, 0.8f, 1f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(-11F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.EAST,icon); + 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) + { + IHLRenderUtils.instance.reset(); + TileEntity tile = blockAccess.getTileEntity(x, y, z); + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)tile).getFacing()) + { + case 5: + IHLRenderUtils.instance.renderFromInside=true; + IHLRenderUtils.instance.swapXandZ=true; + IHLRenderUtils.instance.swapRenderBoundsZ=true; + break; + case 3: + IHLRenderUtils.instance.swapRenderBoundsX=true; + IHLRenderUtils.instance.swapRenderBoundsZ=true; + break; + case 4: + IHLRenderUtils.instance.renderFromInside=true; + IHLRenderUtils.instance.swapXandZ=true; + IHLRenderUtils.instance.swapRenderBoundsX=true; + break; + default: + } + } + Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z)); + int colorMultiplier = block.colorMultiplier(blockAccess, x, y, z); + float red = (colorMultiplier >> 16 & 255) / 255.0F; + float green = (colorMultiplier >> 8 & 255) / 255.0F; + float blue = (colorMultiplier & 255) / 255.0F; + Tessellator.instance.setColorOpaque_F(red, green, blue); + IIcon icon = block.getBlockTextureFromSide(0); + IHLRenderUtils.instance.setPosition(x, y, z); + IHLRenderUtils.instance.setRotationPoint(0F, 16F, 0F); + IHLRenderUtils.instance.setRotation(0F, 0f, 0F); + IHLRenderUtils.instance.drawPipe(-2F, 7F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawKnee(-8F, 2F, -3F, 5, 6, 6, .8F, 1F, ForgeDirection.UP, ForgeDirection.EAST,icon); + IHLRenderUtils.instance.drawPipe(3.5F, -7F, -1.5F, 4, 3, 3, 0.8f, 1f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(7F, -7.5F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(7F, 3F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(-3F, 3.5F, -1.5F, 10, 3, 3, .8F, 1F, ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(-2F, -8F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-1.5F, -7F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-1.5F, 5F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP,icon); + IHLRenderUtils.instance.drawPipe(-2F, -2F, -8F, 4, 4, 1, 0.6f, 1f,ForgeDirection.NORTH,icon); + IHLRenderUtils.instance.drawPipe(-1.5F, -1.5F, -7F, 3, 3, 7, 0.8f, 1f,ForgeDirection.NORTH,icon); + IHLRenderUtils.instance.setRotationPoint(3F, 16F, 0F); + IHLRenderUtils.instance.setRotation(0F, 0f, -0.5F); + IHLRenderUtils.instance.drawPipe(1F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(-9F, -4F, -4F, 10, 8, 8, 0.8f, 1f,ForgeDirection.WEST,icon); + IHLRenderUtils.instance.drawPipe(-11F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.EAST,icon); + return true; + } + + @Override + public boolean shouldRender3DInInventory(int arg0) + { + return true; + } + + @Override + public int getRenderId() { + return renderId; + } +} diff --git a/ihl/model/RenderGameOverlayEventHandler.java b/ihl/model/RenderGameOverlayEventHandler.java new file mode 100644 index 0000000..e2bbde4 --- /dev/null +++ b/ihl/model/RenderGameOverlayEventHandler.java @@ -0,0 +1,39 @@ +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.GuiIngameForge; +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/RenderInfo.java b/ihl/model/RenderInfo.java new file mode 100644 index 0000000..dde123d --- /dev/null +++ b/ihl/model/RenderInfo.java @@ -0,0 +1,68 @@ +package ihl.model; + +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; + +public class RenderInfo { + + public Block template = Blocks.stone; + public IIcon[] texture = null; + public IIcon override = null; + public float minX = 0; + public float minY = 0; + public float minZ = 0; + public float maxX = 1; + public float maxY = 1; + public float maxZ = 1; + public boolean[] renderSide = new boolean[6]; + public float light = -1f; + public int brightness = -1; + + public RenderInfo() { + setRenderAllSides(); + } + + public RenderInfo(Block template, IIcon[] texture) { + this(); + this.template = template; + this.texture = texture; + } + + public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { + this(); + setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); + } + + public final void setBlockBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { + this.minX = minX; + this.minY = minY; + this.minZ = minZ; + this.maxX = maxX; + this.maxY = maxY; + this.maxZ = maxZ; + } + + public final void setRenderSingleSide(int side) { + Arrays.fill(renderSide, false); + renderSide[side] = true; + } + + public final void setRenderAllSides() { + Arrays.fill(renderSide, true); + } + + public IIcon getBlockTextureFromSide(int i) { + if (override != null) + return override; + if (texture == null || texture.length == 0) + return template.getBlockTextureFromSide(i); + else { + if (i >= texture.length) + i = 0; + return texture[i]; + } + } +} diff --git a/ihl/model/SwitchBoxBlockRender.java b/ihl/model/SwitchBoxBlockRender.java new file mode 100644 index 0000000..93f63a7 --- /dev/null +++ b/ihl/model/SwitchBoxBlockRender.java @@ -0,0 +1,129 @@ +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; + float var11; + var5.setColorOpaque_F(var7, var8, var9); + var11 = 0.0625F; + 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/model/UniversalTileRender.java b/ihl/model/UniversalTileRender.java new file mode 100644 index 0000000..8062778 --- /dev/null +++ b/ihl/model/UniversalTileRender.java @@ -0,0 +1,73 @@ +package ihl.model; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; +import ihl.flexible_cable.IronWorkbenchModel; + +public class UniversalTileRender extends TileEntitySpecialRenderer{ +private ModelBase model = new IronWorkbenchModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/ironWorkbench.png"); +private final float scale=1F/16F; + +public UniversalTileRender(ModelBase model1, ResourceLocation texture) +{ + this.model=model1; + this.tex=texture; +} + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)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; + } + } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + + bindTexture(tex); + for(int i = 0;i getGuiClass() + { + return AchesonFurnaceGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{34-5,34-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{41-11,23-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{107-5,107-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{41-11,23-11}; + } + + @Override + public String getRecipeName() + { + return "Acheson Furnace"; + } + + @Override + public String getRecipeId() + { + return "ihl.achesonFurnace"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIAchesonFurnaceNEI.png"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(40-5, 55-11, 90, 30), this.getRecipeId(), new Object[0])); + } + + @Override + public String getOverlayIdentifier() + { + return "achesonFurnace"; + } + + @Override + public Map getRecipeList() + { + return AchesonFurnanceTileEntity.getRecipes(); + } + + @Override + public List getAdditionalIngredients() + { + List ps = new ArrayList(); + RecipeInputOreDictionaryList ari = new RecipeInputOreDictionaryList(new String[] {"stickCoal","stickGraphite"}); + ps.add(new PositionedStack(ari.getInputs(),16-5,41-11)); + ps.add(new PositionedStack(ari.getInputs(),52-5,41-11)); + ps.add(new PositionedStack(IHLUtils.getOreDictItemStack("stickGraphite"),89-5,41-11)); + ps.add(new PositionedStack(IHLUtils.getOreDictItemStack("stickGraphite"),125-5,41-11)); + return ps; + } + +} diff --git a/ihl/nei_integration/ChemicalReactorRecipeHandler.java b/ihl/nei_integration/ChemicalReactorRecipeHandler.java new file mode 100644 index 0000000..161bdfe --- /dev/null +++ b/ihl/nei_integration/ChemicalReactorRecipeHandler.java @@ -0,0 +1,140 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import ihl.processing.chemistry.ChemicalReactorGui; +import ihl.processing.chemistry.ChemicalReactorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.StatCollector; + + +public class ChemicalReactorRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return ChemicalReactorGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{104-5,122-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{15-11}; + } + + @Override + protected int[] getFluidInputPosX() + { + return new int[]{42-5,60-5}; + } + + @Override + protected int[] getFluidInputPosY() + { + return new int[]{15-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{104-5,122-5}; + } + + @Override + protected int[] getFluidOutputPosX() + { + return new int[]{42-5,60-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{51-11}; + } + + @Override + protected int[] getFluidOutputPosY() + { + return new int[]{51-11}; + } + + @Override + public String getRecipeName() + { + return "Chemical reactor"; + } + + @Override + public String getRecipeId() + { + return "ihl.chemicalReactor"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIChemicalReactor.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "chemicalReactor"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(103-5,32-10, 36, 18), this.getRecipeId(), new Object[0])); + } + + @Override + public void drawExtras(int recipeNumber) + { + super.drawExtras(recipeNumber); + MachineRecipeHandler.CachedIORecipe recipe = (CachedIORecipe) this.arecipes.get(recipeNumber); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.drawTexturedModalRect(103-18-5, 52-11, 246, 226+6*(this.ticks%4),10,6); + if(recipe.specialConditions) + { + GuiDraw.drawTexturedModalRect(0, 32-11, 0, 166,134,18); + GuiDraw.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.use_with_cryogenic_distiller"), 0, 27, 16777215); + } + } + + @Override + public void drawBackground(int i) + { + super.drawBackground(i); + GuiDraw.drawTexturedModalRect(41-5, 14-11, 59, 14, 18, 18); + GuiDraw.drawTexturedModalRect(41-5, 50-11, 59, 50, 18, 18); + } + + @Override + public Map getRecipeList() + { + return ChemicalReactorTileEntity.getRecipes(); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} diff --git a/ihl/nei_integration/ChimneyKneeRecipeHandler.java b/ihl/nei_integration/ChimneyKneeRecipeHandler.java new file mode 100644 index 0000000..d60c251 --- /dev/null +++ b/ihl/nei_integration/ChimneyKneeRecipeHandler.java @@ -0,0 +1,73 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.chemistry.GoldChimneyKneeTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class ChimneyKneeRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return null; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{6-5,6-5,106-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{33-11,53-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{96-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{35-11,31-11}; + } + + + @Override + public String getRecipeName() + { + return "Chimney knee"; + } + + @Override + public String getRecipeId() + { + return "ihl.chimneyKnee"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIChimneyKneeNEI.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "chimneyKnee"; + } + + @Override + public Map getRecipeList() + { + return GoldChimneyKneeTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/CrucibleRecipeHandler.java b/ihl/nei_integration/CrucibleRecipeHandler.java new file mode 100644 index 0000000..dc2c012 --- /dev/null +++ b/ihl/nei_integration/CrucibleRecipeHandler.java @@ -0,0 +1,86 @@ +package ihl.nei_integration; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import codechicken.nei.PositionedStack; +import ihl.processing.metallurgy.Crucible; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class CrucibleRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return null; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{11-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{15-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{106-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{51-11}; + } + + + @Override + public String getRecipeName() + { + return "Crucible"; + } + + @Override + public String getRecipeId() + { + return "ihl.crucible"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUICrucibleNEI.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "crucible"; + } + + @Override + public Map getRecipeList() + { + return Crucible.getRecipes(); + } + + @Override + public List getAdditionalIngredients() + { + List ps = new ArrayList(); + ps.add(new PositionedStack(IHLUtils.getThisModItemStackWithDamage("crucible", 0),61-5,15-11)); + ps.add(new PositionedStack(IHLUtils.getThisModItemStackWithDamage("crucible", 1),106-5,15-11)); + return ps; + } +} diff --git a/ihl/nei_integration/CryogenicDistillerRecipeHandler.java b/ihl/nei_integration/CryogenicDistillerRecipeHandler.java new file mode 100644 index 0000000..c3bcff3 --- /dev/null +++ b/ihl/nei_integration/CryogenicDistillerRecipeHandler.java @@ -0,0 +1,111 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Iterator; +import java.util.Map; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import ic2.core.item.ItemFluidCell; +import ihl.processing.chemistry.CryogenicDistillerGui; +import ihl.processing.chemistry.CryogenicDistillerTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidStack; + + +public class CryogenicDistillerRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return CryogenicDistillerGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{103-5}; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(102-5, 32-10, 18, 18), this.getRecipeId(), new Object[0])); + } + + @Override + protected int[] getInputPosY() + { + return new int[]{51-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{123-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{33-11,51-11}; + } + + + @Override + public String getRecipeName() + { + return "Cryogenic distiller"; + } + + @Override + public String getRecipeId() + { + return "ihl.cryogenicDistiller"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUICryogenicDistiller.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "cryogenicDistiller"; + } + + @Override + public void drawExtras(int recipeNumber) + { + MachineRecipeHandler.CachedIORecipe recipe = (MachineRecipeHandler.CachedIORecipe) this.arecipes.get(recipeNumber); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + if(recipe.specialConditions) + { + GuiDraw.drawTexturedModalRect(0, 0, 0, 166, 97, 69); + String note = StatCollector.translateToLocal("ihl.as_byproduct_of_processing_of"); + FluidStack fstack = ((ItemFluidCell)recipe.getIngredients().get(0).item.getItem()).getFluid(recipe.getIngredients().get(0).item); + note+=" "+ fstack.getLocalizedName(); + note+=" "+ StatCollector.translateToLocal("ihl.in_chemical_reactor"); + Iterator noteListIterator = GuiDraw.fontRenderer.listFormattedStringToWidth(note, 90).iterator(); + int yTextPos=0; + while(noteListIterator.hasNext()) + { + GuiDraw.fontRenderer.drawStringWithShadow(noteListIterator.next(), 0, yTextPos, 16777215); + yTextPos+=10; + } + GuiDraw.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.check_usage"), 0, 44, 16777215); + } + } + + @Override + public Map getRecipeList() + { + return CryogenicDistillerTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/DetonationSprayingMachineRecipeHandler.java b/ihl/nei_integration/DetonationSprayingMachineRecipeHandler.java new file mode 100644 index 0000000..07385dd --- /dev/null +++ b/ihl/nei_integration/DetonationSprayingMachineRecipeHandler.java @@ -0,0 +1,88 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import codechicken.lib.gui.GuiDraw; +import ihl.processing.metallurgy.DetonationSprayingMachineGui; +import ihl.processing.metallurgy.DetonationSprayingMachineTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class DetonationSprayingMachineRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return DetonationSprayingMachineGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{10-5,98-5,117-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{17-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{10-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{53-11}; + } + + @Override + public String getRecipeName() + { + return "Detonation Spraying Machine"; + } + + @Override + public String getRecipeId() + { + return "ihl.detonationSprayingMachine"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIDetonationSprayingMachine.png"; + } + + @Override + public void drawBackground(int i) + { + super.drawBackground(i); + GuiDraw.drawTexturedModalRect(9-5, 34-11, 176, 0, 18, 36); + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(30-5,0, 60, 30), this.getRecipeId(), new Object[0])); + } + + @Override + public String getOverlayIdentifier() + { + return "detonationSprayingMachine"; + } + + @Override + public Map getRecipeList() + { + return DetonationSprayingMachineTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/ElectricEvaporatorRecipeHandler.java b/ihl/nei_integration/ElectricEvaporatorRecipeHandler.java new file mode 100644 index 0000000..1c9cff3 --- /dev/null +++ b/ihl/nei_integration/ElectricEvaporatorRecipeHandler.java @@ -0,0 +1,81 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import ihl.processing.chemistry.ElectricEvaporatorGui; +import ihl.processing.chemistry.ElectricEvaporatorTileEntity; +import ihl.processing.chemistry.EvaporatorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class ElectricEvaporatorRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return ElectricEvaporatorGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{39}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{3}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{112}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{21}; + } + + @Override + public String getRecipeName() + { + return "Electric Evaporator"; + } + + @Override + public String getRecipeId() + { + return "ihl.electricEvaporator"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIElectricEvaporator.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "electricEvaporator"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(99-5,34-10, 17, 13), this.getRecipeId(), new Object[0])); + } + + @Override + public Map getRecipeList() + { + return EvaporatorTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/ElectrolysisBathRecipeHandler.java b/ihl/nei_integration/ElectrolysisBathRecipeHandler.java new file mode 100644 index 0000000..38f10ee --- /dev/null +++ b/ihl/nei_integration/ElectrolysisBathRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.chemistry.ElectrolysisBathGui; +import ihl.processing.chemistry.ElectrolysisBathTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class ElectrolysisBathRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return ElectrolysisBathGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{6-5,98-5,78-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{16-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{6-5,87-5,106-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{52-11,51-11,15-11}; + } + + + @Override + public String getRecipeName() + { + return "Electrolysis bath"; + } + + @Override + public String getRecipeId() + { + return "ihl.electrolysisBath"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIElectrolysisBath.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "electrolysisBath"; + } + + @Override + public Map getRecipeList() + { + return ElectrolysisBathTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/EvaporatorRecipeHandler.java b/ihl/nei_integration/EvaporatorRecipeHandler.java new file mode 100644 index 0000000..bfb697e --- /dev/null +++ b/ihl/nei_integration/EvaporatorRecipeHandler.java @@ -0,0 +1,80 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import ihl.processing.chemistry.EvaporatorGui; +import ihl.processing.chemistry.EvaporatorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class EvaporatorRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return EvaporatorGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{39}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{3}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{112}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{21}; + } + + @Override + public String getRecipeName() + { + return "Evaporator"; + } + + @Override + public String getRecipeId() + { + return "ihl.evaporator"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUISolidFuelEvaporator.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "evaporator"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(99-5,34-10, 17, 13), this.getRecipeId(), new Object[0])); + } + + @Override + public Map getRecipeList() + { + return EvaporatorTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/ExtruderRecipeHandler.java b/ihl/nei_integration/ExtruderRecipeHandler.java new file mode 100644 index 0000000..3dae277 --- /dev/null +++ b/ihl/nei_integration/ExtruderRecipeHandler.java @@ -0,0 +1,73 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.metallurgy.ExtruderGui; +import ihl.processing.metallurgy.ExtruderTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class ExtruderRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return ExtruderGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{39-5,57-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{32-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{92-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{32-11}; + } + + @Override + public String getRecipeName() + { + return "Extruder"; + } + + @Override + public String getRecipeId() + { + return "ihl.extruder"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIExtruder.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "extruder"; + } + + @Override + public Map getRecipeList() + { + return ExtruderTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/FluidizedBedReactorRecipeHandler.java b/ihl/nei_integration/FluidizedBedReactorRecipeHandler.java new file mode 100644 index 0000000..9f90536 --- /dev/null +++ b/ihl/nei_integration/FluidizedBedReactorRecipeHandler.java @@ -0,0 +1,112 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import codechicken.lib.gui.GuiDraw; +import ihl.processing.chemistry.FluidizedBedReactorGui; +import ihl.processing.chemistry.FluidizedBedReactorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class FluidizedBedReactorRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return FluidizedBedReactorGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{8-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{23-11,41-11}; + } + + @Override + protected int[] getFluidInputPosX() + { + return new int[]{102-5,84-5}; + } + + @Override + protected int[] getFluidInputPosY() + { + return new int[]{15-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{43-5}; + } + + @Override + protected int[] getFluidOutputPosX() + { + return new int[]{102-5,84-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{33-11}; + } + + @Override + protected int[] getFluidOutputPosY() + { + return new int[]{51-11,51-11}; + } + @Override + public void drawBackground(int i) + { + super.drawBackground(i); + GuiDraw.drawTexturedModalRect(83-5, 14-11, 101, 14, 18, 18); + GuiDraw.drawTexturedModalRect(83-5, 50-11, 101, 14, 18, 18); + } + + @Override + public String getRecipeName() + { + return "Fluidized bed reactor"; + } + + @Override + public String getRecipeId() + { + return "ihl.fluidizedBedReactor"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIFluidizedBedReactor.png"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(25-5,34-10, 17, 13), this.getRecipeId(), new Object[0])); + } + + @Override + public String getOverlayIdentifier() + { + return "fluidizedBedReactor"; + } + + @Override + public Map getRecipeList() + { + return FluidizedBedReactorTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/FractionationColumnRecipeHandler.java b/ihl/nei_integration/FractionationColumnRecipeHandler.java new file mode 100644 index 0000000..eda5896 --- /dev/null +++ b/ihl/nei_integration/FractionationColumnRecipeHandler.java @@ -0,0 +1,73 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.chemistry.FractionatorBottomTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class FractionationColumnRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return null; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{6-5,61-5,106-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{33-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{76-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{51-11,31-11}; + } + + + @Override + public String getRecipeName() + { + return "Fractionation column"; + } + + @Override + public String getRecipeId() + { + return "ihl.fractionator"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIFractionationColumn.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "fractionator"; + } + + @Override + public Map getRecipeList() + { + return FractionatorBottomTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/GasWeldingStationGasRecipeHandler.java b/ihl/nei_integration/GasWeldingStationGasRecipeHandler.java new file mode 100644 index 0000000..0f3a85a --- /dev/null +++ b/ihl/nei_integration/GasWeldingStationGasRecipeHandler.java @@ -0,0 +1,81 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import ihl.processing.metallurgy.GasWeldingStationGui; +import ihl.processing.metallurgy.GasWeldingStationTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class GasWeldingStationGasRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return GasWeldingStationGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{44-5,62-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{15-11,51-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{62-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{15-11,33-11}; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(80-5, 15-11, 50, 50), this.getRecipeId(), new Object[0])); + } + + + @Override + public String getRecipeName() + { + return "Gas welding station"; + } + + @Override + public String getRecipeId() + { + return "ihl.gasWeldingStationGas"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIGasWeldingStation.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "gasWeldingStationGas"; + } + + @Override + public Map getRecipeList() + { + return GasWeldingStationTileEntity.getGasRecipes(); + } +} diff --git a/ihl/nei_integration/IHLBlockHighlightHandler.java b/ihl/nei_integration/IHLBlockHighlightHandler.java new file mode 100644 index 0000000..c6f8359 --- /dev/null +++ b/ihl/nei_integration/IHLBlockHighlightHandler.java @@ -0,0 +1,51 @@ +package ihl.nei_integration; + +import codechicken.nei.api.IHighlightHandler; +import codechicken.nei.api.ItemInfo; +import codechicken.nei.guihook.GuiContainerManager; +import net.minecraft.block.BlockRedstoneWire; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import ihl.flexible_cable.RectifierTransformerUnitTileEntity; + +import java.util.List; + +public class IHLBlockHighlightHandler implements IHighlightHandler +{ + @Override + public List handleTextData(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition movingObjectPosition, List currenttip, ItemInfo.Layout layout) + { + TileEntity tile = world.getTileEntity(movingObjectPosition.blockX, movingObjectPosition.blockY, movingObjectPosition.blockZ); + if(tile instanceof RectifierTransformerUnitTileEntity) + { + RectifierTransformerUnitTileEntity rtu = (RectifierTransformerUnitTileEntity)tile; + currenttip.add("Current mode: "+EnumChatFormatting.RED+getMode(rtu.mode)+"x V"); + currenttip.add("R.Click: "+EnumChatFormatting.RED+getMode(Math.min(rtu.mode*RectifierTransformerUnitTileEntity.modeMultiplier,RectifierTransformerUnitTileEntity.modeMax))+"x V"); + currenttip.add("IC2 Mode+R.Click: "+EnumChatFormatting.RED+getMode(Math.max(rtu.mode/RectifierTransformerUnitTileEntity.modeMultiplier,RectifierTransformerUnitTileEntity.modeMin))+"x V"); + } + return currenttip; + } + + private String getMode(float value) + { + if(value>=1f) + { + return Integer.toString(Math.round(value)); + } + else + { + return "1/"+Integer.toString(Math.round(1f/value)); + } + } + @Override + public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) { + return null; + } +} diff --git a/ihl/nei_integration/IHLPositionedStack.java b/ihl/nei_integration/IHLPositionedStack.java new file mode 100644 index 0000000..5c81ba9 --- /dev/null +++ b/ihl/nei_integration/IHLPositionedStack.java @@ -0,0 +1,15 @@ +package ihl.nei_integration; + +import ihl.recipes.RecipeOutputItemStack; +import codechicken.nei.PositionedStack; + +public class IHLPositionedStack extends PositionedStack { + + public final float sQuantity; + public IHLPositionedStack(RecipeOutputItemStack object, int x, int y) + { + super(object.itemStack.copy(), x, y); + sQuantity=object.quantity; + } + +} diff --git a/ihl/nei_integration/IHLRecipeHandler.java b/ihl/nei_integration/IHLRecipeHandler.java new file mode 100644 index 0000000..4c0ada6 --- /dev/null +++ b/ihl/nei_integration/IHLRecipeHandler.java @@ -0,0 +1,240 @@ +package ihl.nei_integration; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeOutput; +import ic2.core.util.StackUtil; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +public abstract class IHLRecipeHandler extends TemplateRecipeHandler +{ + protected int ticks; + + @Override + public abstract String getRecipeName(); + + public abstract String getRecipeId(); + + @Override + public abstract String getGuiTexture(); + + @Override + public abstract String getOverlayIdentifier(); + + public abstract Map getRecipeList(); + + @Override + public void drawBackground(int i) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 140, 65); + } + + @Override + public void drawExtras(int i) + { + float f = this.ticks >= 20 ? (this.ticks - 20) % 20 / 20.0F : 0.0F; + this.drawProgressBar(74, 23, 176, 14, 25, 16, f, 0); + f = this.ticks <= 20 ? this.ticks / 20.0F : 1.0F; + this.drawProgressBar(51, 25, 176, 0, 14, 14, f, 3); + } + + @Override + public void onUpdate() + { + super.onUpdate(); + ++this.ticks; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(74, 23, 25, 16), this.getRecipeId(), new Object[0])); + } + + @Override + public void loadCraftingRecipes(String outputId, Object ... results) + { + if (outputId.equals(this.getRecipeId())) + { + Iterator i$ = this.getRecipeList().entrySet().iterator(); + + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue())); + } + } + else + { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(ItemStack result) + { + Iterator i$ = this.getRecipeList().entrySet().iterator(); + + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + Iterator i$1 = ((RecipeOutput)entry.getValue()).items.iterator(); + + while (i$1.hasNext()) + { + ItemStack output = (ItemStack)i$1.next(); + + if (NEIServerUtils.areStacksSameTypeCrafting(output, result)) + { + this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue())); + break; + } + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) + { + Iterator i$ = this.getRecipeList().entrySet().iterator(); + + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + + if (((IRecipeInput)entry.getKey()).matches(ingredient)) + { + this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue())); + } + } + } + + protected int getInputPosX() + { + return 51; + } + + protected int getInputPosY() + { + return 6; + } + + protected int getOutputPosX() + { + return 111; + } + + protected int getOutputPosY() + { + return 24; + } + + protected boolean isOutputsVertical() + { + return true; + } + + public class CachedIORecipe extends CachedRecipe + { + private final List ingredients = new ArrayList(); + private final PositionedStack output; + private final List otherStacks = new ArrayList(); + + @Override + public List getIngredients() + { + return this.getCycledIngredients(IHLRecipeHandler.this.cycleticks / 20, this.ingredients); + } + + @Override + public PositionedStack getResult() + { + return this.output; + } + + @Override + public List getOtherStacks() + { + return this.otherStacks; + } + + public CachedIORecipe(ItemStack input, ItemStack output1) + { + super(); + + if (input == null) + { + throw new NullPointerException("Input must not be null (recipe " + input + " -> " + output1 + ")."); + } + else if (output1 == null) + { + throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ")."); + } + else + { + this.ingredients.add(new PositionedStack(input, IHLRecipeHandler.this.getInputPosX(), IHLRecipeHandler.this.getInputPosY())); + this.output = new PositionedStack(output1, IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY()); + } + } + + public CachedIORecipe(IRecipeInput input, RecipeOutput output1) + { + super(); + + if (input == null) + { + throw new NullPointerException("Input must not be null (recipe " + input + " -> " + output1 + ")."); + } + else if (output1 == null) + { + throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ")."); + } + else if (output1.items.isEmpty()) + { + throw new IllegalArgumentException("Output must not be empty (recipe " + input + " -> " + output1 + ")."); + } + else if (output1.items.contains((Object)null)) + { + throw new IllegalArgumentException("Output must not contain null (recipe " + input + " -> " + output1 + ")."); + } + else + { + ArrayList items = new ArrayList(); + Iterator i = input.getInputs().iterator(); + + while (i.hasNext()) + { + ItemStack item = (ItemStack)i.next(); + items.add(StackUtil.copyWithSize(item, input.getAmount())); + } + + this.ingredients.add(new PositionedStack(items, IHLRecipeHandler.this.getInputPosX(), IHLRecipeHandler.this.getInputPosY())); + this.output = new PositionedStack(output1.items.get(0), IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY()); + + for (int var7 = 1; var7 < output1.items.size(); ++var7) + { + if (IHLRecipeHandler.this.isOutputsVertical()) + { + this.otherStacks.add(new PositionedStack(output1.items.get(var7), IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY() + var7 * 18)); + } + else + { + this.otherStacks.add(new PositionedStack(output1.items.get(var7), IHLRecipeHandler.this.getOutputPosX() + var7 * 18, IHLRecipeHandler.this.getOutputPosY())); + } + } + } + } + } +} diff --git a/ihl/nei_integration/ImpregnatingMachineRecipeHandler.java b/ihl/nei_integration/ImpregnatingMachineRecipeHandler.java new file mode 100644 index 0000000..d1f172e --- /dev/null +++ b/ihl/nei_integration/ImpregnatingMachineRecipeHandler.java @@ -0,0 +1,112 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import codechicken.lib.gui.GuiDraw; +import ihl.processing.metallurgy.ImpregnatingMachineGui; +import ihl.processing.metallurgy.ImpregnatingMachineTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class ImpregnatingMachineRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return ImpregnatingMachineGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{116-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{16-11}; + } + + @Override + protected int[] getFluidInputPosX() + { + return new int[]{24-5,6-5}; + } + + @Override + protected int[] getFluidInputPosY() + { + return new int[]{16-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{116-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{41-11,59-11}; + } + + @Override + protected int[] getFluidOutputPosX() + { + return new int[]{24-5}; + } + + @Override + protected int[] getFluidOutputPosY() + { + return new int[]{52-11}; + } + + @Override + public String getRecipeName() + { + return "Bronze tub"; + } + + @Override + public String getRecipeId() + { + return "ihl.impregnatingMachine"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUITubBronze.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "impregnatingMachine"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(134-5, 0, 35, 65), this.getRecipeId(), new Object[0])); + } + + @Override + public void drawBackground(int i) + { + super.drawBackground(i); + GuiDraw.drawTexturedModalRect(5-5, 15-11, 23, 15, 18, 18); + } + + @Override + public Map getRecipeList() + { + return ImpregnatingMachineTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/InjectionMoldRecipeHandler.java b/ihl/nei_integration/InjectionMoldRecipeHandler.java new file mode 100644 index 0000000..106b41b --- /dev/null +++ b/ihl/nei_integration/InjectionMoldRecipeHandler.java @@ -0,0 +1,73 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.metallurgy.InjectionMoldTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class InjectionMoldRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return null; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{65-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{15-11,51-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{101-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{51-11}; + } + + + @Override + public String getRecipeName() + { + return "Injection mold"; + } + + @Override + public String getRecipeId() + { + return "ihl.casting"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUICastingNEI.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "casting"; + } + + @Override + public Map getRecipeList() + { + return InjectionMoldTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/IronWorkbenchRecipeHandler.java b/ihl/nei_integration/IronWorkbenchRecipeHandler.java new file mode 100644 index 0000000..1589f36 --- /dev/null +++ b/ihl/nei_integration/IronWorkbenchRecipeHandler.java @@ -0,0 +1,297 @@ +package ihl.nei_integration; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ic2.api.recipe.IRecipeInput; +import ic2.core.Ic2Items; +import ihl.IHLMod; +import ihl.recipes.IronWorkbenchRecipe; +import ihl.utils.IHLUtils; + +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import ihl.flexible_cable.IronWorkbenchGui; +import ihl.flexible_cable.IronWorkbenchTileEntity; +import ihl.interfaces.IWire; + +public class IronWorkbenchRecipeHandler extends TemplateRecipeHandler +{ + private static final int workspaceItemsPosX=8-7; + private static final int workspaceItemsPosY=8-7; + private static final int toolsPosX=26-7; + private static final int toolsPosY=8-7; + private static final int materialsPosX=65-7; + private static final int materialsPosY=8-7; + private static final int outputPosX=116-7; + private static final int outputPosY=8-7; + + @Override + public Class getGuiClass() + { + return IronWorkbenchGui.class; + } + + @Override + public String getRecipeName() + { + return "Iron workbench"; + } + + @Override + public int recipiesPerPage() + { + return 1; + } + + public String getRecipeId() + { + return "ihl.ironWorkbench"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIIronWorkbench.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "ironWorkbench"; + } + + public List getRecipeList() + { + return IronWorkbenchTileEntity.recipes; + } + + + @Override + public void drawBackground(int recipeNumber) + { + IronWorkbenchRecipeHandler.CachedIORecipe recipe = (CachedIORecipe) this.arecipes.get(recipeNumber); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 7, 7, 162, 108); + } + + @Override + public void drawExtras(int i) + { + /* + float f = this.ticks >= 20 ? (float)((this.ticks - 20) % 20) / 20.0F : 0.0F; + this.drawProgressBar(74, 23, 176, 14, 25, 16, f, 0); + f = this.ticks <= 20 ? (float)this.ticks / 20.0F : 1.0F; + this.drawProgressBar(51, 25, 176, 0, 14, 14, f, 3); + */ + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(104-10, 9-10, 15, 108), this.getRecipeId(), new Object[0])); + } + + @Override + public void loadCraftingRecipes(String outputId, Object ... results) + { + if (outputId.equals(this.getRecipeId())) + { + Iterator i$ = this.getRecipeList().iterator(); + + while (i$.hasNext()) + { + IronWorkbenchRecipe entry = i$.next(); + this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry)); + } + } + else + { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(ItemStack result) + { + Iterator i$ = this.getRecipeList().iterator(); + + while (i$.hasNext()) + { + IronWorkbenchRecipe entry = i$.next(); + Iterator i$1 = entry.outputs.iterator(); + while (i$1.hasNext()) + { + ItemStack output = (ItemStack)i$1.next(); + if (NEIServerUtils.areStacksSameTypeCrafting(output, result)) + { + this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry)); + break; + } + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) + { + Iterator i$ = this.getRecipeList().iterator(); + while (i$.hasNext()) + { + IronWorkbenchRecipe entry = i$.next(); + if(entry.workspaceElements!=null && !entry.workspaceElements.isEmpty()) + { + Iterator i$1 = entry.workspaceElements.iterator(); + while (i$1.hasNext()) + { + ItemStack output = (ItemStack)i$1.next(); + if (NEIServerUtils.areStacksSameTypeCrafting(output, ingredient) || IHLUtils.isItemsHaveSameOreDictionaryEntry(output, ingredient) || output.getItem()==ingredient.getItem()) + { + this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry)); + break; + } + } + } + + if(entry.tools!=null && !entry.tools.isEmpty()) + { + Iterator i$1 = entry.tools.iterator(); + while (i$1.hasNext()) + { + IRecipeInput output = i$1.next(); + if (output.matches(ingredient)) + { + this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry)); + break; + } + } + } + if(entry.materials!=null && !entry.materials.isEmpty()) + { + Iterator i$2 = entry.materials.iterator(); + while (i$2.hasNext()) + { + IRecipeInput output = i$2.next(); + if (output.matches(ingredient)) + { + this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry)); + break; + } + } + } + } + } + + public class CachedIORecipe extends CachedRecipe + { + private final List ingredients = new ArrayList(); + private final PositionedStack output; + private final List otherStacks = new ArrayList(); + + @Override + public List getIngredients() + { + return this.getCycledIngredients(IronWorkbenchRecipeHandler.this.cycleticks / 20, this.ingredients); + } + + @Override + public PositionedStack getResult() + { + return this.output; + } + + @Override + public List getOtherStacks() + { + return this.otherStacks; + } + + public CachedIORecipe(IronWorkbenchRecipe recipe) + { + super(); + if (recipe == null) + { + throw new NullPointerException("Recipe must not be null."); + } + else + { + this.ingredients.add(new PositionedStack(IHLUtils.getThisModItemStack("ironWorkbench"), workspaceItemsPosX, workspaceItemsPosY)); + if(recipe.workspaceElements!=null && !recipe.workspaceElements.isEmpty()) + { + Iterator i = recipe.workspaceElements.iterator(); + int index = 1; + while (i.hasNext()) + { + int x = workspaceItemsPosX; + int y = workspaceItemsPosY + index * 18; + ItemStack stack = (ItemStack)i.next(); + this.ingredients.add(new PositionedStack(stack, x, y)); + index++; + } + } + if(recipe.tools!=null && !recipe.tools.isEmpty()) + { + Iterator i = recipe.tools.iterator(); + int index = 0; + while (i.hasNext()) + { + int x = toolsPosX + (index % 2) * 18; + int y = toolsPosY + index / 2 * 18; + IRecipeInput rInput = (IRecipeInput)i.next(); + this.ingredients.add(new PositionedStack(rInput.getInputs(), x, y)); + index++; + } + } + + if(recipe.materials!=null && !recipe.materials.isEmpty()) + { + Iterator i = recipe.materials.iterator(); + int index = 0; + while (i.hasNext()) + { + int x = materialsPosX + (index % 2) * 18; + int y = materialsPosY + index / 2 * 18; + IRecipeInput rInput = (IRecipeInput)i.next(); + Iterator rInputsi = rInput.getInputs().iterator(); + List itemInputs = new ArrayList(); + while(rInputsi.hasNext()) + { + ItemStack stack = rInputsi.next().copy(); + if(!(stack.getItem() instanceof IWire)) + { + stack.stackSize=rInput.getAmount(); + } + itemInputs.add(stack); + } + this.ingredients.add(new PositionedStack(itemInputs, x, y)); + index++; + } + } + this.output=new PositionedStack(recipe.outputs.get(0), outputPosX, outputPosY); + Iterator i = recipe.outputs.iterator(); + int index = 0; + while (i.hasNext()) + { + int x = outputPosX + (index % 3) * 18; + int y = outputPosY + index / 3 * 18; + ItemStack stack = (ItemStack)i.next(); + if(index>0) + { + this.otherStacks.add(new PositionedStack(stack, x, y)); + } + index++; + } + } + } + + } +} diff --git a/ihl/nei_integration/LabElectrolyzerRecipeHandler.java b/ihl/nei_integration/LabElectrolyzerRecipeHandler.java new file mode 100644 index 0000000..c36e27d --- /dev/null +++ b/ihl/nei_integration/LabElectrolyzerRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.chemistry.LabElectrolyzerGui; +import ihl.processing.chemistry.LabElectrolyzerTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class LabElectrolyzerRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return LabElectrolyzerGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{42-5,60-5,78-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{15-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{8-5,87-5,106-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{15-11,51-11,15-11}; + } + + + @Override + public String getRecipeName() + { + return "Lab electrolyzer"; + } + + @Override + public String getRecipeId() + { + return "ihl.labElectrolyzer"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUILabElectrolyzer.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "labElectrolyzer"; + } + + @Override + public Map getRecipeList() + { + return LabElectrolyzerTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/LeadOvenRecipeHandler.java b/ihl/nei_integration/LeadOvenRecipeHandler.java new file mode 100644 index 0000000..5c43f9e --- /dev/null +++ b/ihl/nei_integration/LeadOvenRecipeHandler.java @@ -0,0 +1,100 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import codechicken.lib.gui.GuiDraw; +import ihl.processing.chemistry.LeadOvenGui; +import ihl.processing.chemistry.LeadOvenTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class LeadOvenRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return LeadOvenGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{47-5,65-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{17-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{112-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{35-11}; + } + + @Override + protected int[] getFluidOutputPosX() + { + return new int[]{112-5}; + } + + @Override + protected int[] getFluidOutputPosY() + { + return new int[]{17-11}; + } + + @Override + public String getRecipeName() + { + return "Chemically resistant oven"; + } + + @Override + public String getRecipeId() + { + return "ihl.leadOven"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUILeadOven.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "leadOven"; + } + + @Override + public void drawBackground(int i) + { + super.drawBackground(i); + GuiDraw.drawTexturedModalRect(107-5, 16-11, 199, 0, 26, 18); + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(80-10, 35-10, 22, 15), this.getRecipeId(), new Object[0])); + } + + @Override + public Map getRecipeList() + { + return LeadOvenTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/LoomRecipeHandler.java b/ihl/nei_integration/LoomRecipeHandler.java new file mode 100644 index 0000000..b7f6331 --- /dev/null +++ b/ihl/nei_integration/LoomRecipeHandler.java @@ -0,0 +1,81 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import ihl.processing.chemistry.LoomGui; +import ihl.processing.chemistry.LoomTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class LoomRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return LoomGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{8-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{44-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{127-5}; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(35-10, 0, 90, 60), this.getRecipeId(), new Object[0])); + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{44-11}; + } + + + @Override + public String getRecipeName() + { + return "Loom"; + } + + @Override + public String getRecipeId() + { + return "ihl.loom"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUILoom.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "loom"; + } + + @Override + public Map getRecipeList() + { + return LoomTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/MachineRecipeHandler.java b/ihl/nei_integration/MachineRecipeHandler.java new file mode 100644 index 0000000..aa5a30b --- /dev/null +++ b/ihl/nei_integration/MachineRecipeHandler.java @@ -0,0 +1,514 @@ +package ihl.nei_integration; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ic2.api.recipe.IRecipeInput; +import ic2.core.Ic2Items; +import ic2.core.item.ItemFluidCell; +import ihl.interfaces.IWire; +import ihl.recipes.IRecipeInputFluid; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +import org.lwjgl.opengl.GL11; + +public abstract class MachineRecipeHandler extends TemplateRecipeHandler +{ + protected int ticks; + + @Override + public abstract String getRecipeName(); + + public abstract String getRecipeId(); + + @Override + public abstract String getGuiTexture(); + + @Override + public abstract String getOverlayIdentifier(); + + public abstract Map getRecipeList(); + + @Override + public void drawBackground(int i) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 140, 65); + } + + @Override + public void drawExtras(int recipeNumber) + { + MachineRecipeHandler.CachedIORecipe recipe = (CachedIORecipe) this.arecipes.get(recipeNumber); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + if(recipe.output instanceof IHLPositionedStack) + { + IHLPositionedStack rOutput = (IHLPositionedStack) recipe.output; + drawFormattedString(rOutput); + } + Iterator iOs = recipe.otherStacks.iterator(); + while(iOs.hasNext()) + { + PositionedStack rOutPS = iOs.next(); + if(rOutPS instanceof IHLPositionedStack) + { + IHLPositionedStack rOutput = (IHLPositionedStack) rOutPS; + drawFormattedString(rOutput); + } + } + GuiDraw.changeTexture(this.getGuiTexture()); + } + + public void drawFormattedString(IHLPositionedStack rOutput) + { + if(Math.abs(rOutput.sQuantity-Math.round(rOutput.sQuantity))<0.01f) + { + if(Math.round(rOutput.sQuantity)!=1) + { + GuiDraw.fontRenderer.drawStringWithShadow(String.format("%d", Math.round(rOutput.sQuantity)), rOutput.relx+11, rOutput.rely+9, 16777215); + } + } + else + { + GuiDraw.fontRenderer.drawStringWithShadow(String.format("%.1f", rOutput.sQuantity), rOutput.relx+3, rOutput.rely+9, 16777215); + } + } + + @Override + public void onUpdate() + { + super.onUpdate(); + ++this.ticks; + } + + @Override + public void loadTransferRects() + { + //this.transferRects.add(new RecipeTransferRect(new Rectangle(74, 23, 25, 16), this.getRecipeId(), new Object[0])); + } + + @Override + public void loadCraftingRecipes(String outputId, Object ... results) + { + if (outputId.equals(this.getRecipeId())) + { + Iterator i$ = this.getRecipeList().entrySet().iterator(); + + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + this.arecipes.add(new MachineRecipeHandler.CachedIORecipe((UniversalRecipeInput)entry.getKey(), (UniversalRecipeOutput)entry.getValue(),getAdditionalIngredients())); + } + } + else + { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(ItemStack result) + { + Iterator i$ = this.getRecipeList().entrySet().iterator(); + FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(result); + if(fluidStack==null && result.getItem() instanceof IFluidContainerItem) + { + IFluidContainerItem ifc = (IFluidContainerItem)result.getItem(); + fluidStack = ifc.getFluid(result); + } + else if(result.getItem() instanceof ItemBlock) + { + Block blockfluid = ((ItemBlock)result.getItem()).field_150939_a; + if(blockfluid instanceof BlockFluidBase) + { + Fluid fluid = ((BlockFluidBase)blockfluid).getFluid(); + if(fluid!=null) + { + fluidStack = new FluidStack(fluid,1000); + } + } + } + if(fluidStack!=null) + { + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + Iterator i$1 = ((UniversalRecipeOutput)entry.getValue()).getFluidOutputs().iterator(); + while (i$1.hasNext()) + { + FluidStack output = (FluidStack)i$1.next(); + if (output!=null && output.getFluid()==fluidStack.getFluid()) + { + this.arecipes.add(new MachineRecipeHandler.CachedIORecipe((UniversalRecipeInput)entry.getKey(), (UniversalRecipeOutput)entry.getValue(),getAdditionalIngredients())); + break; + } + } + } + } + else + { + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + Iterator i$1 = ((UniversalRecipeOutput)entry.getValue()).getItemOutputs().iterator(); + + while (i$1.hasNext()) + { + RecipeOutputItemStack output = i$1.next(); + + if (NEIServerUtils.areStacksSameTypeCrafting(output.itemStack, result) || IHLUtils.isItemsHaveSameOreDictionaryEntry(output.itemStack, result)) + { + this.arecipes.add(new MachineRecipeHandler.CachedIORecipe((UniversalRecipeInput)entry.getKey(), (UniversalRecipeOutput)entry.getValue(),getAdditionalIngredients())); + break; + } + } + } + } + } + + + public List getAdditionalIngredients() + { + return null; + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) + { + Iterator i$ = this.getRecipeList().entrySet().iterator(); + FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(ingredient); + if(fluidStack==null && ingredient.getItem() instanceof IFluidContainerItem) + { + IFluidContainerItem ifc = (IFluidContainerItem)ingredient.getItem(); + fluidStack = ifc.getFluid(ingredient); + } + else if(ingredient.getItem() instanceof ItemBlock) + { + Block blockfluid = ((ItemBlock)ingredient.getItem()).field_150939_a; + if(blockfluid instanceof BlockFluidBase) + { + Fluid fluid = ((BlockFluidBase)blockfluid).getFluid(); + if(fluid!=null) + { + fluidStack = new FluidStack(fluid,1000); + } + } + } + + if(fluidStack!=null && fluidStack.getFluid()!=null) + { + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + if (((UniversalRecipeInput)entry.getKey()).containFluidStack(fluidStack)) + { + this.arecipes.add(new MachineRecipeHandler.CachedIORecipe((UniversalRecipeInput)entry.getKey(), (UniversalRecipeOutput)entry.getValue(),getAdditionalIngredients())); + } + } + } + else + { + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + if (((UniversalRecipeInput)entry.getKey()).containItemStack(ingredient)) + { + this.arecipes.add(new MachineRecipeHandler.CachedIORecipe((UniversalRecipeInput)entry.getKey(), (UniversalRecipeOutput)entry.getValue(),getAdditionalIngredients())); + } + } + } + } + + protected int[] getFluidInputPosX() + { + return null; + } + + protected int[] getFluidInputPosY() + { + return null; + } + + protected int[] getFluidOutputPosX() + { + return null; + } + + protected int[] getFluidOutputPosY() + { + return null; + } + + protected abstract int[] getInputPosX(); + protected abstract int[] getInputPosY(); + protected abstract int[] getOutputPosX(); + protected abstract int[] getOutputPosY(); + + public class CachedIORecipe extends CachedRecipe + { + private final List ingredients = new ArrayList(); + public PositionedStack output; + public final List otherStacks = new ArrayList(); + public boolean specialConditions=false; + + @Override + public List getIngredients() + { + return this.getCycledIngredients(MachineRecipeHandler.this.cycleticks / 20, this.ingredients); + } + + @Override + public PositionedStack getResult() + { + return this.output; + } + + @Override + public List getOtherStacks() + { + return this.otherStacks; + } + + public CachedIORecipe(UniversalRecipeInput input, UniversalRecipeOutput output1, List additionalIngredients) + { + super(); + if (input == null) + { + throw new NullPointerException("Input must not be null (recipe " + input + " -> " + output1 + ")."); + } + else if (output1 == null) + { + throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ")."); + } + else if ((output1.getFluidOutputs() == null || output1.getFluidOutputs().isEmpty()) && (output1.getItemOutputs() == null || output1.getItemOutputs().isEmpty())) + { + throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ")."); + } + else + { + specialConditions=output1.specialConditions; + ArrayList> items = new ArrayList(); + ArrayList> fluidItems = new ArrayList(); + if(input.getFluidInputs()!=null && !input.getFluidInputs().isEmpty()) + { + Iterator i = input.getFluidInputs().iterator(); + while (i.hasNext()) + { + IRecipeInputFluid fstackRI = (IRecipeInputFluid)i.next(); + List fstackList = fstackRI.getInputs(); + List fContainers = new ArrayList(); + for(FluidStack fstack:fstackList) + { + ItemStack stack = Ic2Items.FluidCell.copy(); + ((ItemFluidCell)Ic2Items.FluidCell.copy().getItem()).fill(stack, fstack, true); + if(fstack.amount>1000) + { + stack.stackSize=fstack.amount/1000; + } + fContainers.add(stack); + } + fluidItems.add(fContainers); + } + } + + if(input.getItemInputs()!=null && !input.getItemInputs().isEmpty()) + { + Iterator i = input.getItemInputs().iterator(); + while (i.hasNext()) + { + IRecipeInput rInput = (IRecipeInput)i.next(); + Iterator rInputsi = rInput.getInputs().iterator(); + List itemInputs = new ArrayList(); + while(rInputsi.hasNext()) + { + ItemStack stack = rInputsi.next().copy(); + if(!(stack.getItem() instanceof IWire)) + { + stack.stackSize=rInput.getAmount(); + } + itemInputs.add(stack); + } + items.add(itemInputs); + } + } + + int var7=0; + int var8=0; + boolean skipOneFluidOutput=false; + if(output1.getItemOutputs()!=null && !output1.getItemOutputs().isEmpty()) + { + int x = MachineRecipeHandler.this.getOutputPosX()[0],y = MachineRecipeHandler.this.getOutputPosY()[0]; + if(output1.getItemOutputs().get(0)!=null)this.output = new IHLPositionedStack(output1.getItemOutputs().get(0), x, y); + Iterator i = output1.getItemOutputs().iterator(); + i.next(); + while (i.hasNext()) + { + RecipeOutputItemStack rOut = i.next(); + var7++; + if(var71000) + { + fluidCellStack.stackSize=output1.getFluidOutputs().get(0).amount/1000; + } + if(MachineRecipeHandler.this.getFluidOutputPosX()!=null) + { + this.output = new PositionedStack(fluidCellStack, MachineRecipeHandler.this.getFluidOutputPosX()[0], MachineRecipeHandler.this.getFluidOutputPosY()[0]); + } + else + { + this.output = new PositionedStack(fluidCellStack, MachineRecipeHandler.this.getOutputPosX()[0], MachineRecipeHandler.this.getOutputPosY()[0]); + } + skipOneFluidOutput=true; + var8++; + } + + if(output1.getFluidOutputs()!=null && !output1.getFluidOutputs().isEmpty()) + { + int x = MachineRecipeHandler.this.getOutputPosX()[0],y = MachineRecipeHandler.this.getOutputPosY()[0]; + if(MachineRecipeHandler.this.getFluidOutputPosX()!=null) + { + x = MachineRecipeHandler.this.getFluidOutputPosX()[0]; + y = MachineRecipeHandler.this.getFluidOutputPosY()[0]; + } + Iterator i = output1.getFluidOutputs().iterator(); + if(skipOneFluidOutput) + { + i.next(); + } + while (i.hasNext()) + { + FluidStack fstack = (FluidStack)i.next(); + ItemStack stack1 = Ic2Items.FluidCell.copy(); + ((ItemFluidCell)stack1.getItem()).fill(stack1, fstack, true); + if(fstack.amount>1000) + { + stack1.stackSize=fstack.amount/1000; + } + var7++; + if(MachineRecipeHandler.this.getFluidOutputPosX()!=null) + { + if(var8 getGuiClass() + { + return MuffleFurnaceGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{51-5,69-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{34-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{105-5,123-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{34-11}; + } + + @Override + public String getRecipeName() + { + return "Muffle furnace"; + } + + @Override + public String getRecipeId() + { + return "ihl.muffleFurnace"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIMuffleFurnace.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "muffleFurnace"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(40-5, 55-11, 55, 15), this.getRecipeId(), new Object[0])); + } + + + @Override + public void drawBackground(int i) + { + super.drawBackground(i); + GuiDraw.drawTexturedModalRect(86-5, 33-11, 176, 14, 54, 18); + } + + @Override + public Map getRecipeList() + { + return MuffleFurnanceTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/NEIIHLConfig.java b/ihl/nei_integration/NEIIHLConfig.java new file mode 100644 index 0000000..7ffc3fb --- /dev/null +++ b/ihl/nei_integration/NEIIHLConfig.java @@ -0,0 +1,121 @@ +package ihl.nei_integration; + +import ihl.IHLModInfo; +import ihl.processing.chemistry.ChemicalReactorGui; +import ihl.processing.chemistry.CryogenicDistillerGui; +import ihl.processing.chemistry.ElectricEvaporatorGui; +import ihl.processing.chemistry.EvaporatorGui; +import ihl.processing.chemistry.FluidizedBedReactorGui; +import ihl.processing.chemistry.LabElectrolyzerGui; +import ihl.processing.chemistry.LeadOvenGui; +import ihl.processing.chemistry.LoomGui; +import ihl.processing.chemistry.PaperMachineGui; +import ihl.processing.metallurgy.AchesonFurnaceGui; +import ihl.processing.metallurgy.DetonationSprayingMachineGui; +import ihl.processing.metallurgy.ExtruderGui; +import ihl.processing.metallurgy.GasWeldingStationGui; +import ihl.processing.metallurgy.ImpregnatingMachineGui; +import ihl.processing.metallurgy.MuffleFurnaceGui; +import ihl.processing.metallurgy.RollingMachineGui; +import ihl.processing.metallurgy.WireMillGui; +import ihl.processing.metallurgy.WoodenRollingMachineGui; +import ihl.utils.IHLUtils; +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import codechicken.nei.api.ItemInfo; + +public class NEIIHLConfig implements IConfigureNEI +{ + @Override + public void loadConfig() + { + API.registerHighlightHandler(new IHLBlockHighlightHandler(), ItemInfo.Layout.HEADER); + API.registerRecipeHandler(new EvaporatorRecipeHandler()); + API.registerUsageHandler(new EvaporatorRecipeHandler()); + API.registerGuiOverlay(EvaporatorGui.class, "evaporator", 5, 11); + API.registerRecipeHandler(new ElectricEvaporatorRecipeHandler()); + API.registerUsageHandler(new ElectricEvaporatorRecipeHandler()); + API.registerGuiOverlay(ElectricEvaporatorGui.class, "electricevaporator", 5, 11); + API.registerRecipeHandler(new AchesonFurnaceRecipeHandler()); + API.registerUsageHandler(new AchesonFurnaceRecipeHandler()); + API.registerGuiOverlay(AchesonFurnaceGui.class, "achesonFurnace", 5, 11); + API.registerRecipeHandler(new MuffleFurnaceRecipeHandler()); + API.registerUsageHandler(new MuffleFurnaceRecipeHandler()); + API.registerGuiOverlay(MuffleFurnaceGui.class, "muffleFurnace", 5, 11); + API.registerRecipeHandler(new DetonationSprayingMachineRecipeHandler()); + API.registerUsageHandler(new DetonationSprayingMachineRecipeHandler()); + API.registerGuiOverlay(DetonationSprayingMachineGui.class, "detonationSprayingMachine", 5, 11); + API.registerRecipeHandler(new ExtruderRecipeHandler()); + API.registerUsageHandler(new ExtruderRecipeHandler()); + API.registerGuiOverlay(ExtruderGui.class, "extruder", 5, 11); + API.registerRecipeHandler(new ImpregnatingMachineRecipeHandler()); + API.registerUsageHandler(new ImpregnatingMachineRecipeHandler()); + API.registerGuiOverlay(ImpregnatingMachineGui.class, "impregnatingMachine", 5, 11); + API.registerRecipeHandler(new LeadOvenRecipeHandler()); + API.registerUsageHandler(new LeadOvenRecipeHandler()); + API.registerGuiOverlay(LeadOvenGui.class, "leadOven", 5, 11); + API.registerRecipeHandler(new LoomRecipeHandler()); + API.registerUsageHandler(new LoomRecipeHandler()); + API.registerGuiOverlay(LoomGui.class, "loom", 5, 11); + API.registerGuiOverlay(GasWeldingStationGui.class, "gasWeldingStation", 5, 11); + API.registerRecipeHandler(new GasWeldingStationGasRecipeHandler()); + API.registerUsageHandler(new GasWeldingStationGasRecipeHandler()); + API.registerGuiOverlay(GasWeldingStationGui.class, "gasWeldingStationGas", 5, 11); + API.registerRecipeHandler(new WoodenRollingMachineRecipeHandler()); + API.registerUsageHandler(new WoodenRollingMachineRecipeHandler()); + API.registerGuiOverlay(WoodenRollingMachineGui.class, "woodenRollingMachine", 5, 11); + API.registerRecipeHandler(new CryogenicDistillerRecipeHandler()); + API.registerUsageHandler(new CryogenicDistillerRecipeHandler()); + API.registerGuiOverlay(CryogenicDistillerGui.class, "cryogenicDistiller", 5, 11); + API.registerRecipeHandler(new ChemicalReactorRecipeHandler()); + API.registerUsageHandler(new ChemicalReactorRecipeHandler()); + API.registerGuiOverlay(ChemicalReactorGui.class, "chemicalReactor", 5, 11); + API.registerRecipeHandler(new FluidizedBedReactorRecipeHandler()); + API.registerUsageHandler(new FluidizedBedReactorRecipeHandler()); + API.registerGuiOverlay(FluidizedBedReactorGui.class, "fluidizedBedReactor", 5, 11); + API.registerRecipeHandler(new LabElectrolyzerRecipeHandler()); + API.registerUsageHandler(new LabElectrolyzerRecipeHandler()); + API.registerGuiOverlay(LabElectrolyzerGui.class, "labElectrolyzer", 5, 11); + API.registerRecipeHandler(new RollingMachineRecipeHandler()); + API.registerUsageHandler(new RollingMachineRecipeHandler()); + API.registerGuiOverlay(RollingMachineGui.class, "rollingMachine", 5, 11); + API.registerRecipeHandler(new PaperMachineRecipeHandler()); + API.registerUsageHandler(new PaperMachineRecipeHandler()); + API.registerGuiOverlay(PaperMachineGui.class, "paperMachine", 5, 11); + API.registerRecipeHandler(new ElectrolysisBathRecipeHandler()); + API.registerUsageHandler(new ElectrolysisBathRecipeHandler()); + API.registerGuiOverlay(PaperMachineGui.class, "paperMachine", 5, 11); + API.registerRecipeHandler(new WireMillRecipeHandler()); + API.registerUsageHandler(new WireMillRecipeHandler()); + API.registerGuiOverlay(WireMillGui.class, "wireMill", 5, 11); + API.registerRecipeHandler(new InjectionMoldRecipeHandler()); + API.registerUsageHandler(new InjectionMoldRecipeHandler()); + API.registerRecipeHandler(new VulcanizationExtrudingMoldRecipeHandler()); + API.registerUsageHandler(new VulcanizationExtrudingMoldRecipeHandler()); + API.registerRecipeHandler(new CrucibleRecipeHandler()); + API.registerUsageHandler(new CrucibleRecipeHandler()); + API.registerRecipeHandler(new FractionationColumnRecipeHandler()); + API.registerUsageHandler(new FractionationColumnRecipeHandler()); + API.registerRecipeHandler(new ChimneyKneeRecipeHandler()); + API.registerUsageHandler(new ChimneyKneeRecipeHandler()); + API.registerRecipeHandler(new PrecipitatorCondenserRecipeHandler()); + API.registerUsageHandler(new PrecipitatorCondenserRecipeHandler()); + API.registerRecipeHandler(new IronWorkbenchRecipeHandler()); + API.registerUsageHandler(new IronWorkbenchRecipeHandler()); + this.addSubsets(); + } + + public void addSubsets() {} + + @Override + public String getName() + { + return "IHL"; + } + + @Override + public String getVersion() + { + return IHLModInfo.MODVERSION; + } +} diff --git a/ihl/nei_integration/PaperMachineRecipeHandler.java b/ihl/nei_integration/PaperMachineRecipeHandler.java new file mode 100644 index 0000000..5a6e0e2 --- /dev/null +++ b/ihl/nei_integration/PaperMachineRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.chemistry.PaperMachineGui; +import ihl.processing.chemistry.PaperMachineTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class PaperMachineRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return PaperMachineGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{78-5,78-5-18,122-5-18,122-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{15-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{122-5,122-5-18,78-5-18}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{51-11,51-11,51-11}; + } + + + @Override + public String getRecipeName() + { + return "Paper machine"; + } + + @Override + public String getRecipeId() + { + return "ihl.paperMachine"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIPaperMachine.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "paperMachine"; + } + + @Override + public Map getRecipeList() + { + return PaperMachineTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/PrecipitatorCondenserRecipeHandler.java b/ihl/nei_integration/PrecipitatorCondenserRecipeHandler.java new file mode 100644 index 0000000..530ebaf --- /dev/null +++ b/ihl/nei_integration/PrecipitatorCondenserRecipeHandler.java @@ -0,0 +1,73 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.chemistry.PrecipitatorCondenserTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class PrecipitatorCondenserRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return null; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{6-5,6-5,106-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{33-11,53-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{75-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{53-11,31-11}; + } + + + @Override + public String getRecipeName() + { + return "Precipitator/Condenser"; + } + + @Override + public String getRecipeId() + { + return "ihl.precipitatorCondenser"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUICondenserNEI.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "condenser"; + } + + @Override + public Map getRecipeList() + { + return PrecipitatorCondenserTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/RollingMachineRecipeHandler.java b/ihl/nei_integration/RollingMachineRecipeHandler.java new file mode 100644 index 0000000..d550ee7 --- /dev/null +++ b/ihl/nei_integration/RollingMachineRecipeHandler.java @@ -0,0 +1,73 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.metallurgy.RollingMachineGui; +import ihl.processing.metallurgy.RollingMachinePart1TileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class RollingMachineRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return RollingMachineGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{54-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{25-11,34-11,53-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{105-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{25-11}; + } + + @Override + public String getRecipeName() + { + return "Rolling machine"; + } + + @Override + public String getRecipeId() + { + return "ihl.rollingMachine"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIRollingMachine.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "rollingMachine"; + } + + @Override + public Map getRecipeList() + { + return RollingMachinePart1TileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/VulcanizationExtrudingMoldRecipeHandler.java b/ihl/nei_integration/VulcanizationExtrudingMoldRecipeHandler.java new file mode 100644 index 0000000..0da133e --- /dev/null +++ b/ihl/nei_integration/VulcanizationExtrudingMoldRecipeHandler.java @@ -0,0 +1,73 @@ +package ihl.nei_integration; + +import java.util.Map; + +import ihl.processing.metallurgy.VulcanizationExtrudingMoldTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class VulcanizationExtrudingMoldRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return null; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{41-5,16-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{17-11,46-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{123-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{46-11}; + } + + + @Override + public String getRecipeName() + { + return "Vulcanization extruding mold"; + } + + @Override + public String getRecipeId() + { + return "ihl.culcanizationExtrudingMold"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIVulcanizationExtrudingMoldNEI.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "vulcanizationExtrudingMold"; + } + + @Override + public Map getRecipeList() + { + return VulcanizationExtrudingMoldTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/WireMillRecipeHandler.java b/ihl/nei_integration/WireMillRecipeHandler.java new file mode 100644 index 0000000..7a0cafe --- /dev/null +++ b/ihl/nei_integration/WireMillRecipeHandler.java @@ -0,0 +1,109 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; + +import ihl.processing.metallurgy.WireMillGui; +import ihl.processing.metallurgy.WireMillTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class WireMillRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return WireMillGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{117-5,44-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{31-11,14-11}; + } + + @Override + protected int[] getFluidInputPosX() + { + return new int[]{8-5,26-5,44-5}; + } + + @Override + protected int[] getFluidInputPosY() + { + return new int[]{14-11}; + } + + + @Override + protected int[] getOutputPosX() + { + return new int[]{152-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{31-11}; + } + + + @Override + public String getRecipeName() + { + return "Wire mill"; + } + + @Override + public String getRecipeId() + { + return "ihl.wireMill"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIWireMill.png"; + } + + @Override + public String getOverlayIdentifier() + { + return "wireMill"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(134-5, 33-11, 18, 13), this.getRecipeId(), new Object[0])); + } + + @Override + public void drawBackground(int i) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 151, 65); + GuiDraw.drawTexturedModalRect(133-5+18, 30-11, 98+18, 30, 18, 18); + GuiDraw.drawTexturedModalRect(7-5+18, 13-11, 25+18, 13, 18, 18); + GuiDraw.drawTexturedModalRect(7-5, 13-11, 25+18, 13, 18, 18); + } + + @Override + public Map getRecipeList() + { + return WireMillTileEntity.getRecipes(); + } +} diff --git a/ihl/nei_integration/WoodenRollingMachineRecipeHandler.java b/ihl/nei_integration/WoodenRollingMachineRecipeHandler.java new file mode 100644 index 0000000..ea44298 --- /dev/null +++ b/ihl/nei_integration/WoodenRollingMachineRecipeHandler.java @@ -0,0 +1,80 @@ +package ihl.nei_integration; + +import java.awt.Rectangle; +import java.util.Map; + +import ihl.processing.metallurgy.WoodenRollingMachineGui; +import ihl.processing.metallurgy.WoodenRollingMachinePart1TileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import net.minecraft.client.gui.inventory.GuiContainer; + + +public class WoodenRollingMachineRecipeHandler extends MachineRecipeHandler +{ + @Override + public Class getGuiClass() + { + return WoodenRollingMachineGui.class; + } + + @Override + protected int[] getInputPosX() + { + return new int[]{123-5}; + } + + @Override + protected int[] getInputPosY() + { + return new int[]{15-11,34-11,53-11}; + } + + @Override + protected int[] getOutputPosX() + { + return new int[]{54-5}; + } + + @Override + protected int[] getOutputPosY() + { + return new int[]{25-11}; + } + + @Override + public String getRecipeName() + { + return "Wooden rolling machine"; + } + + @Override + public String getRecipeId() + { + return "ihl.woodenRollingMachine"; + } + + @Override + public String getGuiTexture() + { + return "ihl:textures/gui/GUIWoodenRollingMachine.png"; + } + + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(74-5,16-11, 46, 48), this.getRecipeId(), new Object[0])); + } + + @Override + public String getOverlayIdentifier() + { + return "woodenRollingMachine"; + } + + @Override + public Map getRecipeList() + { + return WoodenRollingMachinePart1TileEntity.getRecipes(); + } +} diff --git a/ihl/processing/chemistry/AbsorberCoolerModel.java b/ihl/processing/chemistry/AbsorberCoolerModel.java new file mode 100644 index 0000000..7dac4c9 --- /dev/null +++ b/ihl/processing/chemistry/AbsorberCoolerModel.java @@ -0,0 +1,78 @@ +package ihl.processing.chemistry; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +public class AbsorberCoolerModel extends ModelBase +{ + //fields + ModelRenderer Base; + + public AbsorberCoolerModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 26, 0); + setTextureOffset("Base.Shape2", 0, 17); + setTextureOffset("Base.Shape4", 30, 16); + setTextureOffset("Base.Shape3", 0, 15); + setTextureOffset("Base.Shape5", 2, 12); + setTextureOffset("Base.Shape6", 0, 2); + setTextureOffset("Base.Shape7", 24, 4); + setTextureOffset("Base.Shape8", 50, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape12", 0, 0); + setTextureOffset("Base.Shape13", 0, 0); + setTextureOffset("Base.Shape14", 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, 24); + setTextureOffset("Base.Shape24", 7, 12); + setTextureOffset("Base.Shape25", 21, 8); + setTextureOffset("Base.Shape26", 12, 24); + setTextureOffset("Base.Shape27", 0, 0); + setTextureOffset("Base.Shape28", 0, 18); + setTextureOffset("Base.Shape29", 21, 0); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 23F, 0F); + Base.mirror = true; + Base.addBox("Shape1", 6F, -14F, -7F, 1, 14, 14); + Base.addBox("Shape2", -7F, -1F, -8F, 14, 1, 1); + Base.addBox("Shape4", 6F, -14F, -8F, 1, 13, 1); + Base.addBox("Shape3", -7F, -1F, 7F, 14, 1, 1); + Base.addBox("Shape5", -7F, -15F, -8F, 6, 1, 16); + Base.addBox("Shape6", -7F, -14F, 7F, 1, 13, 1); + Base.addBox("Shape7", -7F, -14F, -7F, 1, 14, 14); + Base.addBox("Shape8", -7F, -14F, -8F, 1, 13, 1); + Base.addBox("Shape9", 1F, 0F, -8F, 7, 1, 16); + Base.addBox("Shape10", 6F, -14F, 7F, 1, 13, 1); + Base.addBox("Shape11", 3.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape12", 1.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape13", -2.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape14", -4.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape15", -0.5F, -13F, -7F, 1, 1, 14); + Base.addBox("Shape16", -6F, -12.5F, -1.5F, 12, 1, 1); + Base.addBox("Shape17", -6F, -12.5F, -3.5F, 12, 1, 1); + Base.addBox("Shape18", -6F, -12.5F, -5.5F, 12, 1, 1); + Base.addBox("Shape19", -6F, -12.5F, 0.5F, 12, 1, 1); + Base.addBox("Shape20", -6F, -12.5F, 2.5F, 12, 1, 1); + Base.addBox("Shape21", -6F, -12.5F, 4.5F, 12, 1, 1); + Base.addBox("Shape22", -6F, 9F, 7F, 12, 2, 1); + Base.addBox("Shape23", -6F, -14F, -8F, 12, 2, 1); + Base.addBox("Shape24", 1F, -15F, -8F, 6, 1, 16); + Base.addBox("Shape25", -1F, -15F, 1F, 2, 1, 7); + Base.addBox("Shape26", -1F, -15F, -8F, 2, 1, 7); + Base.addBox("Shape27", -8F, 0F, -8F, 7, 1, 16); + Base.addBox("Shape28", -1F, 0F, 1F, 2, 1, 7); + Base.addBox("Shape29", -1F, 0F, -8F, 2, 1, 7); + } +} diff --git a/ihl/processing/chemistry/ApparatusProcessableInvSlot.java b/ihl/processing/chemistry/ApparatusProcessableInvSlot.java new file mode 100644 index 0000000..f0b69b3 --- /dev/null +++ b/ihl/processing/chemistry/ApparatusProcessableInvSlot.java @@ -0,0 +1,67 @@ +package ihl.processing.chemistry; + +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class ApparatusProcessableInvSlot extends InvSlot { + + public ApparatusProcessableInvSlot(TileEntityInventory base1, String name1, + int oldStartIndex1, Access access1, int count, int stackSizeLimit1) { + super(base1, name1, oldStartIndex1, access1, count); + this.setStackSizeLimit(stackSizeLimit1); + } + + public List getItemStackList() + { + List list = new ArrayList(); + for(int i=0; i iconMap = new HashMap(); + private static Map nameMap = new HashMap(); + private static Map descriptionMap = new HashMap(); + + public BatteryItem() + { + super(); + this.setMaxDamage(27); + this.setCreativeTab(IHLCreativeTab.tab); + this.maxStackSize=1; + this.canRepair=false; + this.setUnlocalizedName("battery"); + } + + public static void init() + { + BatteryItem item = new BatteryItem(); + GameRegistry.registerItem(item,item.getUnlocalizedName()); + Type[] var1 = Type.values(); + for(int i=0;i getHudInfo(ItemStack itemStack) + { + LinkedList info = new LinkedList(); + info.add(ElectricItem.manager.getToolTip(itemStack)); + return info; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) + { + Type[] var1 = Type.values(); + for(int i=0;i fluidTankFluidList; + + public ChemicalReactorContainer(EntityPlayer entityPlayer, ChemicalReactorTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList=tileEntity.getFluidTank().getFluidList(); + 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.fillInputSlot, 0, 60, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 60, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 60, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 122-18, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 122, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 122-18, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 122, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 8, 33)); + } + + @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.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + + + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @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.temperature=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/ChemicalReactorGui.java b/ihl/processing/chemistry/ChemicalReactorGui.java new file mode 100644 index 0000000..6342d40 --- /dev/null +++ b/ihl/processing/chemistry/ChemicalReactorGui.java @@ -0,0 +1,84 @@ +package ihl.processing.chemistry; + +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 ChemicalReactorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIChemicalReactor.png"); + private ChemicalReactorContainer container; + private int mixerFrame=0; + + public ChemicalReactorGui (ChemicalReactorContainer 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); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(12, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(30, 29, getFrameX(i1), getFrameY(i1),24,24); + if(mixerFrame++>4) + { + mixerFrame=0; + } + } + else + { + mixerFrame=0; + } + this.drawTexturedModalRect(103-18, 52, 246, 226+6*mixerFrame,10,6); + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 102-18, 28, 114-18, 59, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(background); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 34, xOffset, yOffset); + } + } + + @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); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ChemicalReactorTileEntity.java b/ihl/processing/chemistry/ChemicalReactorTileEntity.java new file mode 100644 index 0000000..7720d2b --- /dev/null +++ b/ihl/processing/chemistry/ChemicalReactorTileEntity.java @@ -0,0 +1,363 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class ChemicalReactorTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("chemicalreactor"); + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public short temperature=20; + + public ChemicalReactorTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 2, 64); + this.isGuiScreenOpened=true; + } + + @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 boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("chemicalReactor"); + } + + @Override + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + switch(from) + { + case UP: + return this.fluidTank.drainLightest(amount, doDrain); + case NORTH: + return this.fluidTank.drainLightest(amount, doDrain); + case SOUTH: + return this.fluidTank.drainLightest(amount, doDrain); + case WEST: + return this.fluidTank.drainLightest(amount, doDrain); + case EAST: + return this.fluidTank.drainLightest(amount, doDrain); + case DOWN: + return this.fluidTank.drain(amount, doDrain); + default: + return this.fluidTank.drain(amount, doDrain); + } + } + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite()); + } + + @Override + public String getInventoryName() { + return "chemicalReactor"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + public float getRenderLiquidLevel() + { + return (float)this.fluidTank.getFluidAmount()/(float)this.fluidTank.getCapacity(); + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + // TODO Auto-generated method stub + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new ChemicalReactorGui(new ChemicalReactorContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new ChemicalReactorContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = getOutput(); + if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs())) + { + if(output.specialConditions) + { + return this.checkSpecialConditions(); + } + else + { + return true; + } + } + return false; + } + + private boolean checkSpecialConditions() + { + ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ); + if(te instanceof CryogenicDistillerTileEntity) + { + CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te; + return cgte.getFacing()==this.getFacing() && cgte.canProcess(); + } + return false; + } + + public UniversalRecipeOutput getOutput() + { + return ChemicalReactorTileEntity.recipeManager.getOutputFor(this.getInput()[0],this.getInput()[1], false, false); + } + + @Override + public List[] getInput() + { + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1, fluidStackInput2}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new ItemStack[] {itemStackOutput1, itemStackOutput2}),200)); + } + + public static void addSpecialConditionsRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1, fluidStackInput2}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new ItemStack[] {itemStackOutput1, itemStackOutput2}),200, true)); + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/CryogenicDistillerContainer.java b/ihl/processing/chemistry/CryogenicDistillerContainer.java new file mode 100644 index 0000000..d3ed523 --- /dev/null +++ b/ihl/processing/chemistry/CryogenicDistillerContainer.java @@ -0,0 +1,90 @@ +package ihl.processing.chemistry; + +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; +import net.minecraftforge.fluids.FluidStack; + +public class CryogenicDistillerContainer extends ContainerBase { + + public CryogenicDistillerTileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private int lastNumberOfFluids = -1; + private int lastFluidAmount = -1; + private final static int height=166; + public List fluidTankFluidList; + + public CryogenicDistillerContainer(EntityPlayer entityPlayer, + CryogenicDistillerTileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + fluidTankFluidList=tileEntity.fluidTankProducts.getFluidList(); + 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(lathePart1TileEntity.engine,0, 8, 32)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fillInputSlotInput,0, 58, 51)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fillInputSlotProducts,0, 103, 51)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fluidItemsSlot,0, 58, 15)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fluidItemsSlot,1, 103, 15)); + } + + @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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + if (this.tileEntity.fluidTankProducts.getFluidAmount() != this.lastFluidAmount || this.tileEntity.fluidTankProducts.getNumberOfFluids() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastNumberOfFluids = this.tileEntity.fluidTankProducts.getNumberOfFluids(); + this.lastFluidAmount = this.tileEntity.fluidTankProducts.getFluidAmount(); + this.lastEnergy = (short) 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; + } + } + +} diff --git a/ihl/processing/chemistry/CryogenicDistillerGui.java b/ihl/processing/chemistry/CryogenicDistillerGui.java new file mode 100644 index 0000000..ef18c53 --- /dev/null +++ b/ihl/processing/chemistry/CryogenicDistillerGui.java @@ -0,0 +1,62 @@ +package ihl.processing.chemistry; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class CryogenicDistillerGui extends GuiContainer { + + private CryogenicDistillerContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUICryogenicDistiller.png"); + + public CryogenicDistillerGui(CryogenicDistillerContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @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(tex); + 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(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(81, 35, 198, 0, i1 + 1, 13); + } + if (this.container.tileEntity.fluidTankProducts.getFluid()!=null && this.container.tileEntity.fluidTankProducts.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankProducts, 125, 28, 137, 67, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 34, xOffset, yOffset); + } + } + + @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(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/chemistry/CryogenicDistillerTileEntity.java b/ihl/processing/chemistry/CryogenicDistillerTileEntity.java new file mode 100644 index 0000000..4c237d3 --- /dev/null +++ b/ihl/processing/chemistry/CryogenicDistillerTileEntity.java @@ -0,0 +1,252 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +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.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import net.minecraft.block.Block; +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.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CryogenicDistillerTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler{ + + public final InvSlotConsumableLiquidIHL fillInputSlotInput; + public final InvSlotOutput fluidItemsSlot; + public final InvSlotConsumableLiquidIHL fillInputSlotProducts; + + private int processTimer=0; + private IHLFluidTank fluidTankInput = new IHLFluidTank(8000); + public IHLFluidTank fluidTankProducts = new IHLFluidTank(8000); + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("cryogenicdistiller"); + + public CryogenicDistillerTileEntity() + { + super(); + this.isGuiScreenOpened=true; + this.fillInputSlotInput = new InvSlotConsumableLiquidIHL(this, "fillInputSlotInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.fillInputSlotProducts = new InvSlotConsumableLiquidIHL(this, "fillInputSlotProducts", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.fluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 2); + } + + @Override + public String getInventoryName() { + return "CryogenicDistiller"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ); + if(this.processTimer++>20 && this.engine.correctContent() && this.energy>=this.energyConsume/this.engine.getEfficiency()) + { + this.energy-=this.energyConsume/this.engine.getEfficiency(); + this.processTimer=0; + dir = dir.getOpposite(); + Block block = worldObj.getBlock(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ); + if(block!=null && block.isAir(worldObj, xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ) && this.fluidTankInput.getFluidAmount()<1000) + { + if(this.fluidTankInput.getFluid()==null || (this.fluidTankInput.getNumberOfFluids()<=1 && this.fluidTankInput.getFluid().getFluid()==FluidRegistry.getFluid("air"))) + { + this.fluidTankInput.fill(IHLUtils.getFluidStackWithSize("air", 1000-(this.fluidTankInput.getFluid()!=null?this.fluidTankInput.getFluid().amount:0)),true); + } + } + TileEntity teOnTop = worldObj.getTileEntity(xCoord, yCoord+1, zCoord); + if(teOnTop instanceof IFluidHandler && this.fluidTankProducts.getLigthestFluid()!=null) + { + IFluidHandler topFH = (IFluidHandler)teOnTop; + if(topFH.canFill(ForgeDirection.DOWN, this.fluidTankProducts.getLigthestFluid().getFluid())) + { + FluidStack fsToDrain = this.fluidTankProducts.getLigthestFluid().copy(); + fsToDrain.amount=topFH.fill(ForgeDirection.DOWN, fsToDrain, true); + this.fluidTankProducts.drain(fsToDrain, true); + } + } + ForgeDirection orientation = ForgeDirection.getOrientation(this.getFacing()); + TileEntity teOnFront = worldObj.getTileEntity(xCoord+orientation.offsetX, yCoord, zCoord+orientation.offsetZ); + if(teOnFront instanceof IFluidHandler && this.fluidTankProducts.getFluid()!=null) + { + IFluidHandler frontFH = (IFluidHandler)teOnFront; + if(frontFH.canFill(orientation, this.fluidTankProducts.getFluid().getFluid())) + { + FluidStack fsToDrain = this.fluidTankProducts.getFluid().copy(); + fsToDrain.amount=frontFH.fill(orientation, fsToDrain, true); + this.fluidTankProducts.drain(fsToDrain, true); + } + } + } + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotProducts, null, fluidItemsSlot, fluidTankProducts); + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("cryogenicDistiller"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new CryogenicDistillerGui(new CryogenicDistillerContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new CryogenicDistillerContainer(player, this); + } + + @Override + public void operate() + { + if (!this.fillInputSlotInput.isEmpty() && this.fluidTankInput.getFluid().getFluid()==FluidRegistry.getFluid("air")) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotInput, null, fluidItemsSlot, fluidTankInput); + } + else + { + UniversalRecipeInput ri = CryogenicDistillerTileEntity.recipeManager.getRecipeInput(getInput()); + Iterator listFluidOutputsIterator = getOutput().getFluidOutputs().iterator(); + while(listFluidOutputsIterator.hasNext()) + { + this.fluidTankProducts.fill(listFluidOutputsIterator.next(), true); + } + this.fluidTankInput.drain(ri.getFluidInputs().get(0), true); + } + } + + public UniversalRecipeOutput getOutput() + { + return CryogenicDistillerTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List[] getInput() + { + return new List [] {Arrays.asList(new FluidStack [] {this.fluidTankInput.getLigthestFluid()}),null}; + } + + @Override + public boolean canOperate() + { + return this.engine.correctContent() && this.getOutput()!=null; + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTankInput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankInput")); + this.fluidTankProducts.readFromNBT(nbttagcompound.getCompoundTag("fluidTankProducts")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankInputTag = new NBTTagCompound(); + this.fluidTankInput.writeToNBT(fluidTankInputTag); + nbttagcompound.setTag("fluidTankInput", fluidTankInputTag); + NBTTagCompound fluidTankProductsTag = new NBTTagCompound(); + this.fluidTankProducts.writeToNBT(fluidTankProductsTag); + nbttagcompound.setTag("fluidTankProducts", fluidTankProductsTag); + } + + public static void addRecipe(FluidStack input, FluidStack output, FluidStack output2, boolean specialCondition) + { + if(output2!=null) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {input}),null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {output,output2}),null,20,specialCondition)); + } + else + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {input}),null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {output}),null,20,specialCondition)); + } + } + + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + public boolean canProcess() + { + return this.engine.correctContent() && this.energy>=this.maxStorage && this.fluidTankInput.getFluidAmount()<1000; + } + + @Override + public boolean canDrain(ForgeDirection dir, Fluid arg1) { + return dir.getOpposite().equals(ForgeDirection.getOrientation(this.getFacing())) || dir.equals(ForgeDirection.UP); + } + + @Override + public boolean canFill(ForgeDirection dir, Fluid fluid) { + return dir.equals(ForgeDirection.getOrientation(this.getFacing())); + } + + @Override + public FluidStack drain(ForgeDirection dir, FluidStack fstack, boolean doDrain) { + if(this.canDrain(dir, null)) + { + return this.fluidTankProducts.drain(fstack, doDrain); + } + return null; + } + + @Override + public FluidStack drain(ForgeDirection dir, int amount, boolean doDrain) { + if(this.canDrain(dir, null)) + { + if(dir.equals(ForgeDirection.UP)) + { + return this.fluidTankProducts.drainLightest(amount, doDrain); + } + return this.fluidTankProducts.drain(amount, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection dir, FluidStack fstack, boolean doFill) + { + if(fstack!=null && fstack.getFluid()!=null && this.canFill(dir, fstack.getFluid())) + { + this.fluidTankInput.drain(IHLUtils.getFluidStackWithSize("air", this.fluidTankInput.getCapacity()), true); + return this.fluidTankInput.fill(fstack, doFill); + } + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection dir) + { + return new FluidTankInfo[] {this.fluidTankInput.getInfo(),this.fluidTankProducts.getInfo()}; + } + +} diff --git a/ihl/processing/chemistry/ElectricEvaporatorBlock.java b/ihl/processing/chemistry/ElectricEvaporatorBlock.java new file mode 100644 index 0000000..2507b2e --- /dev/null +++ b/ihl/processing/chemistry/ElectricEvaporatorBlock.java @@ -0,0 +1,221 @@ +package ihl.processing.chemistry; + +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +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.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class ElectricEvaporatorBlock extends Block implements ITileEntityProvider{ + + IIcon textureFrontActive, textureSide, textureBottom, textureTop; + + public ElectricEvaporatorBlock(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 new ItemStack(Blocks.furnace,1).getItem(); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + ItemStack result = new ItemStack(Blocks.furnace,1); + this.dropBlockAsItem(world, x, y, z, result); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new ElectricEvaporatorTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorFront"); + this.textureFrontActive = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorFrontActive"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorSide"); + this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorTop"); + this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorBottom"); + } + + @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 ElectricEvaporatorTileEntity) + { + ElectricEvaporatorTileEntity bte = (ElectricEvaporatorTileEntity)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) + { + int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null && t instanceof ElectricEvaporatorTileEntity) + { + ElectricEvaporatorTileEntity te = (ElectricEvaporatorTileEntity)t; + if(player.isSneaking()) + { + switch(var7) + { + case 0: + te.setFacing((short) 3); + break; + case 1: + te.setFacing((short) 4); + break; + case 2: + te.setFacing((short) 2); + break; + case 3: + te.setFacing((short) 5); + break; + default: + break; + } + } + else + { + switch(var7) + { + case 0: + te.setFacing((short) 2); + break; + case 1: + te.setFacing((short) 5); + break; + case 2: + te.setFacing((short) 3); + break; + case 3: + te.setFacing((short) 4); + break; + default: + break; + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + IIcon faceIcon=this.blockIcon; + int facing=3; + int mask[] = { + 0,1,2,3,4,5, + 1,0,3,2,4,5, + 2,3,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) + { + ElectricEvaporatorTileEntity tebh = (ElectricEvaporatorTileEntity) te; + facing=tebh.getFacing(); + if(tebh.getActive()) + { + faceIcon=this.textureFrontActive; + } + } + + switch (mask[facing*6+side]) + { + case 0: + return faceIcon; + case 1: + return this.textureSide; + case 2: + return this.textureBottom; + case 3: + return this.textureTop; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + IIcon sideIcon = this.blockIcon; + switch (side) + { + case 0: + return this.textureBottom; + case 1: + return this.textureTop; + case 2: + return this.textureSide; + case 3: + return this.blockIcon; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random random) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof ElectricEvaporatorTileEntity) + { + ElectricEvaporatorTileEntity ete = (ElectricEvaporatorTileEntity) te; + if(ete.getActive()) + { + world.spawnParticle("snowshovel", x+0.2D, y+1.2D, z+0.2D, 0D, 0.05D, 0D); + } + } + } +} diff --git a/ihl/processing/chemistry/ElectricEvaporatorContainer.java b/ihl/processing/chemistry/ElectricEvaporatorContainer.java new file mode 100644 index 0000000..9dc136e --- /dev/null +++ b/ihl/processing/chemistry/ElectricEvaporatorContainer.java @@ -0,0 +1,113 @@ +package ihl.processing.chemistry; + +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; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class ElectricEvaporatorContainer extends ContainerBase { + + protected ElectricEvaporatorTileEntity tileEntity; + public int lastFluidAmount = -1; + public double lastEnergy = -1; + public short lastProgress = -1; + private final static int height=166; + + public ElectricEvaporatorContainer(EntityPlayer entityPlayer, ElectricEvaporatorTileEntity electricEvaporatorTileEntity){ + super(electricEvaporatorTileEntity); + this.tileEntity = electricEvaporatorTileEntity; + 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(electricEvaporatorTileEntity.fuelSlot, 0, 8, 32)); + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.fluidItemsSlot, 0, 44, 14)); + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.emptyFluidItemsSlot, 0, 44, 32)); + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.fillItemsSlot, 0, 44, 50)); + this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.outputSlot, 0, 117, 32)); + for(int row=0;row<=3;row++) + { + this.addSlotToContainer(new SlotInvSlot(tileEntity.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.getFluidTank().getFluid()!=null && this.tileEntity.getFluidTank().getFluidAmount() != this.lastFluidAmount) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getFluidTank().getFluid().getFluid().getID()); + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getFluidTank().getFluidAmount()); + } + + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, ((int)this.tileEntity.getEnergy()>>15) & Short.MAX_VALUE); + icrafting.sendProgressBarUpdate(this, 3, (short)((int)this.tileEntity.getEnergy() & Short.MAX_VALUE)); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 4, this.tileEntity.progress); + icrafting.sendProgressBarUpdate(this, 5, this.tileEntity.maxProgress); + } + } + + this.lastFluidAmount = this.tileEntity.getFluidTank().getFluidAmount(); + this.lastEnergy = this.tileEntity.getEnergy(); + this.lastProgress = this.tileEntity.progress; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.getFluidTank().setFluid(new FluidStack(FluidRegistry.getFluid(value), 1000)); + break; + case 1: + this.tileEntity.getFluidTank().setFluid(new FluidStack(this.tileEntity.getFluidTank().getFluid().getFluid(), value)); + break; + case 2: + this.tileEntity.setEnergy(value<<15); + break; + case 3: + this.tileEntity.setEnergy(this.tileEntity.getEnergy()+value); + break; + case 4: + this.tileEntity.progress=(short) value; + break; + case 5: + this.tileEntity.maxProgress=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/ElectricEvaporatorGui.java b/ihl/processing/chemistry/ElectricEvaporatorGui.java new file mode 100644 index 0000000..016335f --- /dev/null +++ b/ihl/processing/chemistry/ElectricEvaporatorGui.java @@ -0,0 +1,86 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; +import ic2.core.util.DrawUtil; +import ic2.core.util.GuiTooltipHelper; + +@SideOnly(Side.CLIENT) +public class ElectricEvaporatorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIElectricEvaporator.png"); + private ElectricEvaporatorContainer container; + private String title = StatCollector.translateToLocal("ihl.gui.electricEvaporator"); + + public ElectricEvaporatorGui (ElectricEvaporatorContainer electricEvaporatorContainer) { + //the container is instanciated and passed to the superclass for handling + super(electricEvaporatorContainer); + this.container=electricEvaporatorContainer; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + fontRendererObj.drawString(title, 8, 70, 6171880); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(99, 34, 198, 0, i1 + 1, 13); + } + + if (this.container.tileEntity.getFluidTank().getFluid()!=null && this.container.tileEntity.getFluidTank().getFluidAmount() > 0) + { + FluidStack fluidStack = this.container.tileEntity.getFluidTank().getFluid(); + if(fluidStack!=null) + { + Fluid fluid = fluidStack.getFluid(); + if(fluid!=null) + { + + IIcon fluidIcon = fluid.getIcon(); + + if (fluidIcon != null) + { + this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + int liquidHeight = this.container.tileEntity.gaugeLiquidScaled(47); + + DrawUtil.drawRepeated(fluidIcon, (82), 16 + 47 - liquidHeight, 12.0D, liquidHeight, this.zLevel); + this.mc.renderEngine.bindTexture(background); + } + } + String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getUnlocalizedName()) + ": " + fluidStack.amount + "mB"; + //GuiTooltiphelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset+64, yOffset+23, xOffset+74, yOffset+71); + GuiTooltipHelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset-8, yOffset-15, xOffset+2, yOffset+30); + } + } + } + + @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/processing/chemistry/ElectricEvaporatorTileEntity.java b/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java new file mode 100644 index 0000000..3505cda --- /dev/null +++ b/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java @@ -0,0 +1,444 @@ +package ihl.processing.chemistry; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +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.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +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.api.network.INetworkTileEntityEventListener; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.audio.AudioSource; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotUpgrade; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ic2.core.upgrade.IUpgradableBlock; +import ic2.core.upgrade.IUpgradeItem; +import ic2.core.upgrade.UpgradableProperty; +import ihl.IHLMod; +import ihl.utils.IHLInvSlotDischarge; +import ihl.utils.IHLUtils; + +public class ElectricEvaporatorTileEntity extends EvaporatorTileEntity implements IEnergySink, IUpgradableBlock, INetworkTileEntityEventListener +{ + public final InvSlotUpgrade upgradeSlot; + private int tier; + private int lastTier; + public int maxStorage; + private int defaultMaxStorage; + private double energy; + public final int defaultEnergyConsume; + public final int defaultOperationLength; + public final int defaultTier; + public int energyConsume; + public AudioSource audioSource; + private static final int EventStart = 0; + private static final int EventInterrupt = 1; + private static final int EventStop = 2; + private int updateChecksum=0; + private boolean addedToEnergyNet=false; + + public ElectricEvaporatorTileEntity() + { + super(); + this.defaultEnergyConsume = this.energyConsume = 8; + this.defaultOperationLength = this.maxProgress = 400; + this.energy=0D; + this.lastTier = this.tier = this.defaultTier = 1; + this.maxStorage = this.defaultMaxStorage = defaultEnergyConsume * defaultOperationLength; + this.fuelSlot = new IHLInvSlotDischarge(this, 1, Access.IO, this.tier, InvSlot.InvSide.BOTTOM); + this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 4, 4); + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("tier"); + fields.add("maxStorage"); + return fields; + } + + public void setOverclockRates() + { + int speedUp=0; + int tierUp=0; + int capacityUp=0; + int checksum=0; + for(int i=0;i 1.0D) + { + double amount = ((IHLInvSlotDischarge)this.fuelSlot).discharge(this.getDemandedEnergy(), false); + this.energy += amount; + } + if (this.needsFluid()) + { + IHLUtils.handleFluidSlotsBehaviour(null, fluidItemsSlot, emptyFluidItemsSlot, fluidTank); + } + + if (this.canOperate() && this.energy >= this.energyConsume) + { + this.setActive(true); + + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + this.energy -= this.energyConsume; + if (this.progress >= this.maxProgress) + { + this.operate(); + needsInvUpdate = true; + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + for (int i = 0; i < this.upgradeSlot.size(); ++i) + { + ItemStack stack = this.upgradeSlot.get(i); + + if (stack != null && stack.getItem() instanceof IUpgradeItem && ((IUpgradeItem)stack.getItem()).onTick(stack, this)) + { + needsInvUpdate = true; + } + } + } + } + + private static int applyModifier(int base, int extra, double multiplier) + { + double ret = Math.round(((double)base + (double)extra) * multiplier); + return ret > 2.147483647E9D ? Integer.MAX_VALUE : (int)ret; + } + + @Override + public void onNetworkEvent(int event) + { + if (this.audioSource == null && this.getStartSoundFile() != null) + { + this.audioSource = IC2.audioManager.createSource(this, this.getStartSoundFile()); + } + + switch (event) + { + case 0: + if (this.audioSource != null) + { + this.audioSource.play(); + } + + break; + + case 1: + if (this.audioSource != null) + { + this.audioSource.stop(); + } + + break; + + case 2: + if (this.audioSource != null) + { + this.audioSource.stop(); + } + + } + } + + public String getStartSoundFile() + { + return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg"; + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + return "Electric evaporator"; + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer entityPlayer) + { + return new ElectricEvaporatorContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new ElectricEvaporatorGui(new ElectricEvaporatorContainer(entityPlayer, this)); + } + + @Override + public boolean getGui(EntityPlayer player) + { + return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; + } + + @Override + public int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + @Override + public int mZ() + { + switch(this.getFacing()) + { + case 2: + return -1; + case 3: + return 1; + default: + return 0; + } + } + + @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 void setEnergy(double i) { + this.energy=i; + } + + @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 boolean acceptsEnergyFrom(TileEntity emitter, + ForgeDirection direction) { + return true; + } + + public ItemStack getOutput(int arg0) + { + return this.outputSlot.get(arg0); + } + + public int getOutputSize() { + return this.outputSlot.size(); + } + + public void setOutput(int arg0, ItemStack arg1) + { + this.outputSlot.put(arg0, arg1); + } + + @Override + public Set getUpgradableProperties() + { + Set properties = new HashSet(); + properties.add(UpgradableProperty.ItemProducing); + properties.add(UpgradableProperty.EnergyStorage); + properties.add(UpgradableProperty.Transformer); + return properties; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ElectrolysisBathContainer.java b/ihl/processing/chemistry/ElectrolysisBathContainer.java new file mode 100644 index 0000000..f2cc74e --- /dev/null +++ b/ihl/processing/chemistry/ElectrolysisBathContainer.java @@ -0,0 +1,94 @@ +package ihl.processing.chemistry; + +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; +import net.minecraftforge.fluids.FluidStack; + +public class ElectrolysisBathContainer extends ContainerBase { + + protected ElectrolysisBathTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public short lastTemperature = -1; + private final static int height=166; + public List fluidTankFluidList; + + public ElectrolysisBathContainer(EntityPlayer entityPlayer, ElectrolysisBathTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList(); + 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.fillInputSlot, 0, 6, 52)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 6, 16)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 6, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 98, 16)); + } + + @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.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + } + + @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.temperature=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/ElectrolysisBathGui.java b/ihl/processing/chemistry/ElectrolysisBathGui.java new file mode 100644 index 0000000..cb39044 --- /dev/null +++ b/ihl/processing/chemistry/ElectrolysisBathGui.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry; + +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 ic2.core.network.NetworkManager; +import ihl.collector.GuiMultiTextureButton; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class ElectrolysisBathGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIElectrolysisBath.png"); + private ElectrolysisBathContainer container; + private GuiMultiTextureButton button1; + private int timer=10; + + public ElectrolysisBathGui (ElectrolysisBathContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + button1=new GuiMultiTextureButton(0, x+97, y+58, 18, 18, background,97,58,238,238); + 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=true; + timer=10; + } + } + + @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.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(121, 33, getFrameX(i1), getFrameY(i1),24,24); + } + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 32, 11, 89, 72, zLevel, par1, par2, xOffset, yOffset); + } + this.mc.renderEngine.bindTexture(background); + this.drawTexturedModalRect(60, 3, 252, 0,4,48); + } + + @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=false; + } + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ElectrolysisBathModel.java b/ihl/processing/chemistry/ElectrolysisBathModel.java new file mode 100644 index 0000000..310ec62 --- /dev/null +++ b/ihl/processing/chemistry/ElectrolysisBathModel.java @@ -0,0 +1,86 @@ +package ihl.processing.chemistry; + +// Date: 12.04.2015 13:06:31 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +public class ElectrolysisBathModel extends ModelBase +{ + //fields + ModelRenderer Piece1; + ModelRenderer FrontPylone; + ModelRenderer BackPylone; + ModelRenderer LeftPylone; + ModelRenderer RightPylone; + + public ElectrolysisBathModel() + { + textureWidth = 64; + textureHeight = 128; + setTextureOffset("Piece1.Stick01", 48, 4); + setTextureOffset("Piece1.Shape1", 16, 18); + setTextureOffset("Piece1.Body04", 0, 48); + setTextureOffset("Piece1.Shape2", 0, 18); + setTextureOffset("Piece1.Shape3", 16, 0); + setTextureOffset("Piece1.Shape4", 0, 0); + setTextureOffset("Piece1.Box01", 41, 18); + setTextureOffset("Piece1.Shape5", 23, 84); + setTextureOffset("Piece1.Shape6", 23, 84); + setTextureOffset("Piece1.Shape7", 23, 84); + setTextureOffset("Piece1.Shape8", 23, 83); + setTextureOffset("FrontPylone.Shape9", 23, 84); + setTextureOffset("BackPylone.Shape10", 23, 84); + setTextureOffset("LeftPylone.Shape12", 23, 84); + setTextureOffset("RightPylone.Shape11", 23, 82); + + Piece1 = new ModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = false; + Piece1.addBox("Stick01", -1F, -16F, -1F, 2, 9, 2); + Piece1.addBox("Shape1", -8F, -8F, -8F, 2, 16, 14); + Piece1.addBox("Body04", -6F, -7F, -6F, 12, 15, 12); + Piece1.addBox("Shape2", 6F, -8F, -6F, 2, 16, 14); + Piece1.addBox("Shape3", -6F, -8F, -8F, 14, 16, 2); + Piece1.addBox("Shape4", -8F, -8F, 6F, 14, 16, 2); + Piece1.addBox("Box01", -2F, -13F, -2F, 4, 2, 4); + Piece1.addBox("Shape5", 5F, -9F, -1.5F, 2, 2, 3); + Piece1.addBox("Shape6", -7F, -9F, -1.5F, 2, 2, 3); + Piece1.addBox("Shape7", -1.5F, -9F, 5F, 3, 2, 2); + Piece1.addBox("Shape8", -1.5F, -9F, -7F, 3, 2, 2); + FrontPylone = new ModelRenderer(this, "FrontPylone"); + FrontPylone.setRotationPoint(0F, 7F, -5F); + setRotation(FrontPylone, -0.9F, 0F, 0); + FrontPylone.mirror = true; + FrontPylone.addBox("Shape9", -1F, -5F, -1F, 2, 6, 1); + BackPylone = new ModelRenderer(this, "BackPylone"); + BackPylone.setRotationPoint(0F, 7F, 5F); + setRotation(BackPylone, 0.9F, 0F, 0F); + BackPylone.mirror = true; + BackPylone.addBox("Shape10", -1F, -5F, 0F, 2, 6, 1); + LeftPylone = new ModelRenderer(this, "LeftPylone"); + LeftPylone.setRotationPoint(5F, 7F, 0F); + setRotation(LeftPylone, 0F, 0F, -0.9F); + LeftPylone.mirror = true; + LeftPylone.addBox("Shape12", 0F, -5F, -1F, 1, 6, 2); + RightPylone = new ModelRenderer(this, "RightPylone"); + RightPylone.setRotationPoint(-5F, 7F, 0F); + setRotation(RightPylone, 0, 0F, 0.9F); + RightPylone.mirror = true; + RightPylone.addBox("Shape11", -1F, -5F, -1F, 1, 6, 2); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/chemistry/ElectrolysisBathTileEntity.java b/ihl/processing/chemistry/ElectrolysisBathTileEntity.java new file mode 100644 index 0000000..b549247 --- /dev/null +++ b/ihl/processing/chemistry/ElectrolysisBathTileEntity.java @@ -0,0 +1,312 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +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.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +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.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 ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ic2.core.network.NetworkManager; +import ihl.IHLMod; +import ihl.flexible_cable.FlexibleCableHolderBaseTileEntity; +import ihl.flexible_cable.IHLGrid; +import ihl.flexible_cable.NodeEntity; +import ihl.interfaces.IEnergyNetNode; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class ElectrolysisBathTileEntity extends FlexibleCableHolderBaseTileEntity implements IHasGui, INetworkClientTileEntityEventListener, IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("electrolysisbath"); + public final ApparatusProcessableInvSlot input; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + public short progress; + protected short operationLength=20000;//Short.MAX_VALUE=32767 + private final IHLFluidTank fluidTank = new IHLFluidTank(2000); + public short temperature=20; + private final static double resistance=5D; + + public ElectrolysisBathTileEntity() { + super(); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 1, 64); + } + + @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); + NBTTagCompound fractionalOutputNBT = new NBTTagCompound(); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("electrolysisBath"); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + temperature=(short) (this.fluidTank.getTemperature()-273); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + boolean needsInvUpdate = false; + if (this.canOperate()) + { + this.setActive(true); + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + if(this.getGrid().energy>0D) + { + double voltage = this.getGrid().getSinkVoltage(this); + double drawEnergy = voltage*voltage/resistance; + this.progress+=drawEnergy; + this.getGrid().drawEnergy(drawEnergy, this); + } + + if (this.progress >= this.operationLength) + { + this.operate(); + needsInvUpdate = true; + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + FluidStack fstack = this.fluidTank.drain(amount, doDrain); + return fstack; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return true; + } + + @Override + public String getInventoryName() { + return "Electrolysis bath"; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + TileEntity te = worldObj.getTileEntity(xCoord, yCoord-1, zCoord); + if(te instanceof IFluidHandler && this.fluidTank.getFluid()!=null) + { + IFluidHandler ifhte = (IFluidHandler)te; + if(ifhte.canFill(ForgeDirection.UP, this.fluidTank.getFluid().getFluid())) + { + int filled = ifhte.fill(ForgeDirection.UP, this.fluidTank.drain(this.getTankAmount(), false), true); + this.fluidTank.drain(filled, true); + } + } + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new ElectrolysisBathGui(new ElectrolysisBathContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new ElectrolysisBathContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + public boolean canOperate() + { + return getOutput()!=null; + } + + public UniversalRecipeOutput getOutput() + { + return ElectrolysisBathTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + public List[] getInput() + { + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + + @Override + public double getMaxAllowableVoltage() + { + return 64000D; + } + + @Override + public double getEnergyAmountThisNodeWant() + { + double voltage = this.getGrid().getSinkVoltage(this); + double energy = voltage*voltage/resistance; + return this.getOutput()!=null?energy:0; + } + + @Override + public void injectEnergyInThisNode(double amount, double voltage) + { + this.progress+=amount; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/EvaporatorBlock.java b/ihl/processing/chemistry/EvaporatorBlock.java new file mode 100644 index 0000000..038a044 --- /dev/null +++ b/ihl/processing/chemistry/EvaporatorBlock.java @@ -0,0 +1,222 @@ +package ihl.processing.chemistry; + +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +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.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class EvaporatorBlock extends Block implements ITileEntityProvider{ + + IIcon textureFrontActive, textureSide, textureBottom, textureTop; + + public EvaporatorBlock(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 new ItemStack(Blocks.furnace,1).getItem(); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + ItemStack result = new ItemStack(Blocks.furnace,1); + this.dropBlockAsItem(world, x, y, z, result); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new EvaporatorTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorFront"); + this.textureFrontActive = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorFrontActive"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorSide"); + this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorTop"); + this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorBottom"); + } + + @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 EvaporatorTileEntity) + { + EvaporatorTileEntity bte = (EvaporatorTileEntity)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) + { + int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null && t instanceof EvaporatorTileEntity) + { + EvaporatorTileEntity te = (EvaporatorTileEntity)t; + if(player.isSneaking()) + { + switch(var7) + { + case 0: + te.setFacing((short) 3); + break; + case 1: + te.setFacing((short) 4); + break; + case 2: + te.setFacing((short) 2); + break; + case 3: + te.setFacing((short) 5); + break; + default: + break; + } + } + else + { + switch(var7) + { + case 0: + te.setFacing((short) 2); + break; + case 1: + te.setFacing((short) 5); + break; + case 2: + te.setFacing((short) 3); + break; + case 3: + te.setFacing((short) 4); + break; + default: + break; + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + IIcon faceIcon=this.blockIcon; + int facing=3; + int mask[] = { + 0,1,2,3,4,5, + 1,0,3,2,4,5, + 2,3,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) + { + EvaporatorTileEntity tebh = (EvaporatorTileEntity) te; + facing=tebh.getFacing(); + if(tebh.getActive()) + { + faceIcon=this.textureFrontActive; + } + } + + switch (mask[facing*6+side]) + { + case 0: + return faceIcon; + case 1: + return this.textureSide; + case 2: + return this.textureBottom; + case 3: + return this.textureTop; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + IIcon sideIcon = this.blockIcon; + switch (side) + { + case 0: + return this.textureTop; + case 1: + return this.textureBottom; + case 2: + return this.textureSide; + case 3: + return this.blockIcon; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + public void randomDisplayTick(World world, int x, int y, int z, Random random) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof EvaporatorTileEntity) + { + EvaporatorTileEntity ete = (EvaporatorTileEntity) te; + if(ete.getActive()) + { + world.spawnParticle("snowshovel", x+0.2D, y+1.2D, z+0.2D, 0D, 0.05D, 0D); + world.spawnParticle("flame", x+0.5D+ete.mX()*0.5D+(random.nextDouble()*0.4D-0.2D)*ete.mZ(), y+random.nextDouble()*0.25D, z+0.5D+ete.mZ()*0.5D+(random.nextDouble()*0.4D-0.2D)*ete.mX(), 0D, 0.01D, 0D); + } + } + } +} diff --git a/ihl/processing/chemistry/EvaporatorContainer.java b/ihl/processing/chemistry/EvaporatorContainer.java new file mode 100644 index 0000000..1df3d2f --- /dev/null +++ b/ihl/processing/chemistry/EvaporatorContainer.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry; + +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; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class EvaporatorContainer extends ContainerBase { + + protected EvaporatorTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastFuel = -1; + public short lastProgress = -1; + private final static int height=166; + + public EvaporatorContainer(EntityPlayer entityPlayer, EvaporatorTileEntity 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.fuelSlot, 0, 8, 32)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fluidItemsSlot, 0, 44, 14)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 44, 32)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillItemsSlot, 0, 44, 50)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 117, 32)); + + } + + @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.getFluidTank().getFluid()!=null && this.tileEntity.getFluidTank().getFluidAmount() != this.lastFluidAmount) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getFluidTank().getFluid().getFluid().getID()); + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getFluidTank().getFluidAmount()); + } + + if (this.tileEntity.fuel != this.lastFuel) + { + icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.fuel); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 3, this.tileEntity.progress); + } + } + + this.lastFluidAmount = this.tileEntity.getFluidTank().getFluidAmount(); + this.lastFuel = this.tileEntity.fuel; + this.lastProgress = this.tileEntity.progress; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.getFluidTank().setFluid(new FluidStack(FluidRegistry.getFluid(value), 1000)); + break; + case 1: + this.tileEntity.getFluidTank().setFluid(new FluidStack(this.tileEntity.getFluidTank().getFluid().getFluid(), value)); + break; + case 2: + this.tileEntity.fuel=value; + break; + case 3: + this.tileEntity.progress=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/EvaporatorGui.java b/ihl/processing/chemistry/EvaporatorGui.java new file mode 100644 index 0000000..12edba9 --- /dev/null +++ b/ihl/processing/chemistry/EvaporatorGui.java @@ -0,0 +1,85 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; +import ic2.core.util.DrawUtil; +import ic2.core.util.GuiTooltipHelper; + +@SideOnly(Side.CLIENT) +public class EvaporatorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUISolidFuelEvaporator.png"); + private EvaporatorContainer container; + private String title = StatCollector.translateToLocal("ihl.gui.evaporator"); + + + public EvaporatorGui (EvaporatorContainer 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; + fontRendererObj.drawString(title, 8, 70, 6171880); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.fuel > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeFuelScaled(12),12); + this.drawTexturedModalRect(9, 16 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(99, 34, 198, 0, i1 + 1, 13); + } + + if (this.container.tileEntity.getTankAmount() > 0) + { + FluidStack fluidStack = this.container.tileEntity.getFluidTank().getFluid(); + if(fluidStack!=null) + { + Fluid fluid = fluidStack.getFluid(); + if(fluid!=null) + { + + IIcon fluidIcon = fluid.getIcon(); + + if (fluidIcon != null) + { + this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + int liquidHeight = this.container.tileEntity.gaugeLiquidScaled(47); + DrawUtil.drawRepeated(fluidIcon, (82), 16 + 47 - liquidHeight, 12.0D, liquidHeight, this.zLevel); + this.mc.renderEngine.bindTexture(background); + } + } + String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getUnlocalizedName()) + ": " + fluidStack.amount + "mB"; + GuiTooltipHelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset-8, yOffset-15, xOffset+2, yOffset+30); + } + } + } + + @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/processing/chemistry/EvaporatorTileEntity.java b/ihl/processing/chemistry/EvaporatorTileEntity.java new file mode 100644 index 0000000..e4eb8c0 --- /dev/null +++ b/ihl/processing/chemistry/EvaporatorTileEntity.java @@ -0,0 +1,299 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.Map; + +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.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import ic2.api.item.IC2Items; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityLiquidTankInventory; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableFuel; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.IHLMod; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; + +public class EvaporatorTileEntity extends TileEntityLiquidTankInventory implements IHasGui +{ + public final IHLInvSlotOutput outputSlot; + public InvSlot fuelSlot; + public final InvSlotConsumableLiquidIHL fluidItemsSlot; + public final InvSlotConsumableLiquidIHL fillItemsSlot; + public final InvSlotOutput emptyFluidItemsSlot; + + public short progress = 0; + public short maxProgress = 450; + public int fuel = 0; + public int maxFuel = 0; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("evaporator"); + + public EvaporatorTileEntity() + { + super(8); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1); + this.fuelSlot = new InvSlotConsumableFuel(this, "fuel", 1, 1, true); + this.fluidItemsSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", 2, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillItemsSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", 4, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 3, 1); + } + + public static void init() + { + addRecipe(new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"),200), IC2Items.getItem("resin")); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + + try + { + this.fuel = nbttagcompound.getInteger("fuel"); + } + catch (Throwable var4) + { + this.fuel = nbttagcompound.getShort("fuel"); + } + + try + { + this.maxFuel = nbttagcompound.getInteger("maxFuel"); + } + catch (Throwable var3) + { + this.maxFuel = nbttagcompound.getShort("maxFuel"); + } + + this.progress = nbttagcompound.getShort("progress"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setInteger("fuel", this.fuel); + nbttagcompound.setInteger("maxFuel", this.maxFuel); + nbttagcompound.setShort("progress", this.progress); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + if(this.outputSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.outputSlot.get())); + if(this.fuelSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.fuelSlot.get())); + if(this.emptyFluidItemsSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.emptyFluidItemsSlot.get())); + return new ItemStack(IHLMod.evaporatorBlock,1); + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / maxProgress; + } + + public int gaugeFuelScaled(int i) + { + if (this.maxFuel == 0) + { + this.maxFuel = this.fuel; + + if (this.maxFuel == 0) + { + this.maxFuel = 160; + } + } + + return this.fuel * i / this.maxFuel; + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + boolean needsInvUpdate = false; + if (this.needsFluid()) + { + IHLUtils.handleFluidSlotsBehaviour(fillItemsSlot, fluidItemsSlot, emptyFluidItemsSlot, fluidTank); + } + if (this.fuel <= 0 && this.canOperate()) + { + this.fuel = this.maxFuel = ((InvSlotConsumableFuel) this.fuelSlot).consumeFuel(); + + if (this.fuel > 0) + { + needsInvUpdate = true; + } + } + + if (this.isBurning() && this.canOperate()) + { + ++this.progress; + + if (this.progress >= maxProgress) + { + this.progress = 0; + this.operate(); + needsInvUpdate = true; + } + } + else + { + this.progress = 0; + } + + if (this.fuel > 0) + { + --this.fuel; + } + + if (this.getActive() != this.isBurning()) + { + this.setActive(this.isBurning()); + needsInvUpdate = true; + } + } + + public void operate() + { + UniversalRecipeOutput output = this.getOutput(); + if(output!=null && !output.getItemOutputs().isEmpty()) + { + this.outputSlot.add(this.getOutput().getItemOutputs().get(0).copy()); + } + this.fluidTank.drain(recipeManager.getRecipeInput(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null).getFluidInputs().get(0).getAmount(), true); + } + + public boolean isBurning() + { + return this.fuel > 0; + } + + public boolean canOperate() + { + if (this.fluidTank.getFluid()==null) + { + return false; + } + else + { + UniversalRecipeOutput output = recipeManager.getOutputFor(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null, false, false); + return output == null ? false : (this.outputSlot.canAdd(output.getItemOutputs()) ? true : false); + } + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + return "Solid fuel evaporator"; + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer entityPlayer) + { + return new EvaporatorContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new EvaporatorGui(new EvaporatorContainer(entityPlayer, this)); + } + + @Override + public void onGuiClosed(EntityPlayer entityPlayer) {} + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection arg0, Fluid fluid1) { + return true; + } + + public boolean getGui(EntityPlayer player) + { + return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; + } + + public int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + public int mZ() + { + switch(this.getFacing()) + { + case 2: + return -1; + case 3: + return 1; + default: + return 0; + } + } + + public static void addRecipe(FluidStack input, ItemStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack [] {input}),null), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {output}),20)); + } + + public UniversalRecipeOutput getOutput() + { + if (this.fluidTank.getFluid()==null) + { + return null; + } + else + { + UniversalRecipeOutput output = recipeManager.getOutputFor(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null, false, false); + return output == null ? null : (this.outputSlot.canAdd(output.getItemOutputs()) ? output : null); + } + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/ExplosiveTileEntity.java b/ihl/processing/chemistry/ExplosiveTileEntity.java new file mode 100644 index 0000000..777f527 --- /dev/null +++ b/ihl/processing/chemistry/ExplosiveTileEntity.java @@ -0,0 +1,49 @@ +package ihl.processing.chemistry; + +import ic2.core.ExplosionIC2; +import ic2.core.block.EntityIC2Explosive; +import ihl.utils.EntityIHLExplosion; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class ExplosiveTileEntity extends TileEntity { + + public int explosionPower=10000; + public int explosionType=1; + + public void createExplosion(EntityPlayer player) + { + switch(this.explosionType) + { + case 0: + ExplosionIC2 explosion = new ExplosionIC2(this.worldObj, new EntityIC2Explosive(worldObj), xCoord+0.5d, yCoord+0.5d, zCoord+0.5d, this.explosionPower/1000f, 0f, ExplosionIC2.Type.Normal,player, 0); + System.out.println("Start"); + explosion.doExplosion(); + System.out.println("End"); + break; + case 1: + EntityIHLExplosion ex1 = new EntityIHLExplosion(worldObj, xCoord, yCoord, zCoord,this.explosionPower); + worldObj.spawnEntityInWorld(ex1); + break; + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + if(nbt!=null) + { + explosionPower=nbt.getInteger("explosionPower"); + explosionType=nbt.getInteger("explosionType"); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + nbt.setInteger("explosionPower",explosionPower); + nbt.setInteger("explosionType",explosionType); + } + +} diff --git a/ihl/processing/chemistry/ExtruderModel.java b/ihl/processing/chemistry/ExtruderModel.java new file mode 100644 index 0000000..25e1263 --- /dev/null +++ b/ihl/processing/chemistry/ExtruderModel.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class ExtruderModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer Extruder; + + public ExtruderModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 7); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 0, 0); + setTextureOffset("Belt2.Shape13", 0, 0); + setTextureOffset("Extruder.PipeN16", 0, 0); + setTextureOffset("Extruder.PipeN15", 24, 20); + setTextureOffset("Extruder.Shape8", 0, 0); + setTextureOffset("Extruder.PipeU17", 0, 0); + setTextureOffset("Extruder.PipeUC18", 0, 0); + setTextureOffset("Extruder.Shape14", 0, 0); + setTextureOffset("Extruder.PipeN14", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape16", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -1F, -1F, 1F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0.5F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + Extruder = new IHLModelRenderer(this, "Extruder"); + Extruder.setRotationPoint(0F, 16F, 0F); + setRotation(Extruder, 0F, 0F, 0F); + Extruder.mirror = true; + Extruder.addTube("PipeN16", -4.5F, 0.5F, -5F, 3, 3, 12, 0F,1F,ForgeDirection.NORTH); + Extruder.addTube("PipeN15", -5.5F, -0.5F, 0F, 5, 5, 7, 0.5F,1F,ForgeDirection.NORTH); + Extruder.addBox("Shape8", -5F, 4F, 6.9F, 4, 3, 1); + Extruder.addTube("PipeU17", -5.5F, -8F, -5F, 5, 8, 5, 0.8F,1F,ForgeDirection.UP); + Extruder.addTube("PipeUC18", -5.5F, 0F, -5F, 5, 2, 5, 0.8F,0.6F,ForgeDirection.UP); + Extruder.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Extruder.addTube("PipeN14", -5.5F, -0.5F, 7F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/chemistry/FluidizedBedReactorContainer.java b/ihl/processing/chemistry/FluidizedBedReactorContainer.java new file mode 100644 index 0000000..4d42d29 --- /dev/null +++ b/ihl/processing/chemistry/FluidizedBedReactorContainer.java @@ -0,0 +1,103 @@ +package ihl.processing.chemistry; + +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; +import net.minecraftforge.fluids.FluidStack; + +public class FluidizedBedReactorContainer extends ContainerBase { + + protected FluidizedBedReactorTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public short lastTemperature = -1; + public short lastEnergy = -1; + private final static int height=166; + public List fluidTankFluidList; + + public FluidizedBedReactorContainer(EntityPlayer entityPlayer, FluidizedBedReactorTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList(); + 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.fillInputSlot, 0, 102, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 102, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 102, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 8, 23)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 8, 41)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 43, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 151, 33)); + } + + @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.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @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.temperature=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/FluidizedBedReactorGui.java b/ihl/processing/chemistry/FluidizedBedReactorGui.java new file mode 100644 index 0000000..6d07aca --- /dev/null +++ b/ihl/processing/chemistry/FluidizedBedReactorGui.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry; + +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 FluidizedBedReactorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIFluidizedBedReactor.png"); + private FluidizedBedReactorContainer container; + private int mixerFrame=0; + + public FluidizedBedReactorGui (FluidizedBedReactorContainer 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) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(155, 17 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(17),17); + this.drawTexturedModalRect(25, 34, 198, 0,i1,13); + if(mixerFrame++>3) + { + mixerFrame=0; + } + this.drawTexturedModalRect(126, 31, 244, 126+26*mixerFrame,12,26); + } + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 126, 28, 138, 59, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(background); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 169, 34, xOffset, yOffset); + } + } + + @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/processing/chemistry/FluidizedBedReactorTileEntity.java b/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java new file mode 100644 index 0000000..e9b2ec5 --- /dev/null +++ b/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java @@ -0,0 +1,358 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class FluidizedBedReactorTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("fluidizedbedreactor"); + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public short temperature=20; + private int fractionalOutputAmount=0; + + public FluidizedBedReactorTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 2, 64); + this.isGuiScreenOpened=true; + } + + @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 boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("fluidizedBedReactor"); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + switch(from) + { + case UP: + return this.fluidTank.drainLightest(amount, doDrain); + case NORTH: + return this.fluidTank.drainLightest(amount, doDrain); + case SOUTH: + return this.fluidTank.drainLightest(amount, doDrain); + case WEST: + return this.fluidTank.drainLightest(amount, doDrain); + case EAST: + return this.fluidTank.drainLightest(amount, doDrain); + case DOWN: + return this.fluidTank.drain(amount, doDrain); + default: + return this.fluidTank.drain(amount, doDrain); + } + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite()); + } + + @Override + public String getInventoryName() { + return "fluidizedBedReactor"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + // TODO Auto-generated method stub + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new FluidizedBedReactorGui(new FluidizedBedReactorContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new FluidizedBedReactorContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = getOutput(); + if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs())) + { + if(output.specialConditions) + { + return this.checkSpecialConditions(); + } + else + { + return true; + } + } + return false; + } + + private boolean checkSpecialConditions() + { + ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ); + if(te instanceof CryogenicDistillerTileEntity) + { + CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te; + return cgte.getFacing()==this.getFacing() && cgte.canProcess(); + } + return false; + } + + public UniversalRecipeOutput getOutput() + { + return FluidizedBedReactorTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List[] getInput() + { + for(int i=0;i1)this.input.consume(1, recipeInput.getItemInputs().get(1).getAmount()); + if(output1.getFluidOutputs().size()>0)this.fluidTank.fill(output1.getFluidOutputs().get(0).copy(), true); + if(output1.getFluidOutputs().size()>1)this.fluidTank.fill(output1.getFluidOutputs().get(1).copy(), true); + if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs()); + + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if(fluidTank.getFluid()!=null && fluidTank.getFluid().containsFluid(fluidStack)) + { + return this.fluidTank.drain(fluidStack, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.fluidTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.fluidTank.getInfo()}; + } + + public boolean needsFluid() + { + return this.fluidTank.getFluidAmount() <= this.fluidTank.getCapacity(); + } + + public FluidStack getFluidStackfromTank() + { + return this.fluidTank.getFluid(); + } + + public int getTankAmount() + { + return this.fluidTank.getFluidAmount(); + } + + public int gaugeLiquidScaled(int i, int index) + { + return this.fluidTank.getFluidAmount() <= 0 ? 0 : this.fluidTank.getFluidAmount(index) * i / this.fluidTank.getCapacity(); + } + public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + public int getNumberOfFluidsInTank() + { + return this.fluidTank.getNumberOfFluids(); + } + + public static Map getRecipes() + { + return recipeManager.getRecipes(); + } + + public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1) + { + if(fluidStackOutput!=null) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new ItemStack[] {itemStackOutput1}),200)); + } + else + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {itemStackOutput1}),200)); + } + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + + public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackInput, FluidStack fluidStackOutput, RecipeOutputItemStack itemStackOutput1) { + if(fluidStackOutput!=null) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new RecipeOutputItemStack[] {itemStackOutput1}),200)); + } + else + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(null, Arrays.asList(new RecipeOutputItemStack[] {itemStackOutput1}),200)); + } + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/FractionatorBottomModel.java b/ihl/processing/chemistry/FractionatorBottomModel.java new file mode 100644 index 0000000..c395af7 --- /dev/null +++ b/ihl/processing/chemistry/FractionatorBottomModel.java @@ -0,0 +1,48 @@ +// Date: 05.04.2015 16:55:22 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class FractionatorBottomModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorBottomModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Box03", 0, 0); + setTextureOffset("Base.Box04", 0, 0); + setTextureOffset("Base.Pipeup02", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.PipeUp05", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Box03", 2F, -7.1F, -8F, 6, 15, 16); + Base.addBox("Box04", -8F, 7F, -8F, 16, 1, 16); + Base.addTube("Pipeup02", -8F, -8F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("WestPipe03", -7.5F, -1.5F, -1.5F, 3, 3, 3, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("WestPipe04", -8F, -2F, -2F, 1, 4, 4, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("PipeUp05", -7F, -7F, -7F, 14, 15, 14, 0.8F, 1.0F, ForgeDirection.UP); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/chemistry/FractionatorBottomTileEntity.java b/ihl/processing/chemistry/FractionatorBottomTileEntity.java new file mode 100644 index 0000000..41840e0 --- /dev/null +++ b/ihl/processing/chemistry/FractionatorBottomTileEntity.java @@ -0,0 +1,389 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +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 net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.api.energy.tile.IHeatSource; +import ic2.core.IC2; +import ic2.core.block.TileEntityInventory; +import ihl.recipes.IRecipeInputFluid; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; + +public class FractionatorBottomTileEntity extends TileEntityInventory +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("fractionator"); + private static float kF = 24000F; + private static float gasC = 1F; + private static float fluidC = 4F; + private static float H = 2256F; + private final IHLFluidTank waterTank = new IHLFluidTank(100); + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + private int amountOfGasCondensed=0; + private int amountOfFluidEvaporated=0; + private int systemHeat=0; + private static final int maxSystemHeat=10000; + private final List listOfColumnSections = new ArrayList(); + private FractionatorCoverTileEntity columnCover; + private RefluxCondenserTileEntity refluxCondenser; + private IHeatSource heatSource; + private int fluxRecirculationProportion=10; + + public FractionatorBottomTileEntity() + { + super(); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.waterTank.readFromNBT(nbttagcompound.getCompoundTag("waterTank")); + this.amountOfGasCondensed=nbttagcompound.getInteger("amountOfGasCondensed"); + this.systemHeat=nbttagcompound.getInteger("systemHeat"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + + NBTTagCompound waterTankTag = new NBTTagCompound(); + this.waterTank.writeToNBT(waterTankTag); + nbttagcompound.setTag("waterTank", waterTankTag); + + nbttagcompound.setInteger("amountOfGasCondensed",this.amountOfGasCondensed); + nbttagcompound.setInteger("systemHeat",this.systemHeat); + + } + + public static void addRecipe(FluidStack fluidIn, FluidStack fluidOut1, FluidStack fluidOut2) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidIn}), null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidOut1,fluidOut2}),null,2)); + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("fractionatorBottom"); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(!this.checkIntegrity()) + { + return; + } + this.fluxRecirculationProportion=100-10000/(100+this.listOfColumnSections.size()*3); + ForgeDirection orientation = ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP); + if(systemHeat < maxSystemHeat && this.checkHeatSource(orientation)) + { + systemHeat+=this.heatSource.requestHeat(orientation.getOpposite(), Integer.MAX_VALUE); + } + FluidStack fsCurrentInput = this.fluidTank.getFluid(); + if(fsCurrentInput!=null && fsCurrentInput.amount>100 && systemHeat>0) + { + UniversalRecipeOutput rOutput = FractionatorBottomTileEntity.recipeManager.getOutputFor(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null, false, false); + UniversalRecipeInput rInput = FractionatorBottomTileEntity.recipeManager.getRecipeInput(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null); + if(rOutput!=null) + { + IRecipeInputFluid input = rInput.getFluidInputs().get(0); + int rInputAmount = input.getAmount(); + FluidStack result1=rOutput.getFluidOutputs().get(0).copy(); + FluidStack result2=rOutput.getFluidOutputs().get(1).copy(); + //max heat per tick of electric heater is 100 + int amountOfFluidToEvaporate = Math.min(fsCurrentInput.amount*result2.amount/rInputAmount,systemHeat/100); + systemHeat-=amountOfFluidToEvaporate*100; + amountOfFluidEvaporated+=amountOfFluidToEvaporate; + int amountOfVapours=amountOfFluidEvaporated*50; + FluidStack coolant = this.waterTank.getFluid(); + if(coolant!=null && coolant.amount>0) + { + int t1 = this.waterTank.getTemperature(); + float densityOfCoolant = IHLFluid.getRealDensity(coolant.getFluid()); + float densityOfGas = 17.8f; + int boilingPointOfGas = IHLFluid.getBoilingPoint(result2.getFluid()); + int amountOfGasToCondense = this.getAmountOfCondensedGas(coolant.amount, amountOfVapours, boilingPointOfGas, t1, densityOfGas, densityOfCoolant); + amountOfGasCondensed += amountOfGasToCondense; + amountOfFluidEvaporated -= amountOfGasToCondense/50; + } + if(amountOfGasCondensed>10000) + { + int amountToProcess=amountOfGasCondensed*this.fluxRecirculationProportion/5000;//only 10% of condensate will be extracted. + int amount = rInputAmount * amountToProcess / result2.amount; + result1.amount = result1.amount* amountToProcess / result2.amount; + result2.amount = amountToProcess; + this.fluidTank.drain(input,amount, true); + this.fillVatResidueOutputApparatus(orientation.getOpposite(), result1, true); + this.fillCondensateOutputApparatus(ForgeDirection.UP, result2, true); + amountOfGasCondensed=0; + } + } + } + if(this.waterTank.getFluid()!=null) + { + FluidStack coolant = this.waterTank.drain(5, true); + this.fillHeatTransferAgentOutputApparatus(ForgeDirection.UP, coolant, true); + } + } + + + private boolean checkHeatSource(ForgeDirection orientation) + { + if(this.heatSource!=null) + { + return true; + } + else + { + TileEntity te = worldObj.getTileEntity(xCoord+orientation.offsetX, yCoord, zCoord+orientation.offsetZ); + if(te instanceof IHeatSource) + { + if(((IHeatSource)te).maxrequestHeatTick(orientation.getOpposite())>0) + { + this.heatSource=(IHeatSource)te; + return true; + } + } + } + return false; + } + + private boolean checkIntegrity() + { + boolean allright=true; + if(!this.listOfColumnSections.isEmpty() && + this.columnCover!=null && + !this.columnCover.isInvalid() && + this.refluxCondenser!=null && + !this.refluxCondenser.isInvalid()) + { + Iterator sectionsIterator = this.listOfColumnSections.iterator(); + while(sectionsIterator.hasNext()) + { + FractionatorSectionTileEntity section = sectionsIterator.next(); + if(section==null || section.isInvalid()) + { + allright=false; + } + } + } + else + { + allright=false; + } + if(allright) + { + return true; + } + else + { + this.listOfColumnSections.clear(); + this.columnCover=null; + this.refluxCondenser=null; + boolean checking = true; + int height=0; + while(checking) + { + height++; + TileEntity te = worldObj.getTileEntity(xCoord, yCoord+height, zCoord); + if(te instanceof FractionatorSectionTileEntity) + { + FractionatorSectionTileEntity section = (FractionatorSectionTileEntity)te; + section.columnBottom=this; + this.listOfColumnSections.add(section); + } + else if(te instanceof FractionatorCoverTileEntity) + { + if(this.listOfColumnSections.isEmpty()) + { + return false; + } + FractionatorCoverTileEntity fcte = (FractionatorCoverTileEntity)te; + this.columnCover=fcte; + ForgeDirection orientation = ForgeDirection.getOrientation(fcte.getFacing()).getRotation(ForgeDirection.DOWN); + te = worldObj.getTileEntity(xCoord+orientation.offsetX, yCoord+height, zCoord+orientation.offsetZ); + if(te instanceof RefluxCondenserTileEntity) + { + if(((RefluxCondenserTileEntity)te).getFacing()==fcte.getFacing()) + { + this.refluxCondenser=(RefluxCondenserTileEntity)te; + this.refluxCondenser.columnBottom=this; + return true; + } + } + } + else + { + checking=false; + } + } + } + return false; + } + + private int getAmountOfCondensedGas(int amountOfCoolant, int amountOfGas, int boilingPointOfGas, int temperatureOfCoolant, float densityOfGas, float densityOfCoolant) + { + if(amountOfCoolant<=0 || amountOfGas<=0 || boilingPointOfGas-202*dt2) + { + deltaT = (float) ((dt1-dt2)/Math.log((double)dt2/(double)dt1)); + } + else + { + deltaT = (dt1+dt2)*0.5F; + } + float Q1 = kF*deltaT; + if(Q1>=maxQ) + { + break; + } + else + { + int next_L = (int)(Q1/H/densityOfGas); + if(Math.abs(next_L-L)<4) + { + L=next_L; + break; + } + L=next_L; + } + } + if(t1_1>t1) + { + this.waterTank.setTemperature(t1_1); + } + else + { + this.waterTank.setTemperature(t1+1); + } + return L; + } + + @Override + public String getInventoryName() + { + return "fractionator"; + } + + public void onGuiClosed(EntityPlayer entityPlayer) {} + + public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) + { + if(direction.equals(ForgeDirection.UP)) + { + return waterTank.fill(fluidStack, doFill); + } + else + { + return fluidTank.fill(fluidStack, doFill); + } + } + + private int fillCondensateOutputApparatus(ForgeDirection direction,FluidStack fluidStack, boolean doFill) + { + TileEntity te = worldObj.getTileEntity(this.refluxCondenser.xCoord,this.refluxCondenser.yCoord-1,this.refluxCondenser.zCoord); + if(te instanceof IFluidHandler) + { + return ((IFluidHandler)te).fill(direction, fluidStack, doFill); + } + else + { + return 0; + } + } + + + private int fillVatResidueOutputApparatus(ForgeDirection orientation, FluidStack fluidStack, boolean doFill) { + TileEntity te = worldObj.getTileEntity(xCoord+orientation.offsetX,yCoord, zCoord+orientation.offsetZ); + if(te instanceof IFluidHandler) + { + return ((IFluidHandler)te).fill(orientation, fluidStack, doFill); + } + else + { + return 0; + } + } + + private int fillHeatTransferAgentOutputApparatus(ForgeDirection direction,FluidStack fluidStack, boolean doFill) + { + ForgeDirection orientation = ForgeDirection.getOrientation(this.refluxCondenser.getFacing()).getOpposite(); + TileEntity te = worldObj.getTileEntity(this.refluxCondenser.xCoord+orientation.offsetX,this.refluxCondenser.yCoord,this.refluxCondenser.zCoord+orientation.offsetZ); + if(te instanceof IFluidHandler) + { + return ((IFluidHandler)te).fill(orientation, fluidStack, doFill); + } + else + { + return 0; + } + } + + @Override + public void setFacing(short facing1) + { + super.setFacing((short) Math.max(facing1, 2)); + } + + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[]{this.fluidTank.getInfo(), this.waterTank.getInfo()}; + } + + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/FractionatorCoverModel.java b/ihl/processing/chemistry/FractionatorCoverModel.java new file mode 100644 index 0000000..451d73c --- /dev/null +++ b/ihl/processing/chemistry/FractionatorCoverModel.java @@ -0,0 +1,52 @@ +// Date: 05.04.2015 1:01:48 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class FractionatorCoverModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorCoverModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.ConeUp14to10", 0, 0); + setTextureOffset("Base.PipeUp", 0, 0); + setTextureOffset("Base.KneeUPWEST", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.ConeUp10To3", 0, 0); + setTextureOffset("Base.WestPipe02", 0, 0); + setTextureOffset("Base.WestPipe01", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -8F, 7F, -8F, 16, 1, 16, .8F, 1F, ForgeDirection.UP); + Base.addTube("ConeUp14to10", -7F, 2F, -7F, 14, 5, 14, .8F, 0.71F, ForgeDirection.DOWN); + Base.addTube("PipeUp", -1.5F, -2.5F, -1.5F, 3, 3, 3, .8F, 1F, ForgeDirection.UP); + Base.addKnee("KneeUPWEST", -3F, -8.5F, -3F, 6, 6, 6, .8F, 1F, ForgeDirection.DOWN, ForgeDirection.WEST); + Base.addTube("WestPipe03", -7F, -7F, -1.5F, 4, 3, 3, .8F, 1F, ForgeDirection.WEST); + Base.addTube("WestPipe04", -8F, -7.5F, -2F, 1, 4, 4, .6F, 1F, ForgeDirection.WEST); + Base.addTube("ConeUp10To3", -5F, 0F, -5F, 10, 2, 10, .8F, 0.3F, ForgeDirection.DOWN); + Base.addTube("WestPipe02", -8F, 3F, -2F, 1, 4, 4, .6F, 1F, ForgeDirection.WEST); + Base.addTube("WestPipe01", -7F, 3.5F, -1.5F, 3, 3, 3, .8F, 1F, ForgeDirection.WEST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/ihl/processing/chemistry/FractionatorCoverTileEntity.java b/ihl/processing/chemistry/FractionatorCoverTileEntity.java new file mode 100644 index 0000000..d7addf2 --- /dev/null +++ b/ihl/processing/chemistry/FractionatorCoverTileEntity.java @@ -0,0 +1,105 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class FractionatorCoverTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{ + + private short facing=2; + private short lastFacing=2; + public FractionatorBottomTileEntity columnBottom; + + public FractionatorCoverTileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("fractionatorCover"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } +} diff --git a/ihl/processing/chemistry/FractionatorSectionModel.java b/ihl/processing/chemistry/FractionatorSectionModel.java new file mode 100644 index 0000000..2a20e7b --- /dev/null +++ b/ihl/processing/chemistry/FractionatorSectionModel.java @@ -0,0 +1,47 @@ +// Date: 05.04.2015 16:59:49 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + + +public class FractionatorSectionModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorSectionModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.Pipeup02", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.PipeUp05", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -8F, 7F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("Pipeup02", -8F, -8F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("WestPipe03", 4.5F, -1.5F, -1.5F, 3, 3, 3, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("WestPipe04", 7F, -2F, -2F, 1, 4, 4, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("PipeUp05", -7F, -7F, -7F, 14, 14, 14, 0.8F, 1.0F, ForgeDirection.UP); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + +} diff --git a/ihl/processing/chemistry/FractionatorSectionTileEntity.java b/ihl/processing/chemistry/FractionatorSectionTileEntity.java new file mode 100644 index 0000000..18314d6 --- /dev/null +++ b/ihl/processing/chemistry/FractionatorSectionTileEntity.java @@ -0,0 +1,146 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class FractionatorSectionTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IFluidHandler{ + + private short facing=2; + private short lastFacing=2; + public FractionatorBottomTileEntity columnBottom; + + public FractionatorSectionTileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("fractionatorSection"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP).equals(direction); + } + + @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 direction, FluidStack fluidStack, boolean doFill) { + if(fluidStack!=null && fluidStack.getFluid()!=null && this.canFill(direction, fluidStack.getFluid()) && columnBottom!=null) + { + return columnBottom.fill(direction, fluidStack, doFill); + } + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) + { + return columnBottom.getTankInfo(arg0); + } + +} diff --git a/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java b/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java new file mode 100644 index 0000000..cbd3239 --- /dev/null +++ b/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java @@ -0,0 +1,76 @@ +package ihl.processing.chemistry; + +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 GaedesMercuryRotaryPumpContainer extends ContainerBase { + + protected GaedesMercuryRotaryPumpTileEntity tileEntity; + private final static int height=166; + public short lastEnergy = -1; + public short lastProgress = -1; + + public GaedesMercuryRotaryPumpContainer(EntityPlayer entityPlayer, GaedesMercuryRotaryPumpTileEntity 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.engine, 0, 61, 36)); + } + + @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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java b/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java new file mode 100644 index 0000000..78f1b0c --- /dev/null +++ b/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java @@ -0,0 +1,69 @@ +package ihl.processing.chemistry; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class GaedesMercuryRotaryPumpGui extends GuiContainer { + + private GaedesMercuryRotaryPumpContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIGaedesMercuryRotaryPump.png"); + + public GaedesMercuryRotaryPumpGui(GaedesMercuryRotaryPumpContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @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(tex); + 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); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(51, 37 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(17, 30, getFrameX(i1), getFrameY(i1),24,24); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 79, 37, xOffset, yOffset); + } + } + + @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(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} diff --git a/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java b/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java new file mode 100644 index 0000000..607d26a --- /dev/null +++ b/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java @@ -0,0 +1,64 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +// Date: 17.03.2015 21:30:34 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +public class GaedesMercuryRotaryPumpModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public GaedesMercuryRotaryPumpModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeN1", 0, 0); + setTextureOffset("Base.PipeU3", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.PipeN2", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape7", 0, 0); + setTextureOffset("Base.PipeU4", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.PipeW5", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape4", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.PipeW8", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeN1", -5F, -5F, -6F, 10, 10, 10,0F,1F,ForgeDirection.NORTH); + Base.addTube("PipeU3", -0.5F, -2.5F, -8F, 1, 2, 1,0.1F,1F,ForgeDirection.UP); + Base.addBox("Shape3", -0.5F, -0.5F, -8F, 1, 1, 2); + Base.addTube("PipeN2", -3F, -2F, 4F, 6, 6, 4,0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape5", -7F, 7F, -6F, 14, 1, 14); + Base.addBox("Shape6", 2F, 1F, -5F, 1, 6, 12); + Base.addBox("Shape7", -3F, 1F, -5F, 1, 6, 12); + Base.addTube("PipeU4", 0F, -8F, -5F, 1, 3, 1,0.1F,1F,ForgeDirection.UP); + Base.addBox("Shape1", 0F, -7F, -5F, 1, 1, 1); + Base.addTube("PipeW5", -1F, -7F, -5F, 8, 1, 1,0.1F,1F,ForgeDirection.WEST); + Base.addBox("Shape2", 4F, -8F, -5F, 1, 2, 1); + Base.addBox("Shape4", 4F, -8F, -1F, 1, 8, 1); + Base.addBox("Shape8", -5F, -8F, -1F, 1, 8, 1); + Base.addTube("PipeW8", -4F, -8F, -1F, 8, 1, 1,0.1F,1F,ForgeDirection.WEST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java b/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java new file mode 100644 index 0000000..3a9b814 --- /dev/null +++ b/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java @@ -0,0 +1,83 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.ContainerBase; +import ihl.interfaces.IWorkspaceElement; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.utils.IHLUtils; + +public class GaedesMercuryRotaryPumpTileEntity extends BasicElectricMotorTileEntity implements IWorkspaceElement{ + + public boolean ready=false; + + public GaedesMercuryRotaryPumpTileEntity() + { + this.isGuiScreenOpened=true; + } + + @Override + public void operate() + { + ready=true; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump"); + } + + @Override + public List[] getInput() + { + return null; + } + + @Override + public boolean canOperate() + { + return !ready; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new GaedesMercuryRotaryPumpGui(new GaedesMercuryRotaryPumpContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new GaedesMercuryRotaryPumpContainer(player, this); + } + + @Override + public boolean canBeUsed() + { + return ready; + } + + @Override + public void use() + { + ready=false; + } + + @Override + public boolean getIsInvalid() + { + return this.isInvalid(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/chemistry/GoldChimneyKneeModel.java b/ihl/processing/chemistry/GoldChimneyKneeModel.java new file mode 100644 index 0000000..f98fe15 --- /dev/null +++ b/ihl/processing/chemistry/GoldChimneyKneeModel.java @@ -0,0 +1,45 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class GoldChimneyKneeModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public GoldChimneyKneeModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 26, 0); + setTextureOffset("Base.Shape2", 0, 17); + setTextureOffset("Base.Shape4", 30, 16); + setTextureOffset("Base.Shape3", 0, 15); + setTextureOffset("Base.Shape5", 11, 12); + setTextureOffset("Base.Shape6", 9, 2); + setTextureOffset("Base.Shape7", 24, 7); + setTextureOffset("Base.Shape8", 50, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 6, 0); + setTextureOffset("Base.Shape11", 18, 0); + setTextureOffset("Base.Pipe", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 23F, -6F); + Base.mirror = true; + Base.addBox("Shape1", 5F, -14F, 0F, 1, 15, 12, false); + Base.addBox("Shape2", -6F, -1F, 0F, 11, 2, 1, false); + Base.addBox("Shape4", 5F, -14F, -2F, 1, 13, 2, false); + Base.addBox("Shape3", -6F, -2F, -2F, 11, 1, 3, false); + Base.addBox("Shape5", -6F, -14F, -2F, 11, 1, 14, false); + Base.addBox("Shape6", -5F, -13F, 11F, 4, 14, 1, false); + Base.addBox("Shape7", -6F, -13F, 1F, 1, 14, 11, false); + Base.addBox("Shape8", -6F, -13F, -2F, 1, 11, 3, false); + Base.addBox("Shape9", 1F, -13F, 11F, 4, 14, 1, false); + Base.addBox("Shape10", -1F, -13F, 11F, 2, 4, 1, false); + Base.addBox("Shape11", -1F, -7F, 11F, 2, 8, 1, false); + Base.addTube("Pipe", -2F, -10F, 2F, 4, 4, 12, 0.5F, 1F,ForgeDirection.NORTH); + } +} diff --git a/ihl/processing/chemistry/GoldChimneyKneeRender.java b/ihl/processing/chemistry/GoldChimneyKneeRender.java new file mode 100644 index 0000000..d862963 --- /dev/null +++ b/ihl/processing/chemistry/GoldChimneyKneeRender.java @@ -0,0 +1,50 @@ +package ihl.processing.chemistry; +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 GoldChimneyKneeRender extends TileEntitySpecialRenderer{ +private GoldChimneyKneeModel model = new GoldChimneyKneeModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/porcelainBox.png"); + +public GoldChimneyKneeRender(){} + +public void renderAModelAt(GoldChimneyKneeTileEntity 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((GoldChimneyKneeTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/GoldChimneyKneeTileEntity.java b/ihl/processing/chemistry/GoldChimneyKneeTileEntity.java new file mode 100644 index 0000000..6c73a5b --- /dev/null +++ b/ihl/processing/chemistry/GoldChimneyKneeTileEntity.java @@ -0,0 +1,293 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class GoldChimneyKneeTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IFluidHandler { + private short facing=2; + private short lastFacing=2; + private final IHLFluidTank gasBuffer = new IHLFluidTank(10000); + private final IHLFluidTank fluidTank = new IHLFluidTank(10000); + private static UniversalRecipeManager recipeManager = new UniversalRecipeManager("chimneyknee"); + + + public GoldChimneyKneeTileEntity() + { + super(); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.facing!=side; + } + + @Override + public short getFacing() + { + return facing; + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(IC2.platform.isSimulating()) + { + if(this.facing!=this.lastFacing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + this.lastFacing=this.facing; + } + if(this.fluidTank.getFluid()!=null && this.gasBuffer.getFluid()!=null) + { + if(this.getOutput()!=null) + { + List output = GoldChimneyKneeTileEntity.recipeManager.getOutputFor(getInput(), true, true).getFluidOutputs(); + if(output.size()>0) + { + this.fillOutputApparatus(getConnectDirection(),output.get(0), true); + } + } + } + if(this.fluidTank.getFluid()!=null) + { + if(this.fillOutputApparatus(getConnectDirection(),this.fluidTank.drain(this.fluidTank.getCapacity(), false), false)>0) + { + this.fillOutputApparatus(getConnectDirection(),this.fluidTank.drain(this.fluidTank.getCapacity(), true), true); + } + } + if(this.gasBuffer.getFluid()!=null) + { + if(this.fillOutputApparatus(getConnectDirection(),this.gasBuffer.drain(this.gasBuffer.getCapacity(), false), false)>0) + { + this.fillOutputApparatus(getConnectDirection(),this.gasBuffer.drain(this.gasBuffer.getCapacity(), true), true); + } + } + + } + } + + private int fillOutputApparatus(ForgeDirection direction,FluidStack fluidStack, boolean doFill) + { + TileEntity te = worldObj.getTileEntity(xCoord+mX(),yCoord, zCoord+mZ()); + if(te instanceof IFluidHandler) + { + return ((IFluidHandler)te).fill(direction, fluidStack, doFill); + } + else + { + return 0; + } + } + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } + + @Override + public float getWrenchDropRate() + { + return 1F; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return IHLUtils.getThisModItemStack("goldChimneyKnee"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing",facing); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + + NBTTagCompound gasBufferTag = new NBTTagCompound(); + this.gasBuffer.writeToNBT(gasBufferTag); + nbttagcompound.setTag("gasBuffer", gasBufferTag); + + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.gasBuffer.readFromNBT(nbttagcompound.getCompoundTag("gasBuffer")); + } + + protected int mX() + { + switch(this.getFacing()) + { + case 4: + return 1; + case 5: + return -1; + default: + return 0; + } + } + + protected int mZ() + { + switch(this.getFacing()) + { + case 2: + return 1; + case 3: + return -1; + default: + return 0; + } + } + + public TileEntity getConnectedTileEntity() + { + return worldObj.getTileEntity(xCoord+mX(), yCoord, zCoord+mZ()); + } + + public ForgeDirection getConnectDirection() + { + switch(this.getFacing()) + { + case 2: + return ForgeDirection.NORTH; + case 3: + return ForgeDirection.SOUTH; + case 4: + return ForgeDirection.WEST; + case 5: + return ForgeDirection.EAST; + default: + return ForgeDirection.NORTH; + } + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) + { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid fluid) + { + return fluid.isGaseous() && (direction==ForgeDirection.DOWN || direction==getConnectDirection()); + } + + @Override + public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) + { + if(direction==getConnectDirection() && fluidStack!=null && fluidStack.getFluid()!=null) + { + if(fluidStack.getFluid().isGaseous() && fluidStack.getFluid().getDensity() getRecipes() + { + return recipeManager.getRecipes(); + } +} diff --git a/ihl/processing/chemistry/LabElectrolyzerContainer.java b/ihl/processing/chemistry/LabElectrolyzerContainer.java new file mode 100644 index 0000000..5ee9caf --- /dev/null +++ b/ihl/processing/chemistry/LabElectrolyzerContainer.java @@ -0,0 +1,133 @@ +package ihl.processing.chemistry; + +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; +import net.minecraftforge.fluids.FluidStack; + +public class LabElectrolyzerContainer extends ContainerBase { + + protected LabElectrolyzerTileEntity tileEntity; + public short lastProgress = -1; + public short lastTemperature = -1; + public short lastEnergy = -1; + private final static int height=166; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public int lastFluidAmount2 = -1; + public int lastNumberOfFluids2 = -1; + public int lastFluidAmount3 = -1; + public int lastNumberOfFluids3 = -1; + public List fluidTankFluidList; + public List fluidTankFluidList2; + public List fluidTankFluidList3; + + public LabElectrolyzerContainer(EntityPlayer entityPlayer, LabElectrolyzerTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList(); + fluidTankFluidList2 = this.tileEntity.fluidTankAnodeOutput.getFluidList(); + fluidTankFluidList3 = this.tileEntity.fluidTankCathodeOutput.getFluidList(); + 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.fillInputSlot, 0, 42, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlotAnodeOutput, 0, 106, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlotCathodeOutput, 0, 8, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 42, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 8, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 1, 42, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 2, 106, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 87, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 152, 15)); + } + + @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.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.fluidTankAnodeOutput.getFluidAmount() != this.lastFluidAmount2 || this.tileEntity.fluidTankAnodeOutput.getNumberOfFluids() != this.lastNumberOfFluids2) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList2"); + } + + if (this.tileEntity.fluidTankCathodeOutput.getFluidAmount() != this.lastFluidAmount3 || this.tileEntity.fluidTankCathodeOutput.getNumberOfFluids() != this.lastNumberOfFluids3) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList3"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + + + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastEnergy = (short) this.tileEntity.energy; + this.lastNumberOfFluids2 = this.tileEntity.fluidTankAnodeOutput.getNumberOfFluids(); + this.lastFluidAmount2 = this.tileEntity.fluidTankAnodeOutput.getFluidAmount(); + this.lastNumberOfFluids3 = this.tileEntity.fluidTankCathodeOutput.getNumberOfFluids(); + this.lastFluidAmount3 = this.tileEntity.fluidTankCathodeOutput.getFluidAmount(); + + } + + @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.temperature=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/LabElectrolyzerGui.java b/ihl/processing/chemistry/LabElectrolyzerGui.java new file mode 100644 index 0000000..c5997ca --- /dev/null +++ b/ihl/processing/chemistry/LabElectrolyzerGui.java @@ -0,0 +1,83 @@ +package ihl.processing.chemistry; + +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 LabElectrolyzerGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUILabElectrolyzer.png"); + private LabElectrolyzerContainer container; + private int mixerFrame=0; + + public LabElectrolyzerGui (LabElectrolyzerContainer 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); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(142, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(142, 38, getFrameX(i1), getFrameY(i1),24,24); + } + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 61, 19, 84, 67, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.fluidTankCathodeOutput.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankCathodeOutput, 27, 28, 39, 67, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.fluidTankAnodeOutput.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankAnodeOutput, 125, 28, 137, 67, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(background); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 170, 16, xOffset, yOffset); + } + } + + @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); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/LabElectrolyzerTileEntity.java b/ihl/processing/chemistry/LabElectrolyzerTileEntity.java new file mode 100644 index 0000000..cde3e39 --- /dev/null +++ b/ihl/processing/chemistry/LabElectrolyzerTileEntity.java @@ -0,0 +1,298 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class LabElectrolyzerTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("labelectrolyzer"); + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlotAnodeOutput; + public final InvSlotConsumableLiquidIHL fillInputSlotCathodeOutput; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(2000); + public final IHLFluidTank fluidTankAnodeOutput = new IHLFluidTank(8000); + public final IHLFluidTank fluidTankCathodeOutput = new IHLFluidTank(8000); + public short temperature=20; + + public LabElectrolyzerTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.fillInputSlotAnodeOutput = new InvSlotConsumableLiquidIHL(this, "fillInputAnodeOutput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.fillInputSlotCathodeOutput = new InvSlotConsumableLiquidIHL(this, "fillInputCathodeOutput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 3); + this.isGuiScreenOpened=true; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.fluidTankAnodeOutput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankAnodeOutput")); + this.fluidTankCathodeOutput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankCathodeOutput")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + + NBTTagCompound fluidTankAnodeTag = new NBTTagCompound(); + this.fluidTankAnodeOutput.writeToNBT(fluidTankAnodeTag); + nbttagcompound.setTag("fluidTankAnodeOutput", fluidTankAnodeTag); + + NBTTagCompound fluidTankCathodeTag = new NBTTagCompound(); + this.fluidTankCathodeOutput.writeToNBT(fluidTankCathodeTag); + nbttagcompound.setTag("fluidTankCathodeOutput", fluidTankCathodeTag); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("labElectrolyzer"); + } + + @Override + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotAnodeOutput, null, emptyFluidItemsSlot, fluidTankAnodeOutput); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotCathodeOutput, null, emptyFluidItemsSlot, fluidTankCathodeOutput); + } + + @Override + public FluidStack drain(ForgeDirection direction, int amount, boolean doDrain) + { + if(this.canDrain(direction, null)) + { + if(direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP))) + { + return this.fluidTankAnodeOutput.drain(amount, doDrain); + } + if(direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.DOWN))) + { + return this.fluidTankCathodeOutput.drain(amount, doDrain); + } + return this.fluidTank.drain(amount, doDrain); + } + return null; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP))||direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.DOWN))||direction.equals(ForgeDirection.DOWN); + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite()); + } + + @Override + public String getInventoryName() { + return "labElectrolizer"; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + // TODO Auto-generated method stub + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new LabElectrolyzerGui(new LabElectrolyzerContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new LabElectrolyzerContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = getOutput(); + if(output!=null) + { + if(getOutput().getItemOutputs()!=null && !getOutput().getItemOutputs().isEmpty() && getOutput().getItemOutputs().get(0)!=null) + { + return this.outputSlot.canAdd(getOutput().getItemOutputs()); + } + else + { + return this.fluidTankAnodeOutput.getFluidAmount()0)this.fluidTankAnodeOutput.fill(output1.getFluidOutputs().get(0).copy(), true); + if(output1.getFluidOutputs().size()>1)this.fluidTankCathodeOutput.fill(output1.getFluidOutputs().get(1).copy(), true); + if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs()); + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if(this.fluidTankAnodeOutput.getFluid().containsFluid(fluidStack)) + { + return this.fluidTankAnodeOutput.drain(fluidStack.amount, doDrain); + } + if(this.fluidTankCathodeOutput.getFluid().containsFluid(fluidStack)) + { + return this.fluidTankCathodeOutput.drain(fluidStack.amount, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.fluidTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.fluidTank.getInfo()}; + } + + public boolean needsFluid() + { + return this.fluidTank.getFluidAmount() <= this.fluidTank.getCapacity(); + } + + public FluidStack getFluidStackfromTank() + { + return this.fluidTank.getFluid(); + } + + public int getTankAmount() + { + return this.fluidTank.getFluidAmount(); + } + + public int gaugeLiquidScaled(int i, int index) + { + return this.fluidTank.getFluidAmount() <= 0 ? 0 : this.fluidTank.getFluidAmount(index) * i / this.fluidTank.getCapacity(); + } + public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + public int getNumberOfFluidsInTank() + { + return this.fluidTank.getNumberOfFluids(); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(FluidStack fluidStackInput1, FluidStack fluidStackOutputAnode, FluidStack fluidStackOutputCathode, ItemStack itemStackOutput1) + { + if(itemStackOutput1!=null) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutputAnode, fluidStackOutputCathode}), Arrays.asList(new ItemStack[] {itemStackOutput1}),200)); + } + else + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutputAnode, fluidStackOutputCathode}), null,200)); + } + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/LeadOvenContainer.java b/ihl/processing/chemistry/LeadOvenContainer.java new file mode 100644 index 0000000..aa0eafc --- /dev/null +++ b/ihl/processing/chemistry/LeadOvenContainer.java @@ -0,0 +1,80 @@ +package ihl.processing.chemistry; + +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 LeadOvenContainer extends ContainerBase { + + protected LeadOvenTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastFuel = -1; + public short lastProgress = -1; + private final static int height=166; + + public LeadOvenContainer(EntityPlayer entityPlayer, LeadOvenTileEntity 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.fuelSlot, 0, 56, 53)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, 0, 47, 17)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, 1, 65, 17)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 112, 35)); + } + + @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.fuel != this.lastFuel) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.fuel); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.progress); + } + } + this.lastFuel = this.tileEntity.fuel; + this.lastProgress = this.tileEntity.progress; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.fuel=value; + break; + case 1: + this.tileEntity.progress=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/LeadOvenGui.java b/ihl/processing/chemistry/LeadOvenGui.java new file mode 100644 index 0000000..133cb4e --- /dev/null +++ b/ihl/processing/chemistry/LeadOvenGui.java @@ -0,0 +1,51 @@ +package ihl.processing.chemistry; + +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 LeadOvenGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUILeadOven.png"); + private LeadOvenContainer container; + private String title = StatCollector.translateToLocal("ihl.gui.leadOven"); + + + public LeadOvenGui (LeadOvenContainer 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); + } + + @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); + int i1; + if (this.container.tileEntity.fuel > 0) + { + i1 = this.container.tileEntity.gaugeFuelScaled(12); + this.drawTexturedModalRect(x + 56, y + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + i1 = this.container.tileEntity.gaugeProgressScaled(24); + this.drawTexturedModalRect(x + 79, y + 34, 176, 14, i1 + 1, 16); + + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/LeadOvenTileEntity.java b/ihl/processing/chemistry/LeadOvenTileEntity.java new file mode 100644 index 0000000..01f69bf --- /dev/null +++ b/ihl/processing/chemistry/LeadOvenTileEntity.java @@ -0,0 +1,343 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.api.recipe.IRecipeInput; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityLiquidTankInventory; +import ic2.core.block.invslot.InvSlotConsumableFuel; +import ic2.core.block.invslot.InvSlot.Access; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; + +public class LeadOvenTileEntity extends TileEntityLiquidTankInventory implements IHasGui +{ + public final InvSlotConsumableFuel fuelSlot; + public final ApparatusProcessableInvSlot inputSlot; + public final IHLInvSlotOutput outputSlot; + public short progress = 0; + public final short maxProgress = 160; + public int fuel = 0; + public int maxFuel = 0; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("chemicaloven"); + private ItemStack burnedFuel; + + public LeadOvenTileEntity() + { + super(1000); + this.fuelSlot = new InvSlotConsumableFuel(this, "fuel", 1, 1, true); + this.inputSlot = new ApparatusProcessableInvSlot(this, "input", 2, Access.IO, 2, 64); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1); + } + + public static void addRecipe(UniversalRecipeInput input,UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + + try + { + this.fuel = nbttagcompound.getInteger("fuel"); + } + catch (Throwable var4) + { + this.fuel = nbttagcompound.getShort("fuel"); + } + + try + { + this.maxFuel = nbttagcompound.getInteger("maxFuel"); + } + catch (Throwable var3) + { + this.maxFuel = nbttagcompound.getShort("maxFuel"); + } + this.progress = nbttagcompound.getShort("progress"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setInteger("fuel", this.fuel); + nbttagcompound.setInteger("maxFuel", this.maxFuel); + nbttagcompound.setShort("progress", this.progress); + NBTTagCompound gasBufferTag = new NBTTagCompound(); + nbttagcompound.setTag("gasBuffer", gasBufferTag); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return IHLUtils.getThisModItemStack("leadOven"); + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / maxProgress; + } + + public int gaugeFuelScaled(int i) + { + if (this.maxFuel == 0) + { + this.maxFuel = this.fuel; + + if (this.maxFuel == 0) + { + this.maxFuel = 160; + } + } + + return this.fuel * i / this.maxFuel; + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(this.getFluidTank().getFluid()!=null) + { + FluidStack fs; + if(this.maxProgress>0 && this.getOutput()!=null && this.getOutput().getFluidOutputs()!=null && this.getOutput().getFluidOutputs().size()>0) + { + fs = this.getFluidTank().drain(this.getOutput().getFluidOutputs().get(0).amount/this.maxProgress, true); + } + else + { + fs = this.getFluidTank().drain(1000, true); + } + TileEntity te = worldObj.getTileEntity(xCoord, yCoord+1, zCoord); + if(te!=null) + { + ForgeDirection direction = ForgeDirection.DOWN; + if(te instanceof IFluidHandler) + { + ((IFluidHandler)te).fill(direction, fs, true); + } + } + } + boolean needsInvUpdate = false; + if (this.fuel <= 0 && this.canOperate()) + { + if(this.fuelSlot.get()!=null) + { + if(burnedFuel!=null && IHLUtils.isItemsHaveSameOreDictionaryEntry(this.fuelSlot.get(), burnedFuel)) + { + burnedFuel.stackSize++; + } + else if(burnedFuel==null) + { + burnedFuel=this.fuelSlot.get().copy(); + burnedFuel.stackSize=1; + } + } + this.fuel = this.maxFuel = this.fuelSlot.consumeFuel(); + + if (this.fuel > 0) + { + needsInvUpdate = true; + } + } + + if (this.isBurning() && this.canOperate()) + { + ++this.progress; + + if (this.progress >= maxProgress) + { + this.progress = 0; + this.operate(); + needsInvUpdate = true; + } + } + else + { + this.progress = 0; + } + + if (this.fuel > 0) + { + --this.fuel; + } + + if (this.getActive() != this.isBurning()) + { + this.setActive(this.isBurning()); + needsInvUpdate = true; + } + } + + public boolean isBurning() + { + return this.fuel > 0; + } + + public boolean canOperate() + { + return this.getOutput()!=null; + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + return "goldOven"; + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer entityPlayer) + { + return new LeadOvenContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new LeadOvenGui(new LeadOvenContainer(entityPlayer, this)); + } + + @Override + public void onGuiClosed(EntityPlayer entityPlayer) {} + + public int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + public int mZ() + { + switch(this.getFacing()) + { + case 2: + return -1; + case 3: + return 1; + default: + return 0; + } + } + + public UniversalRecipeOutput getOutput() + { + return LeadOvenTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + public List[] getInput() + { + if(this.inputSlot.get(1)!=null) + { + return new List[] {null, Arrays.asList(new ItemStack[] {this.inputSlot.get(0),this.inputSlot.get(1)})}; + } + return new List[] {null, Arrays.asList(new ItemStack[] {this.inputSlot.get()})}; + } + + public void operate() + { + List rinput = LeadOvenTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + UniversalRecipeOutput routput = LeadOvenTileEntity.recipeManager.getOutputFor(getInput(), false, false); + List output2 = routput.getFluidOutputs(); + if(!output2.isEmpty()) + { + this.getFluidTank().fill(output2.get(0), true); + } + List itemOutputs = routput.getItemOutputs(); + if(itemOutputs!=null && !itemOutputs.isEmpty()) + { + this.outputSlot.add(itemOutputs); + } + for(int i=0; i=rinput.get(i).getAmount()) + { + this.burnedFuel.stackSize-=rinput.get(i).getAmount(); + if(this.burnedFuel.stackSize<=0) + { + this.burnedFuel=null; + } + } + else + { + this.inputSlot.consume(i, rinput.get(i).getAmount()); + } + if(this.inputSlot.get(i)!=null && this.inputSlot.get(i).stackSize<=0) + { + this.inputSlot.put(i, null); + } + } + + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection arg0, Fluid arg1) { + return false; + } + + public static void addRecipe(UniversalRecipeInput input, FluidStack fluidStackWithSize) + { + recipeManager.addRecipe(input, new UniversalRecipeOutput(Arrays.asList(new FluidStack[]{fluidStackWithSize}),null,20)); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(ItemStack input, FluidStack fluidStackOutput, ItemStack output) { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {input})),new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}),Arrays.asList(new ItemStack[] {output}),20)); + } + + public static void addRecipe(ItemStack input, ItemStack output) { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {input})),new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output}),20)); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/LoomContainer.java b/ihl/processing/chemistry/LoomContainer.java new file mode 100644 index 0000000..4b8e182 --- /dev/null +++ b/ihl/processing/chemistry/LoomContainer.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry; + +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 LoomContainer extends ContainerBase { + + public LoomTileEntity tileEntity; + public int lastProgress = -1; + private final static int height=166; + + public LoomContainer(EntityPlayer entityPlayer, + LoomTileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + 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(lathePart1TileEntity.input, 0, 8, 44)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.output, 0, 127, 44)); + } + + @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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + } + this.lastProgress = this.tileEntity.progress; + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + + } + } + +} diff --git a/ihl/processing/chemistry/LoomGui.java b/ihl/processing/chemistry/LoomGui.java new file mode 100644 index 0000000..1052252 --- /dev/null +++ b/ihl/processing/chemistry/LoomGui.java @@ -0,0 +1,61 @@ +package ihl.processing.chemistry; + +import org.lwjgl.opengl.GL11; + +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class LoomGui extends GuiContainer { + + private LoomContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUILoom.png"); + + public LoomGui(LoomContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @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(tex); + int i1; + if (this.container.tileEntity.progress > 0) + { + 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.99F); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(38),38); + this.drawTexturedModalRect(68, 30, 176, 0, i1 + 1, 10); + } + IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.coiler.tip")); + } + + @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(tex); + 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; + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 0); + } + +} diff --git a/ihl/processing/chemistry/LoomModel.java b/ihl/processing/chemistry/LoomModel.java new file mode 100644 index 0000000..afef73d --- /dev/null +++ b/ihl/processing/chemistry/LoomModel.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class LoomModel extends ModelBase +{ + //fields + IHLModelRenderer RotatePart; + IHLModelRenderer Piece1; + + public LoomModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("RotatePart.Shape1", 0, 14); + setTextureOffset("RotatePart.Pipe2", 0, 17); + setTextureOffset("RotatePart.Shape4", 3, 14); + setTextureOffset("RotatePart.Shape3", 0, 26); + setTextureOffset("RotatePart.Pipe5", 16, 20); + setTextureOffset("RotatePart.Pipe6", 0, 18); + setTextureOffset("RotatePart.Pipe11", 13, 22); + setTextureOffset("RotatePart.Pipe12", 13, 22); + setTextureOffset("RotatePart.Pipe13", 13, 22); + setTextureOffset("RotatePart.Pipe14", 13, 22); + setTextureOffset("RotatePart.Pipe15", 13, 22); + setTextureOffset("Piece1.Shape7", 0, 17); + setTextureOffset("Piece1.Shape8", 0, 17); + setTextureOffset("Piece1.PipeW9", 0, 18); + setTextureOffset("Piece1.PipeW10", 0, 20); + setTextureOffset("Piece1.Shape2", 0, 0); + + RotatePart = new IHLModelRenderer(this, "RotatePart"); + RotatePart.setRotationPoint(0F, 23F, -6F); + setRotation(RotatePart, 0.4F, 0F, 0F); + RotatePart.mirror = true; + RotatePart.addBox("Shape1", 7F, -1F, -1F, 1, 2, 16,false); + RotatePart.addTube("Pipe2", -7.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addBox("Shape4", -8F, -1F, -1F, 1, 2, 16,false); + RotatePart.addBox("Shape3", -7F, -1F, -1F, 14, 2, 2,false); + RotatePart.addTube("Pipe5", -5.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe6", -3.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe11", -1.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe12", 0.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe13", 2.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe14", 4.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe15", 6.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + Piece1 = new IHLModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = true; + Piece1.addBox("Shape7", 6F, -4F, 6F, 1, 12, 2,false); + Piece1.addBox("Shape8", -7F, -4F, 6F, 1, 12, 2,false); + Piece1.addTube("PipeW9", -6F, 7F, 7F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addTube("PipeW10", -6F, -4F, 6F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addBox("Shape2", 0F, 7F, 0F, 4, 1, 1,false); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/ihl/processing/chemistry/LoomTileEntity.java b/ihl/processing/chemistry/LoomTileEntity.java new file mode 100644 index 0000000..df5ce20 --- /dev/null +++ b/ihl/processing/chemistry/LoomTileEntity.java @@ -0,0 +1,173 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.api.recipe.IRecipeInput; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeInputWire; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class LoomTileEntity extends TileEntityInventory implements IHasGui, INetworkClientTileEntityEventListener +{ + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("loom"); + public short progress; + protected short operationLength=200; + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + boolean isGuiScreenOpened=false; + + public LoomTileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 1, 64); + output = new IHLInvSlotOutput(this, "output", 1, 1); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if (this.canOperate() && this.isGuiScreenOpened) + { + this.setActive(true); + + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + if (this.progress >= this.operationLength) + { + this.operate(); + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + @Override + public String getInventoryName() { + return "Loom"; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("loom"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new LoomGui(new LoomContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + this.isGuiScreenOpened=true; + return new LoomContainer(player, this); + } + + public void operate() + { + List input1 = LoomTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + List output1 = LoomTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + this.output.add(output1); + if(input1.get(0) instanceof RecipeInputWire) + { + int fiberLength = input1.get(0).getAmount(); + boolean isFiberConsumed = IHLUtils.adjustWireLength(this.input.get(), -fiberLength); + if(isFiberConsumed) + { + this.input.put(null); + } + } + else + { + this.input.consume(0, input1.get(0).getAmount()); + } + } + + public List[] getInput() + { + return new List[] {null,Arrays.asList(new ItemStack[] {input.get()})}; + } + + public boolean canOperate() + { + if(LoomTileEntity.recipeManager.getOutputFor(getInput(), false, false)==null) return false; + List output1 = LoomTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + return this.output.canAdd(output1); + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public static void addRecipe(ItemStack input, ItemStack output) + { + if(input==null || output==null) throw new NullPointerException(); + recipeManager.addRecipe(new UniversalRecipeInput(null,Arrays.asList(new ItemStack[] {input})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {output}),20)); + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / this.operationLength; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + switch(event) + { + case 0: + this.isGuiScreenOpened=false; + break; + } + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/chemistry/PaperMachineContainer.java b/ihl/processing/chemistry/PaperMachineContainer.java new file mode 100644 index 0000000..99bfa61 --- /dev/null +++ b/ihl/processing/chemistry/PaperMachineContainer.java @@ -0,0 +1,106 @@ +package ihl.processing.chemistry; + +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; +import net.minecraftforge.fluids.FluidStack; + +public class PaperMachineContainer extends ContainerBase { + + protected PaperMachineTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public short lastTemperature = -1; + public short lastEnergy = -1; + private final static int height=166; + public List fluidTankFluidList; + + public PaperMachineContainer(EntityPlayer entityPlayer, PaperMachineTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList=this.tileEntity.getFluidTank().getFluidList(); + 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.fillInputSlot, 0, 78, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 78, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 78, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 122, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 8, 32)); + } + + @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.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + + + if ((short) this.tileEntity.energy != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @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.temperature=(short) value; + break; + case 2: + this.tileEntity.energy=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/PaperMachineGui.java b/ihl/processing/chemistry/PaperMachineGui.java new file mode 100644 index 0000000..4c8cb72 --- /dev/null +++ b/ihl/processing/chemistry/PaperMachineGui.java @@ -0,0 +1,84 @@ +package ihl.processing.chemistry; + +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 PaperMachineGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIPaperMachine.png"); + private PaperMachineContainer container; + private int mixerFrame=0; + + public PaperMachineGui (PaperMachineContainer 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); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(12, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(38, 29, getFrameX(i1), getFrameY(i1),24,24); + if(mixerFrame++>4) + { + mixerFrame=0; + } + } + else + { + mixerFrame=0; + } + this.drawTexturedModalRect(103, 52, 246, 226+6*mixerFrame,10,6); + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 102, 28, 114, 59, zLevel, par1, par2, xOffset, yOffset); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(background); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 34, xOffset, yOffset); + } + } + + @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); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/PaperMachineTileEntity.java b/ihl/processing/chemistry/PaperMachineTileEntity.java new file mode 100644 index 0000000..a694b82 --- /dev/null +++ b/ihl/processing/chemistry/PaperMachineTileEntity.java @@ -0,0 +1,320 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class PaperMachineTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("papermachine"); + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public short temperature=20; + private int fractionalOutputAmount=0; + + public PaperMachineTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.isGuiScreenOpened=true; + } + + @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); + NBTTagCompound fractionalOutputNBT = new NBTTagCompound(); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("paperMachine"); + } + + @Override + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + FluidStack fstack = this.fluidTank.drain(amount, doDrain); + return fstack; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.UP); + } + + @Override + public String getInventoryName() { + return "chemicalReactor"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + public float getRenderLiquidLevel() + { + return (float)this.fluidTank.getFluidAmount()/(float)this.fluidTank.getCapacity(); + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + // TODO Auto-generated method stub + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new PaperMachineGui(new PaperMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new PaperMachineContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = getOutput(); + if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs())) + { + if(output.specialConditions) + { + return this.checkSpecialConditions(); + } + else + { + return true; + } + } + return false; + } + + private boolean checkSpecialConditions() + { + ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ); + if(te instanceof CryogenicDistillerTileEntity) + { + CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te; + return cgte.getFacing()==this.getFacing() && cgte.canProcess(); + } + return false; + } + + public UniversalRecipeOutput getOutput() + { + return PaperMachineTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List[] getInput() + { + return new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid()}), null}; + } + + @Override + public void operate() + { + UniversalRecipeInput recipeInput = PaperMachineTileEntity.recipeManager.getRecipeInput(getInput()); + UniversalRecipeOutput output1 = getOutput(); + this.fluidTank.drain(recipeInput.getFluidInputs(), true); + this.fluidTank.fill(output1.getFluidOutputs(), true); + if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs()); + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if(fluidTank.getFluid()!=null && fluidTank.getFluid().containsFluid(fluidStack)) + { + return this.fluidTank.drain(fluidStack, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.fluidTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.fluidTank.getInfo()}; + } + + public boolean needsFluid() + { + return this.fluidTank.getFluidAmount() <= this.fluidTank.getCapacity(); + } + + public FluidStack getFluidStackfromTank() + { + return this.fluidTank.getFluid(); + } + + public int getTankAmount() + { + return this.fluidTank.getFluidAmount(); + } + + public int gaugeLiquidScaled(int i, int index) + { + return this.fluidTank.getFluidAmount() <= 0 ? 0 : this.fluidTank.getFluidAmount(index) * i / this.fluidTank.getCapacity(); + } + public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + public int getNumberOfFluidsInTank() + { + return this.fluidTank.getNumberOfFluids(); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackOutput1) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1}), null), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {itemStackOutput1}),200)); + } + + public static void addSpecialConditionsRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {fluidStackInput1, fluidStackInput2}), Arrays.asList(new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStackOutput}), Arrays.asList(new ItemStack[] {itemStackOutput1, itemStackOutput2}),200, true)); + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/PrecipitatorCondenserModel.java b/ihl/processing/chemistry/PrecipitatorCondenserModel.java new file mode 100644 index 0000000..dd6f15a --- /dev/null +++ b/ihl/processing/chemistry/PrecipitatorCondenserModel.java @@ -0,0 +1,110 @@ +package ihl.processing.chemistry; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +public class PrecipitatorCondenserModel extends ModelBase +{ + //fields + ModelRenderer Base; + + public PrecipitatorCondenserModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 22, 0); + setTextureOffset("Base.Shape2", 22, 17); + setTextureOffset("Base.Shape4", 30, 16); + setTextureOffset("Base.Shape3", 30, 15); + setTextureOffset("Base.Shape6", 30, 2); + setTextureOffset("Base.Shape7", 20, 0); + setTextureOffset("Base.Shape8", 50, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 24, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape12", 0, 0); + setTextureOffset("Base.Shape13", 0, 0); + setTextureOffset("Base.Shape14", 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.Shape25", 0, 1); + setTextureOffset("Base.Shape26", 12, 24); + setTextureOffset("Base.Shape27", 0, 0); + setTextureOffset("Base.Shape28", 0, 18); + setTextureOffset("Base.Shape29", 21, 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("Base.Shape37", 0, 0); + setTextureOffset("Base.Shape38", 0, 0); + setTextureOffset("Base.Shape39", 0, 0); + setTextureOffset("Base.Shape40", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape23", 31, 0); + setTextureOffset("Base.Shape24", 10, 0); + setTextureOffset("Base.Shape41", 27, 26); + setTextureOffset("Base.Shape42", 0, 0); + setTextureOffset("Base.Shape43", 0, 0); + setTextureOffset("Base.Shape44", 0, 0); + setTextureOffset("Base.Shape45", 0, 0); + setTextureOffset("Base.Shape46", 0, 0); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 23F, 0F); + Base.mirror = true; + Base.addBox("Shape1", 6F, -15F, -7F, 1, 12, 14); + Base.addBox("Shape2", -7F, -3F, -8F, 14, 3, 1); + Base.addBox("Shape4", 6F, -15F, -8F, 1, 12, 1); + Base.addBox("Shape3", -7F, -3F, 7F, 14, 3, 1); + Base.addBox("Shape6", -7F, -15F, 7F, 1, 12, 1); + Base.addBox("Shape7", -7F, -15F, -7F, 1, 15, 14); + Base.addBox("Shape8", -7F, -15F, -8F, 1, 12, 1); + Base.addBox("Shape9", 1F, 0F, -8F, 6, 1, 16); + Base.addBox("Shape10", 6F, -15F, 7F, 1, 12, 1); + Base.addBox("Shape11", -4F, -13F, 3F, 1, 12, 3); + Base.addBox("Shape12", 4F, -2F, -1F, 2, 1, 3); + Base.addBox("Shape13", 3F, -13F, -1F, 1, 12, 3); + Base.addBox("Shape14", -3F, -13F, 5F, 9, 12, 1); + Base.addBox("Shape15", -6F, -2F, -2F, 12, 1, 1); + Base.addBox("Shape16", -4F, -13F, -5F, 1, 12, 3); + Base.addBox("Shape17", -6F, -2F, 6F, 12, 1, 1); + Base.addBox("Shape18", -6F, -2F, -7F, 12, 1, 2); + Base.addBox("Shape19", -6F, -2F, -5F, 2, 1, 3); + Base.addBox("Shape20", -6F, -2F, 2F, 12, 1, 1); + Base.addBox("Shape21", -6F, -2F, 3F, 2, 1, 3); + Base.addBox("Shape25", -6F, -15F, 7F, 12, 3, 1); + Base.addBox("Shape26", -6F, -15F, -8F, 12, 3, 1); + Base.addBox("Shape27", -8F, 0F, -8F, 7, 1, 16); + Base.addBox("Shape28", -1F, 0F, 1F, 2, 1, 7); + Base.addBox("Shape29", -1F, 0F, -8F, 2, 1, 7); + Base.addBox("Shape30", -3F, -13F, 3F, 9, 12, 1); + Base.addBox("Shape31", -6F, -13F, 1F, 9, 12, 1); + Base.addBox("Shape32", -6F, -13F, -1F, 9, 12, 1); + Base.addBox("Shape33", -3F, -13F, -3F, 9, 12, 1); + Base.addBox("Shape34", -3F, -13F, -5F, 9, 12, 1); + Base.addBox("Shape35", -6F, -13F, -7F, 12, 1, 2); + Base.addBox("Shape36", -6F, -13F, -2F, 12, 1, 1); + Base.addBox("Shape37", -6F, -13F, 2F, 12, 1, 1); + Base.addBox("Shape38", -6F, -13F, 6F, 12, 1, 1); + Base.addBox("Shape39", -6F, -13F, -5F, 2, 1, 3); + Base.addBox("Shape40", -6F, -13F, 3F, 2, 1, 3); + Base.addBox("Shape5", 4F, -13F, -1F, 2, 1, 3); + Base.addBox("Shape23", 6F, -2F, -7F, 1, 2, 14); + Base.addBox("Shape24", 6F, -3F, 3F, 1, 1, 4); + Base.addBox("Shape41", 6F, -3F, -7F, 1, 1, 5); + Base.addBox("Shape42", 7F, -4F, -2F, 4, 1, 5); + Base.addBox("Shape43", 8F, 0F, -2F, 1, 1, 5); + Base.addBox("Shape44", 10F, -3F, -2F, 1, 4, 5); + Base.addBox("Shape45", 7F, -4F, 3F, 4, 5, 1); + Base.addBox("Shape46", 7F, -4F, -3F, 4, 5, 1); + } +} diff --git a/ihl/processing/chemistry/PrecipitatorCondenserRender.java b/ihl/processing/chemistry/PrecipitatorCondenserRender.java new file mode 100644 index 0000000..ae68bbf --- /dev/null +++ b/ihl/processing/chemistry/PrecipitatorCondenserRender.java @@ -0,0 +1,50 @@ +package ihl.processing.chemistry; +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 PrecipitatorCondenserRender extends TileEntitySpecialRenderer{ +private PrecipitatorCondenserModel model = new PrecipitatorCondenserModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/porcelainBox.png"); + +public PrecipitatorCondenserRender(){} + +public void renderAModelAt(PrecipitatorCondenserTileEntity 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((PrecipitatorCondenserTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/PrecipitatorCondenserTileEntity.java b/ihl/processing/chemistry/PrecipitatorCondenserTileEntity.java new file mode 100644 index 0000000..becd7e8 --- /dev/null +++ b/ihl/processing/chemistry/PrecipitatorCondenserTileEntity.java @@ -0,0 +1,380 @@ +package ihl.processing.chemistry; + +import java.util.Arrays; +import java.util.Map; + +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.IC2; +import ic2.core.block.TileEntityInventory; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; + +public class PrecipitatorCondenserTileEntity extends TileEntityInventory implements IFluidHandler +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("precipitatorcondenser"); + private static float kF = 24000F; + private static float gasC = 1F; + private static float fluidC = 4F; + private static float H = 2256F; + private final IHLFluidTank gasBuffer = new IHLFluidTank(10000); + private final IHLFluidTank fluidTank = new IHLFluidTank(100); + private ForgeDirection gasInputDirection = ForgeDirection.WEST; + private int amountOfGasCondensed=0; + + public PrecipitatorCondenserTileEntity() + { + super(); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.gasBuffer.readFromNBT(nbttagcompound.getCompoundTag("gasBuffer")); + this.amountOfGasCondensed=nbttagcompound.getInteger("amountOfGasCondensed"); + } + + public static void addRecipe(String fluidNameIn, String fluidNameOut, int conversionRateToGas) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize(fluidNameIn, conversionRateToGas)}), null), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {IHLUtils.getFluidStackWithSize(fluidNameOut, 1)}),null,2)); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + + NBTTagCompound gasBufferTag = new NBTTagCompound(); + this.gasBuffer.writeToNBT(gasBufferTag); + nbttagcompound.setTag("gasBuffer", gasBufferTag); + + nbttagcompound.setInteger("amountOfGasCondensed",this.amountOfGasCondensed); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("goldPrecipitatorCondenser"); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + FluidStack fluidStack = this.fluidTank.getFluid(); + FluidStack gasStack = this.gasBuffer.getFluid(); + if(fluidStack!=null && gasStack!=null && fluidStack.amount>0 && gasStack.amount>0) + { + int t1 = this.fluidTank.getTemperature(); + float densityOfCoolant = IHLFluid.getRealDensity(fluidStack.getFluid()); + float densityOfGas = IHLFluid.getRealDensity(gasStack.getFluid()); + int boilingPointOfGas = IHLFluid.getBoilingPoint(gasStack.getFluid()); + amountOfGasCondensed += this.getAmountOfCondensedGas(fluidStack.amount, this.gasBuffer.getFluidAmount(), boilingPointOfGas, t1, densityOfGas, densityOfCoolant); + } + if(amountOfGasCondensed>10000) + { + UniversalRecipeOutput rOutput = null; + UniversalRecipeInput rInput = null; + FluidStack fs = null; + for(int i=0;ithis.gasBuffer.getCapacity()*2) + { + FluidStack passingGas = this.gasBuffer.drainLightest(this.gasBuffer.getCapacity()/2, true); + this.fillGaseousOutputApparatus(gasInputDirection, passingGas, true); + } + if(this.fluidTank.getFluid()!=null) + { + FluidStack coolant = this.fluidTank.drain(5, true); + this.fillHeatTransferAgentOutputApparatus(ForgeDirection.UP, coolant, true); + } + } + + private int getAmountOfCondensedGas(int amountOfCoolant, int amountOfGas, int boilingPointOfGas, int temperatureOfCoolant, float densityOfGas, float densityOfCoolant) + { + if(amountOfCoolant<=0 || amountOfGas<=0 || boilingPointOfGas-202*dt2) + { + deltaT = (float) ((dt1-dt2)/Math.log((double)dt2/(double)dt1)); + } + else + { + deltaT = (dt1+dt2)*0.5F; + } + float Q1 = kF*deltaT; + if(Q1>=maxQ) + { + break; + } + else + { + int next_L = (int)(Q1/H/densityOfGas); + if(Math.abs(next_L-L)<4) + { + L=next_L; + break; + } + L=next_L; + } + } + if(t1_1>t1) + { + this.fluidTank.setTemperature(t1_1); + } + else + { + this.fluidTank.setTemperature(t1+1); + } + return L; + } + + @Override + public String getInventoryName() + { + return "precipitatorCondenser"; + } + + public void onGuiClosed(EntityPlayer entityPlayer) {} + + public int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + public int mZ() + { + switch(this.getFacing()) + { + case 2: + return -1; + case 3: + return 1; + default: + return 0; + } + } + + public int mLZ() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + public int mLX() + { + switch(this.getFacing()) + { + case 2: + return 1; + case 3: + return -1; + default: + return 0; + } + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid fluid) { + return direction==ForgeDirection.UP || (gasCanPass(direction) && fluid.isGaseous()); + } + + @Override + public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) + { + if(fluidStack!=null && fluidStack.getFluid()!=null && fluidStack.amount>0) + { + if(gasCanPass(direction) && fluidStack!=null && fluidStack.getFluid()!=null && fluidStack.amount>0) + { + this.gasInputDirection=direction; + if(fluidStack.getFluid().isGaseous() && fluidStack.getFluid().getDensity() getRecipes() + { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} \ No newline at end of file diff --git a/ihl/processing/chemistry/RefluxCondenserModel.java b/ihl/processing/chemistry/RefluxCondenserModel.java new file mode 100644 index 0000000..9cb2f2f --- /dev/null +++ b/ihl/processing/chemistry/RefluxCondenserModel.java @@ -0,0 +1,70 @@ +// Date: 05.04.2015 16:30:47 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + + +public class RefluxCondenserModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPartZ; + + public RefluxCondenserModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.KneeUpEast", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.WestPipe02", 0, 0); + setTextureOffset("Base.WestPipe01", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.PipeUp06", 0, 0); + setTextureOffset("Base.PipeUp07", 0, 0); + setTextureOffset("Base.PipeNorth07", 0, 0); + setTextureOffset("Base.PipeNorth08", 0, 0); + setTextureOffset("RotatingPartZ.ConeWest05", 0, 0); + setTextureOffset("RotatingPartZ.PipeWest07", 0, 0); + setTextureOffset("RotatingPartZ.ConeEast06", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -2F, 7F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP); + Base.addKnee("KneeUpEast", -8F, 2F, -3F, 5, 6, 6, .8F, 1F, ForgeDirection.UP, ForgeDirection.EAST); + Base.addTube("WestPipe03", 3.5F, -7F, -1.5F, 4, 3, 3, 0.8f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe04", 7F, -7.5F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe02", 7F, 3F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe01", -3F, 3.5F, -1.5F, 10, 3, 3, .8F, 1F, ForgeDirection.WEST); + Base.addTube("Shape1", -2F, -8F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP); + Base.addTube("PipeUp06", -1.5F, -7F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP); + Base.addTube("PipeUp07", -1.5F, 5F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP); + Base.addTube("PipeNorth07", -2F, -2F, -8F, 4, 4, 1, 0.6f, 1f,ForgeDirection.NORTH); + Base.addTube("PipeNorth08", -1.5F, -1.5F, -7F, 3, 3, 7, 0.8f, 1f,ForgeDirection.NORTH); + RotatingPartZ = new IHLModelRenderer(this, "RotatingPartZ"); + RotatingPartZ.setRotationPoint(3F, 13F, 0F); + setRotation(RotatingPartZ, 0F, 0F, -0.5F); + RotatingPartZ.mirror = true; + RotatingPartZ.addTube("ConeWest05", 1F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.WEST); + RotatingPartZ.addTube("PipeWest07", -9F, -4F, -4F, 10, 8, 8, 0.8f, 1f,ForgeDirection.WEST); + RotatingPartZ.addTube("ConeEast06", -11F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.EAST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + +} diff --git a/ihl/processing/chemistry/RefluxCondenserTileEntity.java b/ihl/processing/chemistry/RefluxCondenserTileEntity.java new file mode 100644 index 0000000..91366fb --- /dev/null +++ b/ihl/processing/chemistry/RefluxCondenserTileEntity.java @@ -0,0 +1,146 @@ +package ihl.processing.chemistry; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +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.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class RefluxCondenserTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IFluidHandler{ + + private short facing=2; + private short lastFacing=2; + public FractionatorBottomTileEntity columnBottom; + + public RefluxCondenserTileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("refluxCondenser"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return direction.equals(ForgeDirection.UP); + } + + @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 direction, FluidStack fluidStack, boolean doFill) { + if(fluidStack!=null && fluidStack.getFluid()!=null && this.canFill(direction, fluidStack.getFluid()) && columnBottom!=null) + { + return columnBottom.fill(direction, fluidStack, doFill); + } + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) + { + return columnBottom.getTankInfo(arg0); + } + +} diff --git a/ihl/processing/invslots/IHLInvSlotOutput.java b/ihl/processing/invslots/IHLInvSlotOutput.java new file mode 100644 index 0000000..94bf3c8 --- /dev/null +++ b/ihl/processing/invslots/IHLInvSlotOutput.java @@ -0,0 +1,211 @@ +package ihl.processing.invslots; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.recipes.RecipeOutputItemStack; +import ihl.utils.IHLUtils; + +public class IHLInvSlotOutput extends InvSlotOutput{ + + private final Map substanceAmount = new HashMap(); + public IHLInvSlotOutput(TileEntityInventory base1, String name1, int oldStartIndex1, int count) { + super(base1, name1, oldStartIndex1, count); + } + + @Override + public boolean canAdd(List itemOutputs) + { + if(itemOutputs==null || itemOutputs.isEmpty()) + { + return true; + } + Iterator ioi = itemOutputs.iterator(); + if(this.size()>=itemOutputs.size()) + { + Object rois; + if(ioi.hasNext()) + { + rois = ioi.next(); + } + else + { + return true; + } + for(int i=0;i=1) + { + amount--; + this.add(rois.itemStack.copy()); + } + this.substanceAmount.put(key, amount); + } + + @Override + public int add(List itemOutputs) + { + if(itemOutputs==null || itemOutputs.isEmpty()) + { + return 0; + } + Iterator ioi = itemOutputs.iterator(); + if(this.size()>=itemOutputs.size() && ioi.hasNext()) + { + Object rois = ioi.next(); + for(int i=0;i> entrySetIterator = this.substanceAmount.entrySet().iterator(); + while(entrySetIterator.hasNext()) + { + Entry entry = entrySetIterator.next(); + NBTTagCompound tag = new NBTTagCompound(); + tag.setLong("substanceKey", entry.getKey()); + tag.setFloat("substanceAmount", entry.getValue()); + sAmountsList.appendTag(tag); + } + nbtTagCompound.setTag("substanceAmountMap", sAmountsList); + } +} diff --git a/ihl/processing/invslots/InvSlotConsumableLiquidIHL.java b/ihl/processing/invslots/InvSlotConsumableLiquidIHL.java new file mode 100644 index 0000000..c88584e --- /dev/null +++ b/ihl/processing/invslots/InvSlotConsumableLiquidIHL.java @@ -0,0 +1,271 @@ +package ihl.processing.invslots; + +import java.util.Iterator; + +import org.apache.commons.lang3.mutable.MutableObject; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.util.StackUtil; +import ihl.utils.IHLUtils; + +public class InvSlotConsumableLiquidIHL extends InvSlotConsumableLiquid{ + + private OpType opType; + private String additionalInputs; + + public InvSlotConsumableLiquidIHL(TileEntityInventory base1, String name1,int oldStartIndex1, Access access1, int count,InvSide preferredSide1, OpType opType1) + { + super(base1, name1, oldStartIndex1, access1, count, preferredSide1, opType1); + opType=opType1; + } + + public InvSlotConsumableLiquidIHL(TileEntityInventory base1, String name1,int oldStartIndex1, Access access1, int count,InvSide preferredSide1, OpType opType1, String additionalInputs1) + { + super(base1, name1, oldStartIndex1, access1, count, preferredSide1, opType1); + opType=opType1; + additionalInputs=additionalInputs1; + } + + @Override + public FluidStack drain(Fluid fluid, int maxAmount, MutableObject output, boolean simulate) + { + if(output!=null) + { + output.setValue((ItemStack)null); + } + + if (this.opType != InvSlotConsumableLiquid.OpType.Drain && this.opType != InvSlotConsumableLiquid.OpType.Both) + { + return null; + } + else + { + ItemStack stack = this.get(); + + if (stack == null) + { + return null; + } + else if (!FluidContainerRegistry.isFilledContainer(stack)) + { + if (stack.getItem() instanceof IFluidContainerItem) + { + IFluidContainerItem var9 = (IFluidContainerItem)stack.getItem(); + + if (var9.getFluid(stack) == null) + { + return null; + } + else if (fluid != null && var9.getFluid(stack).getFluid() != fluid) + { + return null; + } + else if (!this.acceptsLiquid(var9.getFluid(stack).getFluid())) + { + return null; + } + else + { + ItemStack singleStack = StackUtil.copyWithSize(stack, 1); + FluidStack fluidStack = var9.drain(singleStack, maxAmount, true); + + if (fluidStack != null && fluidStack.amount > 0) + { + if (singleStack.stackSize <= 0) + { + if (!simulate) + { + --stack.stackSize; + } + } + else if (var9.getFluid(singleStack) == null) + { + if(output!=null) + { + output.setValue(singleStack); + } + if (!simulate) + { + --stack.stackSize; + } + } + else + { + if (stack.stackSize > 1) + { + return null; + } + + if (!simulate) + { + this.put(singleStack); + } + } + + if (stack.stackSize <= 0) + { + this.put((ItemStack)null); + } + + return fluidStack; + } + else + { + return null; + } + } + } + else + { + return null; + } + } + else + { + FluidStack container = FluidContainerRegistry.getFluidForFilledItem(stack); + + if (container != null && (fluid == null || fluid == container.getFluid())) + { + if (!this.acceptsLiquid(container.getFluid())) + { + return null; + } + else if (container.amount > 0 && container.amount <= maxAmount) + { + if (stack.getItem().hasContainerItem(stack) && output!=null) + { + output.setValue(stack.getItem().getContainerItem(stack)); + } + else + { + ItemStack emptystack = FluidContainerRegistry.drainFluidContainer(stack); + if(emptystack!=null && output!=null) + { + output.setValue(emptystack); + } + } + + if (!simulate) + { + --stack.stackSize; + + if (stack.stackSize <= 0) + { + this.put((ItemStack)null); + } + } + + return container; + } + else + { + return null; + } + } + else + { + return null; + } + } + } + } + + @Override + public boolean accepts(ItemStack stack) + { + if (stack == null) + { + return true; + } + Item item = stack.getItem(); + if (item == null) + { + return false; + } + else + { + if(this.additionalInputs!=null) + { + String fon = IHLUtils.getFirstOreDictName(stack); + if(fon!=null && fon.contains(additionalInputs)) + { + return true; + } + } + if (this.opType == InvSlotConsumableLiquid.OpType.Drain || this.opType == InvSlotConsumableLiquid.OpType.Both) + { + FluidStack containerItem = null; + if (FluidContainerRegistry.isFilledContainer(stack)) + { + containerItem = FluidContainerRegistry.getFluidForFilledItem(stack); + } + else if (item instanceof IFluidContainerItem) + { + containerItem = ((IFluidContainerItem)item).getFluid(stack); + } + + if (containerItem != null && containerItem.amount > 0) + { + return true; + } + } + if (this.opType == InvSlotConsumableLiquid.OpType.Fill || this.opType == InvSlotConsumableLiquid.OpType.Both) + { + if (FluidContainerRegistry.isEmptyContainer(stack)) + { + if (this.getPossibleFluids() == null) + { + return true; + } + + Iterator containerItem1 = this.getPossibleFluids().iterator(); + + while (containerItem1.hasNext()) + { + Fluid prevFluid = (Fluid)containerItem1.next(); + + if (FluidContainerRegistry.fillFluidContainer(new FluidStack(prevFluid, Integer.MAX_VALUE), stack) != null) + { + return true; + } + } + } + else if (item instanceof IFluidContainerItem) + { + IFluidContainerItem containerItem2 = (IFluidContainerItem)item; + FluidStack prevFluid1 = containerItem2.getFluid(stack); + + if (prevFluid1 == null || containerItem2.getCapacity(stack) > prevFluid1.amount) + { + if (this.getPossibleFluids() == null) + { + return true; + } + + ItemStack singleStack = StackUtil.copyWithSize(stack, 1); + Iterator i$ = this.getPossibleFluids().iterator(); + + while (i$.hasNext()) + { + Fluid fluid = (Fluid)i$.next(); + + if (containerItem2.fill(singleStack, new FluidStack(fluid, Integer.MAX_VALUE), false) > 0) + { + return true; + } + } + } + } + } + return false; + } + } + +} diff --git a/ihl/processing/invslots/InvSlotSignalProcessor.java b/ihl/processing/invslots/InvSlotSignalProcessor.java new file mode 100644 index 0000000..6663db0 --- /dev/null +++ b/ihl/processing/invslots/InvSlotSignalProcessor.java @@ -0,0 +1,125 @@ +package ihl.processing.invslots; + +import java.util.Iterator; +import net.minecraft.block.Block; +import net.minecraftforge.common.util.ForgeDirection; +import ic2.core.Ic2Items; +import ic2.core.block.invslot.InvSlot; +import ihl.IHLMod; +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/invslots/SlotInvSlotOutputInProgress.java b/ihl/processing/invslots/SlotInvSlotOutputInProgress.java new file mode 100644 index 0000000..a1b3937 --- /dev/null +++ b/ihl/processing/invslots/SlotInvSlotOutputInProgress.java @@ -0,0 +1,23 @@ +package ihl.processing.invslots; + +import net.minecraft.entity.player.EntityPlayer; +import ic2.core.slot.SlotInvSlot; +import ihl.flexible_cable.IronWorkbenchInvSlot; + +public class SlotInvSlotOutputInProgress extends SlotInvSlot { + + public IronWorkbenchInvSlot invSlot; + + public SlotInvSlotOutputInProgress(IronWorkbenchInvSlot invSlot1, int index1, + int xDisplayPosition1, int yDisplayPosition1) { + super(invSlot1, index1, xDisplayPosition1, yDisplayPosition1); + this.invSlot=invSlot1; + + } + + @Override + public boolean canTakeStack(EntityPlayer player) + { + return this.invSlot.getCanTakeStack(); + } +} diff --git a/ihl/processing/invslots/SlotRedstoneConverterCableInvSlot.java b/ihl/processing/invslots/SlotRedstoneConverterCableInvSlot.java new file mode 100644 index 0000000..461c3cc --- /dev/null +++ b/ihl/processing/invslots/SlotRedstoneConverterCableInvSlot.java @@ -0,0 +1,23 @@ +package ihl.processing.invslots; + +import net.minecraft.entity.player.EntityPlayer; +import ic2.core.block.invslot.InvSlot; +import ic2.core.slot.SlotInvSlot; + +public class SlotRedstoneConverterCableInvSlot extends SlotInvSlot { + + public InvSlot invSlot; + + public SlotRedstoneConverterCableInvSlot(InvSlot invSlot1, int index1, + int xDisplayPosition1, int yDisplayPosition1) { + super(invSlot1, index1, xDisplayPosition1, yDisplayPosition1); + this.invSlot=invSlot1; + } + + @Override + public boolean canTakeStack(EntityPlayer player) + { + return false; + } + +} diff --git a/ihl/processing/metallurgy/AchesonFurnaceGui.java b/ihl/processing/metallurgy/AchesonFurnaceGui.java new file mode 100644 index 0000000..bafa530 --- /dev/null +++ b/ihl/processing/metallurgy/AchesonFurnaceGui.java @@ -0,0 +1,48 @@ +package ihl.processing.metallurgy; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +public class AchesonFurnaceGui extends GuiContainer { + protected static final ResourceLocation achesonFurnaceBackground = new ResourceLocation("ihl", "textures/gui/GUIAchesonFurnance.png"); + private MachineBaseContainer container; + + public AchesonFurnaceGui(MachineBaseContainer machineBaseContainer) { + //the container is instanciated and passed to the superclass for handling + super(machineBaseContainer); + this.container=machineBaseContainer; + } + + @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(achesonFurnaceBackground); + 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); + this.drawTexturedModalRect(64, 63, 197, 0, i1 + 1, 13); + } + fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("ihl.gui.achesonFurnance"), 40, 12, 16768125); + } + + @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(achesonFurnaceBackground); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/AchesonFurnanceContainer.java b/ihl/processing/metallurgy/AchesonFurnanceContainer.java new file mode 100644 index 0000000..140ec97 --- /dev/null +++ b/ihl/processing/metallurgy/AchesonFurnanceContainer.java @@ -0,0 +1,17 @@ +package ihl.processing.metallurgy; + +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; + +public class AchesonFurnanceContainer extends MachineBaseContainer { + + public AchesonFurnanceContainer(EntityPlayer entityPlayer, + AchesonFurnanceTileEntity tileEntity1) { + super(entityPlayer, tileEntity1); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputElectrode, 0, 63, 40)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputElectrode, 1, 99, 40)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 81, 40)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 81, 22)); + } + +} diff --git a/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java b/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java new file mode 100644 index 0000000..5d228fc --- /dev/null +++ b/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java @@ -0,0 +1,150 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.core.ContainerBase; +import ic2.core.block.invslot.InvSlot.Access; +import ihl.IHLMod; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class AchesonFurnanceTileEntity extends MachineBaseTileEntity{ + + public final ApparatusProcessableInvSlot inputElectrode; + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("achesonfurnace"); + private final RecipeInputOreDict[] validElectrodeTypes=new RecipeInputOreDict[] {new RecipeInputOreDict("stickCoal"),new RecipeInputOreDict("stickGraphite"),new RecipeInputOreDict("plateCoal"),new RecipeInputOreDict("plateGraphite")}; + + public AchesonFurnanceTileEntity() + { + super(2); + inputElectrode = new ApparatusProcessableInvSlot(this, "inputElectrode", 1, Access.IO, 2, 1); + } + + public static void addRecipe(IRecipeInput input1, IRecipeInput input2, String output1) + { + recipeManager.addRecipe(new UniversalRecipeInput(null,Arrays.asList(new IRecipeInput [] {input1,input2})),new UniversalRecipeOutput(null,Arrays.asList(new ItemStack [] {IHLUtils.getThisModItemStack(output1)}),20)); + } + + @Override + public String getStartSoundFile() + { + return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg"; + } + + @Override + public String getLoopSoundFile() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getStopSoundFile() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getInventoryName() { + return "AchesonFurnance"; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new AchesonFurnaceGui(new AchesonFurnanceContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new AchesonFurnanceContainer(player, this); + } + + @Override + public void operate() + { + List output = AchesonFurnanceTileEntity.recipeManager.getOutputFor(getInput(), true, true).getItemOutputs(); + for(int i=0; ii) + { + ItemStack stack = output.get(i).itemStack.copy(); + stack.stackSize=Math.round(output.get(i).quantity); + this.input.put(i,stack); + } + if(this.input.get(i)!=null && this.input.get(i).stackSize<=0) + { + this.input.put(i, null); + } + } + ItemStack crucible = input.getItemStack(IHLMod.crucible); + if(crucible!=null) + { + ItemStack stack = ((Crucible)crucible.getItem()).processContent(crucible, this); + } + } + + @Override + public boolean canOperate() + { + return this.isValidElectrode(this.inputElectrode.get(0)) && + this.isValidElectrode(this.inputElectrode.get(1)) && + this.getOutput()!=null; + } + + @Override + public List[] getInput() + { + return new List[] {null, this.input.getItemStackList()}; + } + + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public UniversalRecipeOutput getOutput() + { + return AchesonFurnanceTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + private boolean isValidElectrode(ItemStack stack) + { + if(stack!=null) + { + for(int i=0;i nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea); + super.setFacing(facing2); + switch(getFacing()) + { + case 4: + setConnectionX(this.xCoord+0.5D); + setConnectionY(this.yCoord+d); + setConnectionZ(this.zCoord+1D-f); + break; + case 5: + setConnectionX(this.xCoord+0.5D); + setConnectionY(this.yCoord+d); + setConnectionZ(this.zCoord+f); + break; + case 2: + setConnectionX(this.xCoord+1D-f); + setConnectionY(this.yCoord+d); + setConnectionZ(this.zCoord+0.5D); + break; + case 3: + setConnectionX(this.xCoord+f); + setConnectionY(this.yCoord+d); + setConnectionZ(this.zCoord+0.5D); + break; + default: + setConnectionX(this.xCoord+1D-f); + setConnectionY(this.yCoord+d); + setConnectionZ(this.zCoord+0.5D); + break; + + } + if(!nodeList.isEmpty()) + { + Iterator ei = nodeList.iterator(); + while(ei.hasNext()) + { + NodeEntity ne=(NodeEntity) ei.next(); + if((ne.prevAnchorEntity==null||ne.nextAnchorEntity==null) && this.cableListContains(ne.getChainUniqueID())) + { + ne.setVirtualNodePos(connectionX,connectionY,connectionZ); + } + } + } + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public double getDemandedEnergy() + { + return this.maxStorage-this.energy; + } + + @Override + public int getSinkTier() { + return 4; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, + double voltage) { + if(this.energy0D && this.energy=this.energyConsume/this.engine.getEfficiency()) + { + this.energy-=this.energyConsume/this.engine.getEfficiency(); + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + if (this.progress >= this.operationLength) + { + this.operate(); + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + } + + } + + public abstract List[] getInput(); + public abstract boolean canOperate(); + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public int getEnergy() + { + return (int)this.energy; + } + + + public int getGUIEnergy(int i) { + if(this.energyx-3;ix--) + { + for(iy=y;iy>y-3;iy--) + { + for(iz=z;iz>z-3;iz--) + { + TileEntity te = worldObj.getTileEntity(ix, iy, iz); + if(te instanceof BigMachineFrameTileEntity) + { + x0=ix+1; + y0=iy+1; + z0=iz+1; + } + } + } + } + for(ix=x0-1;ix 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if(!this.container.tileEntity.engine.correctContent()) + { + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 47, 56, xOffset, yOffset); + } + IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.coiler.tip")); + } + + @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(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/CoilerModel.java b/ihl/processing/metallurgy/CoilerModel.java new file mode 100644 index 0000000..9c1721e --- /dev/null +++ b/ihl/processing/metallurgy/CoilerModel.java @@ -0,0 +1,103 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class CoilerModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer CoilRotating; + IHLModelRenderer Coil; + + public CoilerModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN1", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 17); + setTextureOffset("RotatingPart2.PipeN14", 0, 19); + setTextureOffset("RotatingPart2.PipeN17", 0, 17); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 0, 0); + setTextureOffset("Belt2.Shape13", 0, 0); + setTextureOffset("CoilRotating.PipeN15", 22, 19); + setTextureOffset("Coil.Shape1", 22, 30); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape2", -5.5F, -1F, 7F, 5, 8, 1); + Base.addBox("Shape16", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN1", -0.5F, -0.5F, 0F, 1, 1, 14, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -4F, -4F, 2F, 8, 8, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN14", -4F, -4F, 12F, 8, 8, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN17", -1F, -1F, 3F, 2, 2, 9, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0.5F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + CoilRotating = new IHLModelRenderer(this, "CoilRotating"); + CoilRotating.setRotationPoint(-3F, 18F, -7F); + setRotation(CoilRotating, 0F, 0F, 0F); + CoilRotating.mirror = true; + CoilRotating.addTube("PipeN15", -2F, -2F, 3F, 4, 4, 9, 0F,1F,ForgeDirection.NORTH); + Coil = new IHLModelRenderer(this, "Coil"); + Coil.setRotationPoint(-0.25F, 16F, 0F); + setRotation(Coil, 0F, 0F, -0.2F); + Coil.mirror = true; + Coil.addTube("Shape1", -8F, -0.25F, -0.5F, 5, 1, 1, 0F,1F,ForgeDirection.WEST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/CoilerRender.java b/ihl/processing/metallurgy/CoilerRender.java new file mode 100644 index 0000000..646b342 --- /dev/null +++ b/ihl/processing/metallurgy/CoilerRender.java @@ -0,0 +1,83 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; + +public class CoilerRender extends TileEntitySpecialRenderer{ +private CoilerModel model = new CoilerModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"); +private final float scale=1F/16F; + + public CoilerRender() {} + + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)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; + } + } + else + { + return; + } + CoilerTileEntity cte = (CoilerTileEntity)tile; + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + + bindTexture(tex); + model.Base.render(scale); + model.Belt.render(scale); + model.Belt2.render(scale); + if(cte.getActive()) + { + model.Coil.render(scale); + model.CoilRotating.rotateAngleZ+=0.02F; + model.CoilRotating.render(scale); + model.RotatingPart2.rotateAngleZ+=0.02F; + model.MotorPart1.rotateAngleZ+=0.03F; + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + } + else + { + + if(cte.hasCoil) + { + model.CoilRotating.render(scale); + } + if(cte.hasEngine) + { + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + } + } + model.RotatingPart2.render(scale); + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/CoilerTileEntity.java b/ihl/processing/metallurgy/CoilerTileEntity.java new file mode 100644 index 0000000..6a671b0 --- /dev/null +++ b/ihl/processing/metallurgy/CoilerTileEntity.java @@ -0,0 +1,171 @@ +package ihl.processing.metallurgy; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlotOutput; +import ic2.core.network.NetworkManager; +import ihl.interfaces.IWire; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class CoilerTileEntity extends BasicElectricMotorTileEntity implements IProductionLine{ + + public final InvSlotOutput output; + private int activeTimer=0; + public boolean hasCoil=false; + public boolean hasEngine=false; + + public CoilerTileEntity() + { + super(); + this.output = new InvSlotOutput(this, "output", 1, 1); + this.isGuiScreenOpened=true; + } + + + @Override + public String getInventoryName() { + return "Coiler"; + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("hasCoil"); + fields.add("hasEngine"); + return fields; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("coiler"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new CoilerGui(new CoilerContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + return new CoilerContainer(player, this); + } + + @Override + public boolean canOperate() + { + return false; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(activeTimer>0) + { + activeTimer--; + } + else + { + setActive(false); + } + if(this.output.isEmpty() && hasCoil==true) + { + this.hasCoil=false; + IC2.network.get().updateTileEntityField(this, "hasCoil"); + } + else if(!this.output.isEmpty() && hasCoil==false) + { + this.hasCoil=true; + IC2.network.get().updateTileEntityField(this, "hasCoil"); + } + if(this.engine.isEmpty() && hasEngine==true) + { + this.hasEngine=false; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + else if(this.engine.correctContent() && hasEngine==false) + { + this.hasEngine=true; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + + } + + @Override + public void operate() + {} + + + @Override + public List[] getInput() + { + return null; + } + + + @Override + public boolean canProcess(ItemStack cable) { + if(this.engine.correctContent() && this.energy>1D/this.engine.getEfficiency() && cable.getItem() instanceof IWire) + { + if(this.output.isEmpty()) + { + return true; + } + else if(this.output.get().getItem() instanceof IWire) + { + return ((IWire)this.output.get().getItem()).isSameWire(this.output.get(), cable); + } + else + { + return this.output.get().isItemEqual(cable); + } + } + return false; + } + + + @Override + public void process(ItemStack cable) { + if(cable.getItem() instanceof IWire) + { + this.energy-=1D/this.engine.getEfficiency(); + if(this.output.isEmpty()) + { + setActive(true); + activeTimer=800; + this.output.put(cable); + this.hasCoil=true; + IC2.network.get().updateTileEntityField(this, "hasCoil"); + } + else + { + setActive(true); + activeTimer=800; + int length = this.output.get().stackTagCompound.getInteger(((IWire)this.output.get().getItem()).getTag()); + int fullLength = this.output.get().stackTagCompound.getInteger(((IWire)this.output.get().getItem()).getTagSecondary()); + int lengthToAdd = cable.stackTagCompound.getInteger(((IWire)cable.getItem()).getTag()); + int fullLengthToAdd = cable.stackTagCompound.getInteger(((IWire)cable.getItem()).getTagSecondary()); + this.output.get().stackTagCompound.setInteger(((IWire)this.output.get().getItem()).getTag(), length+lengthToAdd); + this.output.get().stackTagCompound.setInteger(((IWire)this.output.get().getItem()).getTagSecondary(),fullLength+fullLengthToAdd); + } + } + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/metallurgy/Crucible.java b/ihl/processing/metallurgy/Crucible.java new file mode 100644 index 0000000..a435e49 --- /dev/null +++ b/ihl/processing/metallurgy/Crucible.java @@ -0,0 +1,389 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +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.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.oredict.OreDictionary; +import ic2.api.item.IItemHudInfo; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.item.IHandHeldInventory; +import ic2.core.util.LiquidUtil; +import ic2.core.util.StackUtil; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; + +public class Crucible extends Item implements IHandHeldInventory, IFluidContainerItem, IItemHudInfo{ + + public int capacity=864; + private String itemName; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("crucible"); + + @SideOnly(Side.CLIENT) + private IIcon iconHot; + + public Crucible() { + super(); + this.itemName="crucible"; + this.setUnlocalizedName(itemName); + GameRegistry.registerItem(this, this.itemName); + this.setCreativeTab(IHLCreativeTab.tab); + this.maxStackSize=1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setMaxDamage(0); + } + + public static void addRecipe(String string, FluidStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new IRecipeInput[] {new RecipeInputOreDict(string)})), new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {output}),null,20)); + } + + @Override + public IHasGui getInventory(EntityPlayer entityPlayer, ItemStack itemStack) + { + return new CrucibleInventory(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; + } + + /** + * allows items to add custom lines of information to the mouseover description + */ + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) + { + super.addInformation(itemStack, player, info, b); + FluidStack fs = this.getFluid(itemStack); + + if (fs != null) + { + info.add("< " + FluidRegistry.getFluidName(fs) + ", " + fs.amount + " mB >"); + } + else + { + info.add(StatCollector.translateToLocal("ic2.item.FluidContainer.Empty")); + } + } + + @Override + public List getHudInfo(ItemStack itemStack) + { + LinkedList info = new LinkedList(); + FluidStack fs = this.getFluid(itemStack); + + if (fs != null) + { + info.add("< " + FluidRegistry.getFluidName(fs) + ", " + fs.amount + " mB >"); + } + else + { + info.add(StatCollector.translateToLocal("ic2.item.FluidContainer.Empty")); + } + + return info; + } + + @Override + public FluidStack getFluid(ItemStack stack) + { + NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack); + NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid"); + return FluidStack.loadFluidStackFromNBT(fluidTag); + } + + public boolean isEmpty(ItemStack stack) + { + return this.getFluid(stack) == null; + } + + @Override + public int getCapacity(ItemStack container) + { + return this.capacity; + } + + public boolean canfill(Fluid var1) + { + return true; + } + + public ItemStack processContent(ItemStack itemStack, IInventory inventoryContainer) + { + CrucibleInventory inventory = new CrucibleInventory(inventoryContainer, itemStack); + ItemStack content = inventory.getStackInSlot(0); + 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; + itemStack.stackTagCompound = new NBTTagCompound(); + this.fill(itemStack, fluidStack, true); + return itemStack; + } + } + return itemStack; + } + + @Override + public int fill(ItemStack stack, FluidStack resource, boolean doFill) + { + if (stack.stackSize != 1) + { + return 0; + } + else if (resource == null) + { + return 0; + } + else if (!this.canfill(resource.getFluid())) + { + return 0; + } + else + { + NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack); + NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid"); + FluidStack fs = FluidStack.loadFluidStackFromNBT(fluidTag); + + if (fs == null) + { + fs = new FluidStack(resource, 0); + } + + if (!fs.isFluidEqual(resource)) + { + return 0; + } + else + { + int amount = Math.min(this.capacity - fs.amount, resource.amount); + + if (doFill && amount > 0) + { + fs.amount += amount; + fs.writeToNBT(fluidTag); + nbtTagCompound.setTag("Fluid", fluidTag); + if(fs.getFluid().getTemperature()>900)stack.setItemDamage(1); + } + + return amount; + } + } + } + + @Override + public FluidStack drain(ItemStack stack, int maxDrain, boolean doDrain) + { + if (stack.stackSize != 1) + { + return null; + } + else + { + NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack); + NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid"); + FluidStack fs = FluidStack.loadFluidStackFromNBT(fluidTag); + + if (fs == null) + { + return null; + } + else + { + maxDrain = Math.min(fs.amount, maxDrain); + + if (doDrain) + { + fs.amount -= maxDrain; + + if (fs.amount <= 0) + { + nbtTagCompound.removeTag("Fluid"); + stack.setItemDamage(0); + } + else + { + fs.writeToNBT(fluidTag); + nbtTagCompound.setTag("Fluid", fluidTag); + } + } + + return new FluidStack(fs, maxDrain); + } + } + } + private String getFormattedFluidNameFromMaterialName(String input) + { + if(input.length()<6) + { + return ""; + } + String input2 = input.substring(5); + return "molten."+input2.toLowerCase(); + } + + private String getOreName(ItemStack stack) + { + int[] arrayIDs = OreDictionary.getOreIDs(stack); + for(int i=0; i= this.capacity)) + { + amount = handler.fill(dir, fs, false); + + if (amount <= 0) + { + return false; + } + else + { + fs = LiquidUtil.drainContainerStack(stack, player, amount, false); + + if (fs != null && fs.amount > 0) + { + handler.fill(dir, fs, true); + return true; + } + else + { + return false; + } + } + } + else + { + amount = fs == null ? this.capacity : this.capacity - fs.amount; + FluidStack input = handler.drain(dir, amount, false); + + if (input != null && input.amount > 0) + { + amount = LiquidUtil.fillContainerStack(stack, player, input, false); + + if (amount <= 0) + { + return false; + } + else + { + handler.drain(dir, amount, true); + return true; + } + } + else + { + return false; + } + } + } + } + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + +} diff --git a/ihl/processing/metallurgy/CrucibleContainer.java b/ihl/processing/metallurgy/CrucibleContainer.java new file mode 100644 index 0000000..b3ab3d8 --- /dev/null +++ b/ihl/processing/metallurgy/CrucibleContainer.java @@ -0,0 +1,67 @@ +package ihl.processing.metallurgy; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.util.StackUtil; + +public class CrucibleContainer extends ContainerBase +{ + public CrucibleInventory box; + public CrucibleContainer(EntityPlayer entityPlayer, CrucibleInventory box) + { + super(box); + this.box = box; + int col; + if(((Crucible)this.box.thisItemStack.getItem()).isEmpty(this.box.thisItemStack)) + { + this.addSlotToContainer(new CrucibleSlot(this.box, 0, 81, 42)); + } + 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, 84 + col * 18)); + } + } + + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, 142)); + } + } + + @Override + public ItemStack slotClick(int slot, int button, int par3, EntityPlayer player) + { + if (player instanceof EntityPlayerMP && IC2.platform.isSimulating() && slot == -999 && (button == 0 || button == 1)) + { + ItemStack stack = player.inventory.getItemStack(); + + if (stack != null) + { + NBTTagCompound nbtTagCompoundSlot = StackUtil.getOrCreateNbtData(stack); + + if (this.box.isThisContainer(stack)) + { + ((EntityPlayerMP)player).closeScreen(); + } + } + } + return super.slotClick(slot, button, par3, player); + } + + /** + * Called when the container is closed. + */ + @Override + public void onContainerClosed(EntityPlayer entityPlayer) + { + this.box.onGuiClosed(entityPlayer); + super.onContainerClosed(entityPlayer); + } +} diff --git a/ihl/processing/metallurgy/CrucibleGui.java b/ihl/processing/metallurgy/CrucibleGui.java new file mode 100644 index 0000000..b0bfc85 --- /dev/null +++ b/ihl/processing/metallurgy/CrucibleGui.java @@ -0,0 +1,86 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import ic2.core.util.DrawUtil; +import ic2.core.util.GuiTooltipHelper; + +public class CrucibleGui extends GuiContainer +{ + public CrucibleContainer container; + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUICrucible.png"); + private static final String title = StatCollector.translateToLocal("item.crucible.name"); + + public CrucibleGui(CrucibleContainer container1) + { + 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; + fontRendererObj.drawString(title, 68, 0, 6171880); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + @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); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.mc.renderEngine.bindTexture(background); + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if(this.getItemStack().getItemDamage()==1) + { + this.drawTexturedModalRect(x+67, y+26, 198, 52, 58, 39); + } + FluidStack fluidStack = this.getItemInstance().getFluid(this.getItemStack()); + if (fluidStack!=null && fluidStack.amount > 0) + { + Fluid fluid = fluidStack.getFluid(); + if(fluid!=null) + { + IIcon fluidIcon = fluid.getIcon(); + if (fluidIcon != null) + { + this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + int liquidHeight = fluidStack.amount*20/getItemInstance().capacity; + DrawUtil.drawRepeated(fluidIcon, x+71, y+ 41 + 20 - liquidHeight, 35.0D, liquidHeight, this.zLevel); + } + } + String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getName()) + ": " + fluidStack.amount + "mB"; + GuiTooltipHelper.drawAreaTooltip(par2, par3, tooltip, x-16, y+10, x+16, y+29); + } + this.mc.renderEngine.bindTexture(background); + if(this.getItemStack().getItemDamage()==1) + { + this.drawTexturedModalRect(x+68, y+40, 198, 26, 58, 26); + } + else + { + this.drawTexturedModalRect(x+68, y+40, 198, 0, 58, 26); + } + } + + private Crucible getItemInstance() + { + return ((Crucible)this.container.box.thisItemStack.getItem()); + } + + private ItemStack getItemStack() + { + return this.container.box.thisItemStack; + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/CrucibleInventory.java b/ihl/processing/metallurgy/CrucibleInventory.java new file mode 100644 index 0000000..57d9c17 --- /dev/null +++ b/ihl/processing/metallurgy/CrucibleInventory.java @@ -0,0 +1,155 @@ +package ihl.processing.metallurgy; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +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{ + + ItemStack thisItemStack; + IInventory inventoryContainer; + public CrucibleInventory(EntityPlayer player, ItemStack stack) { + super(player, stack, 1); + thisItemStack=stack; + inventoryContainer=player.inventory; + } + + public CrucibleInventory(IInventory inventoryContainer1, ItemStack stack) + { + super(null, stack, 1); + thisItemStack=stack; + inventoryContainer=inventoryContainer1; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new CrucibleGui(new CrucibleContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new CrucibleContainer(player, this); + } + + @Override + public String getInventoryName() { + return "crucible"; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @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; + } + } + } + + } + } + +} diff --git a/ihl/processing/metallurgy/CrucibleSlot.java b/ihl/processing/metallurgy/CrucibleSlot.java new file mode 100644 index 0000000..e0b702d --- /dev/null +++ b/ihl/processing/metallurgy/CrucibleSlot.java @@ -0,0 +1,20 @@ +package ihl.processing.metallurgy; + +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class CrucibleSlot extends Slot +{ + CrucibleInventory inventory; + public CrucibleSlot(CrucibleInventory arg0, int arg1, int arg2, int arg3) + { + super(arg0, arg1, arg2, arg3); + inventory=arg0; + } + + @Override + public boolean isItemValid(ItemStack itemstack) + { + return itemstack == null ? false : inventory.isItemValidForSlot(0, itemstack); + } +} diff --git a/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java b/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java new file mode 100644 index 0000000..3bfd2b0 --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java @@ -0,0 +1,39 @@ +package ihl.processing.metallurgy; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; + +public class DetonationSprayingMachineContainer extends ContainerBase { + + protected DetonationSprayingMachineTileEntity tileEntity; + public int lastFluidAmount = -1; + public short lastProgress = -1; + private final static int height=166; + + public DetonationSprayingMachineContainer(EntityPlayer entityPlayer, DetonationSprayingMachineTileEntity detonationSprayingMachineTileEntity){ + super(detonationSprayingMachineTileEntity); + this.tileEntity = detonationSprayingMachineTileEntity; + 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(detonationSprayingMachineTileEntity.input, 0, 10, 17)); + this.addSlotToContainer(new SlotInvSlot(detonationSprayingMachineTileEntity.input, 1, 98, 17)); + this.addSlotToContainer(new SlotInvSlot(detonationSprayingMachineTileEntity.input, 2, 117, 17)); + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/metallurgy/DetonationSprayingMachineGui.java b/ihl/processing/metallurgy/DetonationSprayingMachineGui.java new file mode 100644 index 0000000..cc4d455 --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineGui.java @@ -0,0 +1,54 @@ +package ihl.processing.metallurgy; + +import java.util.Iterator; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class DetonationSprayingMachineGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDetonationSprayingMachine.png"); + private DetonationSprayingMachineContainer container; + private static final String hint = StatCollector.translateToLocal("ihl.dsmhint"); + + public DetonationSprayingMachineGui (DetonationSprayingMachineContainer detonationSprayingMachineContainer) { + //the container is instanciated and passed to the superclass for handling + super(detonationSprayingMachineContainer); + this.container=detonationSprayingMachineContainer; + } + + @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); + } + + @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); + Iterator noteListIterator = this.mc.fontRenderer.listFormattedStringToWidth(hint, 140).iterator(); + int yTextPos=40; + while(noteListIterator.hasNext()) + { + GuiDraw.fontRenderer.drawStringWithShadow(noteListIterator.next(), x+15, y+yTextPos, 16777215); + yTextPos+=10; + } + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/DetonationSprayingMachineModel.java b/ihl/processing/metallurgy/DetonationSprayingMachineModel.java new file mode 100644 index 0000000..48329d5 --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineModel.java @@ -0,0 +1,65 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraftforge.common.util.ForgeDirection; + +public class DetonationSprayingMachineModel extends ModelBase { + //fields + IHLModelRenderer Base; + + public DetonationSprayingMachineModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape1", 20, 0); + setTextureOffset("Base.Shape2", 34, 0); + setTextureOffset("Base.Shape3", 23, 0); + setTextureOffset("Base.Shape4", 23, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Tube1", 0, 0); + setTextureOffset("Base.Tube2", 0, 0); + setTextureOffset("Base.Shape12", 0, 20); + setTextureOffset("Base.Shape13", 0, 20); + setTextureOffset("Base.Shape14", 0, 20); + setTextureOffset("Base.Shape7", 26, 22); + setTextureOffset("Base.Shape8", 18, 19); + setTextureOffset("Base.Shape9", 18, 22); + setTextureOffset("Base.Tube11", 8, 5); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 8F, 0F); + Base.mirror = true; + Base.addBox("Shape1", 4F, 6F, 7F, 2, 9, 1, false); + Base.addBox("Shape2", -7F, 4F, 6F, 14, 11, 1, false); + Base.addBox("Shape3", -1F, 6F, 7F, 2, 9, 1, false); + Base.addBox("Shape4", -6F, 6F, 7F, 2, 9, 1, false); + Base.addBox("Shape5", -8F, 15F, -8F, 16, 1, 16, false); + Base.addTube("Tube1", -1F, 10F, -7F, 2, 2, 6, 0.5F,1F,ForgeDirection.NORTH); + Base.addTube("Tube2", -2.5F, 10.5F, -6F, 5, 1, 1, 0F,1F,ForgeDirection.EAST); + Base.addBox("Shape12", -2.5F, 11.7F, -2.2F, 5, 4, 1, false); + Base.addBox("Shape13", 1F, 9F, -8F, 1, 6, 6, false); + Base.addBox("Shape14", -2F, 9F, -8F, 1, 6, 6, false); + Base.addBox("Shape7", -1F, 14F, -8F, 2, 1, 5, false); + Base.addBox("Shape8", 2F, 14F, -8F, 2, 1, 9, false); + Base.addBox("Shape9", -4F, 14F, -8F, 2, 1, 9, false); + Base.addTube("Tube11", -1F, 10F, -8F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH); + } + + 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/processing/metallurgy/DetonationSprayingMachineRender.java b/ihl/processing/metallurgy/DetonationSprayingMachineRender.java new file mode 100644 index 0000000..9bb0c6e --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineRender.java @@ -0,0 +1,61 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; +import ihl.utils.IHLItemRenderer; + +public class DetonationSprayingMachineRender extends TileEntitySpecialRenderer{ +private DetonationSprayingMachineModel model = new DetonationSprayingMachineModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/detonationSprayingMachine.png"); +private final float scale=1F/16F; +private IHLItemRenderer itemRenderer=new IHLItemRenderer(true); + +public DetonationSprayingMachineRender(){} + +public void renderAModelAt(DetonationSprayingMachineTileEntity tile, double x, double y, double z, float f) { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y+0.5F, (float)z + 0.5F); + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)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; + } + } + GL11.glRotatef(-rotation*90f, 0F, 1F, 0F); + if(tile.input.get()!=null) + { + this.itemRenderer.doRender(RenderManager.instance,tile.input.get(),0F,-0.2F,-0.35F); + } + bindTexture(tex); //texture + GL11.glScalef(1F, -1F, -1F); + GL11.glTranslatef(0F, -1.0F, 0F); + model.Base.render(1.0F/16.0F); + GL11.glPopMatrix(); +} + + @Override + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) + { + this.renderAModelAt((DetonationSprayingMachineTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java b/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java new file mode 100644 index 0000000..590f6e9 --- /dev/null +++ b/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java @@ -0,0 +1,251 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import ic2.api.network.INetworkTileEntityEventListener; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.core.ContainerBase; +import ic2.core.ExplosionIC2; +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.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; + +public class DetonationSprayingMachineTileEntity extends TileEntityInventory implements IHasGui, INetworkTileEntityEventListener +{ + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("detonationsprayingmachine"); + public final ApparatusProcessableInvSlot input; + private AudioSource explosion; + + public DetonationSprayingMachineTileEntity() { + super(); + this.input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 3, 64); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + return fields; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("cannonBronze"); + } + + @Override + public String getInventoryName() { + return "detonationSprayingMachine"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + + @Override + public void onNetworkEvent(int event) + { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.explode", 4.0F, 1.0F); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new DetonationSprayingMachineGui(new DetonationSprayingMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new DetonationSprayingMachineContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + public boolean canOperate() + { + return getOutput()!=null; + } + + public UniversalRecipeOutput getOutput() + { + return DetonationSprayingMachineTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + public List[] getInput() + { + return new List[] {null,this.input.getItemStackList()}; + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if (IC2.platform.isRendering() && this.explosion==null) + { + this.explosion = IC2.audioManager.createSource(this, PositionSpec.Center, "Machines/MinerOp.ogg",false,false, 0.5F); + } + } + + + public void operate() + {//diamond file max durability - 128000 + //file tags - "GT.ToolStats"->"MaxDamage" & "Damage" + if(this.canOperate()) + { + List output1 = DetonationSprayingMachineTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + ItemStack resultStack = output1.get(0).itemStack.copy(); + resultStack.stackSize=this.input.get(0).stackSize; + if(resultStack.stackTagCompound==null) + { + resultStack.stackTagCompound=this.input.get(0).stackTagCompound; + } + if(resultStack.stackTagCompound!=null && resultStack.stackTagCompound.hasKey("GT.ToolStats")) + { + NBTTagCompound gtTagCompound = resultStack.stackTagCompound.getCompoundTag("GT.ToolStats"); + if(gtTagCompound!=null && gtTagCompound.hasKey("MaxDamage")) + { + int maxDamage = gtTagCompound.getInteger("MaxDamage"); + int damage = 0; + if(gtTagCompound.hasKey("Damage")) + { + damage = gtTagCompound.getInteger("Damage"); + } + if(damage dsmInputs1 = new ArrayList(); + dsmInputs1.add(new RecipeInputItemStack(input)); + dsmInputs1.add(new RecipeInputOreDict("dustDiamond")); + dsmInputs1.add(new RecipeInputOreDict("dustGunpowder")); + recipeManager.addRecipe(new UniversalRecipeInput(null, dsmInputs1), new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output}),1)); + } + + public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) + { + recipeManager.addRecipe(input, output); + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/DrawingDeskContainer.java b/ihl/processing/metallurgy/DrawingDeskContainer.java new file mode 100644 index 0000000..ca570a1 --- /dev/null +++ b/ihl/processing/metallurgy/DrawingDeskContainer.java @@ -0,0 +1,36 @@ +package ihl.processing.metallurgy; + +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 DrawingDeskContainer extends ContainerBase { + + public DrawingDeskTileEntity tileEntity; + public int lastProgress = -1; + private final static int height=166; + + public DrawingDeskContainer(EntityPlayer entityPlayer, + DrawingDeskTileEntity tileEntity1) { + super(tileEntity1); + 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.input, 0, 8, 44)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.output, 0, 127, 44)); + } +} diff --git a/ihl/processing/metallurgy/DrawingDeskGui.java b/ihl/processing/metallurgy/DrawingDeskGui.java new file mode 100644 index 0000000..301e072 --- /dev/null +++ b/ihl/processing/metallurgy/DrawingDeskGui.java @@ -0,0 +1,59 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class DrawingDeskGui extends GuiContainer { + + private DrawingDeskContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIDrawingDesk.png"); + + public DrawingDeskGui(DrawingDeskContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @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(tex); + int i1; + if (this.container.tileEntity.progress > 0) + { + 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.99F); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(38),38); + this.drawTexturedModalRect(68, 30, 176, 0, i1 + 1, 10); + } + } + + @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(tex); + 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; + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 0); + } + +} diff --git a/ihl/processing/metallurgy/DrawingDeskModel.java b/ihl/processing/metallurgy/DrawingDeskModel.java new file mode 100644 index 0000000..55f1c84 --- /dev/null +++ b/ihl/processing/metallurgy/DrawingDeskModel.java @@ -0,0 +1,66 @@ +package ihl.processing.metallurgy; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class DrawingDeskModel extends ModelBase +{ + //fields + IHLModelRenderer RotatePart; + IHLModelRenderer Piece1; + + public DrawingDeskModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("RotatePart.Shape1", 0, 14); + setTextureOffset("RotatePart.Pipe2", 0, 17); + setTextureOffset("RotatePart.Shape4", 3, 14); + setTextureOffset("RotatePart.Shape3", 0, 26); + setTextureOffset("RotatePart.Pipe5", 16, 20); + setTextureOffset("RotatePart.Pipe6", 0, 18); + setTextureOffset("RotatePart.Pipe11", 13, 22); + setTextureOffset("RotatePart.Pipe12", 13, 22); + setTextureOffset("RotatePart.Pipe13", 13, 22); + setTextureOffset("RotatePart.Pipe14", 13, 22); + setTextureOffset("RotatePart.Pipe15", 13, 22); + setTextureOffset("Piece1.Shape7", 0, 17); + setTextureOffset("Piece1.Shape8", 0, 17); + setTextureOffset("Piece1.PipeW9", 0, 18); + setTextureOffset("Piece1.PipeW10", 0, 20); + setTextureOffset("Piece1.Shape2", 0, 0); + + RotatePart = new IHLModelRenderer(this, "RotatePart"); + RotatePart.setRotationPoint(0F, 23F, -6F); + setRotation(RotatePart, 0.4F, 0F, 0F); + RotatePart.mirror = true; + RotatePart.addBox("Shape1", 7F, -1F, -1F, 1, 2, 16,false); + RotatePart.addTube("Pipe2", -7.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addBox("Shape4", -8F, -1F, -1F, 1, 2, 16,false); + RotatePart.addBox("Shape3", -7F, -1F, -1F, 14, 2, 2,false); + RotatePart.addTube("Pipe5", -5.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe6", -3.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe11", -1.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe12", 0.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe13", 2.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe14", 4.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe15", 6.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + Piece1 = new IHLModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = true; + Piece1.addBox("Shape7", 6F, -4F, 6F, 1, 12, 2,false); + Piece1.addBox("Shape8", -7F, -4F, 6F, 1, 12, 2,false); + Piece1.addTube("PipeW9", -6F, 7F, 7F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addTube("PipeW10", -6F, -4F, 6F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addBox("Shape2", 0F, 7F, 0F, 4, 1, 1,false); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/ihl/processing/metallurgy/DrawingDeskTileEntity.java b/ihl/processing/metallurgy/DrawingDeskTileEntity.java new file mode 100644 index 0000000..aed1a97 --- /dev/null +++ b/ihl/processing/metallurgy/DrawingDeskTileEntity.java @@ -0,0 +1,173 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.api.recipe.IRecipeInput; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeInputWire; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class DrawingDeskTileEntity extends TileEntityInventory implements IHasGui, INetworkClientTileEntityEventListener +{ + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("DrawingDesk"); + public short progress; + protected short operationLength=200; + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + boolean isGuiScreenOpened=false; + + public DrawingDeskTileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 1, 64); + output = new IHLInvSlotOutput(this, "output", 1, 1); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if (this.canOperate() && this.isGuiScreenOpened) + { + this.setActive(true); + + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + ++this.progress; + if (this.progress >= this.operationLength) + { + this.operate(); + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + @Override + public String getInventoryName() { + return "DrawingDesk"; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("DrawingDesk"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new DrawingDeskGui(new DrawingDeskContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + this.isGuiScreenOpened=true; + return new DrawingDeskContainer(player, this); + } + + public void operate() + { + List input1 = DrawingDeskTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + List output1 = DrawingDeskTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + this.output.add(output1); + if(input1.get(0) instanceof RecipeInputWire) + { + int fiberLength = input1.get(0).getAmount(); + boolean isFiberConsumed = IHLUtils.adjustWireLength(this.input.get(), -fiberLength); + if(isFiberConsumed) + { + this.input.put(null); + } + } + else + { + this.input.consume(0, input1.get(0).getAmount()); + } + } + + public List[] getInput() + { + return new List[] {null,Arrays.asList(new ItemStack[] {input.get()})}; + } + + public boolean canOperate() + { + if(DrawingDeskTileEntity.recipeManager.getOutputFor(getInput(), false, false)==null) return false; + List output1 = DrawingDeskTileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + return this.output.canAdd(output1); + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public static void addRecipe(ItemStack input, ItemStack output) + { + if(input==null || output==null) throw new NullPointerException(); + recipeManager.addRecipe(new UniversalRecipeInput(null,Arrays.asList(new ItemStack[] {input})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {output}),20)); + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / this.operationLength; + } + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + switch(event) + { + case 0: + this.isGuiScreenOpened=false; + break; + } + } + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/metallurgy/ElectricEngineInvSlot.java b/ihl/processing/metallurgy/ElectricEngineInvSlot.java new file mode 100644 index 0000000..c89c50f --- /dev/null +++ b/ihl/processing/metallurgy/ElectricEngineInvSlot.java @@ -0,0 +1,54 @@ +package ihl.processing.metallurgy; + +import ic2.core.Ic2Items; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; +import net.minecraft.item.ItemStack; + +public class ElectricEngineInvSlot extends InvSlot { + + public ElectricEngineInvSlot(TileEntityInventory base1, String name1, + int oldStartIndex1, Access access1, int count, int stackSizeLimit1) { + super(base1, name1, oldStartIndex1, access1, count); + this.setStackSizeLimit(stackSizeLimit1); + } + + public float getEfficiency() + { + if(this.isEmpty()) + { + return 0F; + } + else if(this.get().getItem() instanceof ElectricEngineItem) + { + return ((ElectricEngineItem)this.get().getItem()).type.efficiency; + } + else if(this.get().getItem() == Ic2Items.elemotor.getItem() && this.get().getItemDamage() == Ic2Items.elemotor.getItemDamage()) + { + return 0.2f; + } + else + { + return 0f; + } + } + + @Override + public boolean accepts(ItemStack stack) + { + if(stack!=null && stack.getItem() == Ic2Items.elemotor.getItem() && stack.getItemDamage() == Ic2Items.elemotor.getItemDamage()) + { + return true; + } + else + { + return stack==null?true:stack.getItem() instanceof ElectricEngineItem; + } + } + + public boolean correctContent() + { + return this.get()==null?false:this.get().stackSize==1 && ((this.get().getItem() instanceof ElectricEngineItem) || (this.get().getItem() == Ic2Items.elemotor.getItem() && this.get().getItemDamage() == Ic2Items.elemotor.getItemDamage())); + } + +} diff --git a/ihl/processing/metallurgy/ElectricEngineItem.java b/ihl/processing/metallurgy/ElectricEngineItem.java new file mode 100644 index 0000000..ec1bdf6 --- /dev/null +++ b/ihl/processing/metallurgy/ElectricEngineItem.java @@ -0,0 +1,84 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; + +public class ElectricEngineItem extends Item{ + + public Type type; + public static List instances = new ArrayList(); + private static Map iconMap = new HashMap(); + + + public ElectricEngineItem(Type type1) + { + super(); + this.type=type1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setUnlocalizedName(type.unLocalizedName); + this.setMaxStackSize(1); + instances.add(this); + } + + public static void init() + { + Type[] var1 = Type.values(); + for(int i=0;i ii = instances.iterator(); + while(ii.hasNext()) + { + ElectricEngineItem instance = ii.next(); + GameRegistry.registerItem(instance,instance.type.unLocalizedName); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) + { + iconMap.put(this.type, register.registerIcon(IHLModInfo.MODID + ":"+this.type.unLocalizedName)); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int i) + { + return iconMap.get(type); + } + + + public enum Type + { + LVLEElectricEngine("electricMotorLVLEDC", 600,400,0.2F,1500); + Type(String unlocalizedName1, int maxVoltage1, int generatedVoltage1, float efficiency1,int rpm1) + { + unLocalizedName=unlocalizedName1; + maxVoltage=maxVoltage1; + generatedVoltage=generatedVoltage1; + efficiency=efficiency1; + rpm=rpm1; + } + + public String unLocalizedName; + public int maxVoltage=600; + public int generatedVoltage=400; + public float efficiency = 0.2F; + public int rpm=1500;//at max voltage + } + +} diff --git a/ihl/processing/metallurgy/ExtruderContainer.java b/ihl/processing/metallurgy/ExtruderContainer.java new file mode 100644 index 0000000..f4af0c0 --- /dev/null +++ b/ihl/processing/metallurgy/ExtruderContainer.java @@ -0,0 +1,75 @@ +package ihl.processing.metallurgy; + +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 ExtruderContainer extends ContainerBase { + + public ExtruderTileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private final static int height=166; + + public ExtruderContainer(EntityPlayer entityPlayer, + ExtruderTileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + 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(lathePart1TileEntity.input, 0, 39, 32)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input2, 0, 57, 32)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.engine,0, 8, 32)); + } + + @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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) 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; + } + } + +} diff --git a/ihl/processing/metallurgy/ExtruderGui.java b/ihl/processing/metallurgy/ExtruderGui.java new file mode 100644 index 0000000..1c10b89 --- /dev/null +++ b/ihl/processing/metallurgy/ExtruderGui.java @@ -0,0 +1,58 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class ExtruderGui extends GuiContainer { + + private ExtruderContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIExtruder.png"); + + public ExtruderGui(ExtruderContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @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(tex); + 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(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(74, 34, 198, 0, i1 + 1, 13); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 34, xOffset, yOffset); + } + } + + @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(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/ExtruderModel.java b/ihl/processing/metallurgy/ExtruderModel.java new file mode 100644 index 0000000..fb28d50 --- /dev/null +++ b/ihl/processing/metallurgy/ExtruderModel.java @@ -0,0 +1,100 @@ +package ihl.processing.metallurgy; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class ExtruderModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer Extruder; + + public ExtruderModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 7); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 0, 0); + setTextureOffset("Belt2.Shape13", 0, 0); + setTextureOffset("Extruder.PipeN16", 0, 0); + setTextureOffset("Extruder.PipeN15", 24, 20); + setTextureOffset("Extruder.Shape8", 0, 0); + setTextureOffset("Extruder.PipeU17", 0, 0); + setTextureOffset("Extruder.PipeUC18", 0, 0); + setTextureOffset("Extruder.Shape14", 0, 0); + setTextureOffset("Extruder.PipeN14", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape16", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -1F, -1F, 1F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0.5F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + Extruder = new IHLModelRenderer(this, "Extruder"); + Extruder.setRotationPoint(0F, 16F, 0F); + setRotation(Extruder, 0F, 0F, 0F); + Extruder.mirror = true; + Extruder.addTube("PipeN16", -4.5F, 0.5F, -5F, 3, 3, 12, 0F,1F,ForgeDirection.NORTH); + Extruder.addTube("PipeN15", -5.5F, -0.5F, 0F, 5, 5, 7, 0.5F,1F,ForgeDirection.NORTH); + Extruder.addBox("Shape8", -5F, 4F, 6.9F, 4, 3, 1); + Extruder.addTube("PipeU17", -5.5F, -8F, -5F, 5, 8, 5, 0.8F,1F,ForgeDirection.UP); + Extruder.addTube("PipeUC18", -5.5F, 0F, -5F, 5, 2, 5, 0.8F,0.6F,ForgeDirection.UP); + Extruder.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Extruder.addTube("PipeN14", -5.5F, -0.5F, 7F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/ExtruderTileEntity.java b/ihl/processing/metallurgy/ExtruderTileEntity.java new file mode 100644 index 0000000..de7a4c7 --- /dev/null +++ b/ihl/processing/metallurgy/ExtruderTileEntity.java @@ -0,0 +1,170 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +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.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.IFluidHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ExtruderTileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final ApparatusProcessableInvSlot input2; + public boolean hasEngine; + private int processTimer=0; + private FluidTank fluidTank = new FluidTank(1000); + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("extruder"); + + public ExtruderTileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 1, 64); + input2 = new ApparatusProcessableInvSlot(this, "input2", 2, Access.IO, 1, 64); + isGuiScreenOpened=true; + } + + + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("hasEngine"); + return fields; + } + + + @Override + public String getInventoryName() { + return "Extruder"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(this.engine.isEmpty() && hasEngine==true) + { + this.hasEngine=false; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + else if(this.engine.correctContent() && hasEngine==false) + { + this.hasEngine=true; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ); + if(checkCorrectAccembly() && this.fluidTank.getFluidAmount()>0 && this.processTimer++>20) + { + this.processTimer=0; + ((IFluidHandler)te).fill(ForgeDirection.getOrientation(getFacing()), this.fluidTank.drain(this.fluidTank.getCapacity(), true), true); + } + + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("extruder"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new ExtruderGui(new ExtruderContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new ExtruderContainer(player, this); + } + + @Override + public void operate() + { + UniversalRecipeInput ri = ExtruderTileEntity.recipeManager.getRecipeInput(getInput()); + this.fluidTank.fill(getOutput().getFluidOutputs().get(0), true); + this.input.consume(0,ri.getItemInputs().get(0).getAmount()); + this.input2.consume(0,ri.getItemInputs().get(1).getAmount()); + } + + public UniversalRecipeOutput getOutput() + { + return ExtruderTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List[] getInput() + { + return new List[]{null,Arrays.asList(new ItemStack[] {input.get(),input2.get()})}; + } + + @Override + public boolean canOperate() + { + return this.fluidTank.getFluidAmount() getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/metallurgy/GasWeldingStationContainer.java b/ihl/processing/metallurgy/GasWeldingStationContainer.java new file mode 100644 index 0000000..2f9e160 --- /dev/null +++ b/ihl/processing/metallurgy/GasWeldingStationContainer.java @@ -0,0 +1,99 @@ +package ihl.processing.metallurgy; + +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; +import net.minecraftforge.fluids.FluidStack; + +public class GasWeldingStationContainer extends ContainerBase { + + protected GasWeldingStationTileEntity tileEntity; + public short lastProgress2 = -1; + private final static int height=166; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public int lastFluidAmount2 = -1; + public int lastNumberOfFluids2 = -1; + public List fluidTankFluidList; + public List fluidTankFluidList2; + + public GasWeldingStationContainer(EntityPlayer entityPlayer, GasWeldingStationTileEntity weldingStation){ + super(weldingStation); + this.tileEntity = weldingStation; + fluidTankFluidList = this.tileEntity.flammableGasTank.getFluidList(); + fluidTankFluidList2 = this.tileEntity.oxygenTank.getFluidList(); + 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(tileEntity.drainInputSlotOxygen, 0, 8, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.drainInputSlotFlammableGas, 0, 44, 15)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlotOxygen, 0, 8, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlotFlammableGas, 0, 44, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 0, 8, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 1, 44, 33)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.input, 0, 62, 51)); + } + + @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.progress2 != this.lastProgress2) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.progress2); + } + if (this.tileEntity.flammableGasTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.flammableGasTank.getNumberOfFluids() != this.lastNumberOfFluids) + { + + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.oxygenTank.getFluidAmount() != this.lastFluidAmount2 || this.tileEntity.oxygenTank.getNumberOfFluids() != this.lastNumberOfFluids2) + { + + IC2.network.get().sendContainerField(this, "fluidTankFluidList2"); + } + } + + + this.lastProgress2 = this.tileEntity.progress2; + this.lastNumberOfFluids = this.tileEntity.flammableGasTank.getNumberOfFluids(); + this.lastFluidAmount = this.tileEntity.flammableGasTank.getFluidAmount(); + this.lastNumberOfFluids2 = this.tileEntity.oxygenTank.getNumberOfFluids(); + this.lastFluidAmount2 = this.tileEntity.oxygenTank.getFluidAmount(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 1: + this.tileEntity.progress2=(short) value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/metallurgy/GasWeldingStationGui.java b/ihl/processing/metallurgy/GasWeldingStationGui.java new file mode 100644 index 0000000..7a34fa6 --- /dev/null +++ b/ihl/processing/metallurgy/GasWeldingStationGui.java @@ -0,0 +1,79 @@ +package ihl.processing.metallurgy; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class GasWeldingStationGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIGasWeldingStation.png"); + private GasWeldingStationContainer container; + private int outputslotoffset=45; + + public GasWeldingStationGui (GasWeldingStationContainer detonationSprayingMachineContainer) { + //the container is instanciated and passed to the superclass for handling + super(detonationSprayingMachineContainer); + this.container=detonationSprayingMachineContainer; + } + + @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.progress2 > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(90, 30, getFrameX(i1), getFrameY(i1),24,24); + } + if (this.container.tileEntity.flammableGasTank.getFluid()!=null && this.container.tileEntity.flammableGasTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.flammableGasTank, 64, 28, 76, 67, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.oxygenTank.getFluid()!=null && this.container.tileEntity.oxygenTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.oxygenTank, 28, 28, 40, 67, zLevel, par1, par2, xOffset, yOffset); + } + + } + + @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 handleMouseClick(Slot slot,int arg1,int arg2,int arg3) + { + if(slot!=null && slot.slotNumber>=outputslotoffset && slot.slotNumber getNetworkedFields() + { + List fields = super.getNetworkedFields(); + return fields; + } + + @Override + public void updateEntityServer() + { + if (this.canProduceGas()) + { + ++this.progress2; + if (this.progress2 >= this.operationLength) + { + this.produceGas(); + this.progress2 = 0; + } + } + else + { + if (!this.canProduceGas()) + { + this.progress2 = 0; + } + } + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotFlammableGas, drainInputSlotFlammableGas, emptyFluidItemsSlot, flammableGasTank); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlotOxygen, drainInputSlotOxygen, emptyFluidItemsSlot, oxygenTank); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.flammableGasTank.readFromNBT(nbttagcompound.getCompoundTag("flammableGasTank")); + this.oxygenTank.readFromNBT(nbttagcompound.getCompoundTag("oxygenTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound flammableGasTankNBT = new NBTTagCompound(); + this.flammableGasTank.writeToNBT(flammableGasTankNBT); + nbttagcompound.setTag("flammableGasTank", flammableGasTankNBT); + NBTTagCompound oxygenTankNBT = new NBTTagCompound(); + this.oxygenTank.writeToNBT(oxygenTankNBT); + nbttagcompound.setTag("oxygenTank", oxygenTankNBT); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("gasWeldingStation"); + } + + @Override + public String getInventoryName() { + return "detonationSprayingMachine"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new GasWeldingStationGui(new GasWeldingStationContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new GasWeldingStationContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + @Override + public void onNetworkEvent(EntityPlayer player, int event) + { + } + + public boolean canProduceGas() + { + UniversalRecipeOutput rOutput = GasWeldingStationTileEntity.acetyleneRecipeManager.getOutputFor(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()}), false, false); + return rOutput!=null; + } + + public void produceGas() + { + if(canProduceGas()) + { + UniversalRecipeInput rInput = GasWeldingStationTileEntity.acetyleneRecipeManager.getRecipeInput(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()})); + UniversalRecipeOutput rOutput = GasWeldingStationTileEntity.acetyleneRecipeManager.getOutputFor(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()}), false, false); + FluidStack output1 = rOutput.getFluidOutputs().get(0).copy(); + FluidStack output2 = rOutput.getFluidOutputs().get(1).copy(); + this.flammableGasTank.drain(rInput.getFluidInputs().get(0), true); + this.input.get().stackSize-=rInput.getItemInputs().get(0).getAmount(); + if(this.input.get().stackSize<=0) + { + this.input.clear(); + } + this.flammableGasTank.fill(output1, true); + this.flammableGasTank.fill(output2, true); + } + } + + + public UniversalRecipeInput getInput() + { + return new UniversalRecipeInput(Arrays.asList(new FluidStack[] {this.flammableGasTank.getLigthestFluid(), this.oxygenTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get(0),this.input.get(1),this.input.get(2)})); + } + + public static void addGasRecipe(ItemStack input, FluidStack inputFluid, FluidStack output, FluidStack output2) + { + acetyleneRecipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {inputFluid}), Arrays.asList(new ItemStack[] {input})), new UniversalRecipeOutput(Arrays.asList(new FluidStack [] {output, output2}),Arrays.asList(new ItemStack [] {}),20)); + } + + public static Map getGasRecipes() { + return acetyleneRecipeManager.getRecipes(); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + FluidStack fstack = this.flammableGasTank.drain(amount, doDrain); + return fstack; + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if(this.flammableGasTank.getFluid().containsFluid(fluidStack)) + { + return this.flammableGasTank.drain(fluidStack.amount, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.oxygenTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] {this.flammableGasTank.getInfo(),this.oxygenTank.getInfo()}; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return true; + } + + public int gaugeProgressScaled(int i) + { + return this.progress2 * i / this.operationLength; + } + + public int gaugeFlammableGasScaled(int i) + { + if(this.flammableGasTank.getFluid()!=null) + { + return this.flammableGasTank.getFluidAmount() * i /this.flammableGasTank.getCapacity(); + } + else + { + return 0; + } + } + + public int gaugeOxygenScaled(int i) + { + if(this.oxygenTank.getFluid()!=null) + { + return this.oxygenTank.getFluidAmount() * i /this.oxygenTank.getCapacity(); + } + else + { + return 0; + } + } + + @Override + public boolean canBeUsed() + { + return + this.flammableGasTank.getFluid()!=null && + this.flammableGasTank.getLigthestFluid().getFluid().getName().equals("acetylene") && + this.flammableGasTank.getLigthestFluid().amount>=20 && + this.oxygenTank.getFluid()!=null && + this.oxygenTank.getLigthestFluid().getFluid().getName().equals("oxygen") && + this.oxygenTank.getLigthestFluid().amount>=20; + } + + @Override + public void use() + { + this.flammableGasTank.drain(IHLUtils.getFluidStackWithSize("acetylene", 20), true); + this.oxygenTank.drain(IHLUtils.getFluidStackWithSize("oxygen", 20), true); + } + + @Override + public boolean getIsInvalid() + { + return this.isInvalid(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/IProductionLine.java b/ihl/processing/metallurgy/IProductionLine.java new file mode 100644 index 0000000..5cf7605 --- /dev/null +++ b/ihl/processing/metallurgy/IProductionLine.java @@ -0,0 +1,12 @@ +package ihl.processing.metallurgy; + +import net.minecraft.item.ItemStack; + +public interface IProductionLine +{ + + short getFacing(); + boolean canProcess(ItemStack stack); + void process(ItemStack stack); + +} diff --git a/ihl/processing/metallurgy/ImpregnatingMachineContainer.java b/ihl/processing/metallurgy/ImpregnatingMachineContainer.java new file mode 100644 index 0000000..4489af2 --- /dev/null +++ b/ihl/processing/metallurgy/ImpregnatingMachineContainer.java @@ -0,0 +1,114 @@ +package ihl.processing.metallurgy; + +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; +import net.minecraftforge.fluids.FluidStack; + +public class ImpregnatingMachineContainer extends ContainerBase { + + protected ImpregnatingMachineTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public int lastVisibleFluidID = -1; + public int lastVisibleFluidAmount = -1; + public short lastProgress = -1; + public short lastTemperature = -1; + private final static int height=166; + public List fluidTankFluidList; + + public ImpregnatingMachineContainer(EntityPlayer entityPlayer, ImpregnatingMachineTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList(); + 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.drainInputSlot, 0, 24, 16)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 24, 34)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 24, 52)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 116, 16)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 116, 41)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 116, 59)); + } + + @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.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.temperature != this.lastTemperature) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature); + } + if (this.tileEntity.visibleFluidId != this.lastVisibleFluidID) + { + icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.visibleFluidId); + } + if (this.tileEntity.visibleFluidAmount != this.lastVisibleFluidAmount) + { + icrafting.sendProgressBarUpdate(this, 3, this.tileEntity.visibleFluidAmount); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastTemperature = this.tileEntity.temperature; + this.lastVisibleFluidID=this.tileEntity.visibleFluidId; + this.lastVisibleFluidAmount=this.tileEntity.visibleFluidAmount; + } + + @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.temperature=(short) value; + break; + case 2: + this.tileEntity.visibleFluidId=value; + break; + case 3: + this.tileEntity.visibleFluidAmount=value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/metallurgy/ImpregnatingMachineGui.java b/ihl/processing/metallurgy/ImpregnatingMachineGui.java new file mode 100644 index 0000000..c6a8b0f --- /dev/null +++ b/ihl/processing/metallurgy/ImpregnatingMachineGui.java @@ -0,0 +1,63 @@ +package ihl.processing.metallurgy; + +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 ImpregnatingMachineGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUITubBronze.png"); + private ImpregnatingMachineContainer container; + + + public ImpregnatingMachineGui (ImpregnatingMachineContainer 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, 0.5F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(138, 28, getFrameX(i1), getFrameY(i1),24,24); + } + if (this.container.tileEntity.getTankAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 50, 11, 107, 72, zLevel, par1, par2, xOffset, yOffset); + } + } + + @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); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/ImpregnatingMachineRender.java b/ihl/processing/metallurgy/ImpregnatingMachineRender.java new file mode 100644 index 0000000..3231b71 --- /dev/null +++ b/ihl/processing/metallurgy/ImpregnatingMachineRender.java @@ -0,0 +1,53 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import ihl.model.FluidRenderer; + +public class ImpregnatingMachineRender extends TileEntitySpecialRenderer{ + + + +public ImpregnatingMachineRender(){} + +public void renderAModelAt(ImpregnatingMachineTileEntity tile, double x, double y, double z, float f) { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y+0.5F, (float)z + 0.5F); + float rotation=0F; + GL11.glRotatef(-rotation, 0F, 1F, 0F); + GL11.glScalef(1F, -1F, -1F); + GL11.glTranslatef(0F, -1.0F, 0F); + GL11.glPopMatrix(); + if (tile.visibleFluidId == -1 || tile.visibleFluidAmount <= 0) { + return; + } + FluidStack fluidStack = new FluidStack(FluidRegistry.getFluid(tile.visibleFluidId),tile.visibleFluidAmount); + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glTranslatef((float) x, (float) y + 0.1F, (float) z); + GL11.glScalef(0.99F, 0.8F*tile.getRenderLiquidLevel(), 0.99F); + int[] displayLists = FluidRenderer.getLiquidDisplayLists(fluidStack); + if (displayLists != null) { + float cap = 900F; + float level = Math.min(fluidStack.amount, cap) / cap; + bindTexture(FluidRenderer.getFluidSheet(fluidStack)); + GL11.glCallList(displayLists[(int) (level * (FluidRenderer.DISPLAY_STAGES - 1))]); + } + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + +} + + @Override + public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) + { + this.renderAModelAt((ImpregnatingMachineTileEntity)par1TileEntity, par2, par4, par6, par8); + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java b/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java new file mode 100644 index 0000000..89a8a63 --- /dev/null +++ b/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java @@ -0,0 +1,393 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.api.network.INetworkTileEntityEventListener; +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 ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ic2.core.network.NetworkManager; +import ihl.interfaces.IHasTemperature; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.chemistry.ChemicalReactorTileEntity; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class ImpregnatingMachineTileEntity extends TileEntityInventory implements IHasGui,INetworkTileEntityEventListener, IFluidHandler, IHasTemperature +{ + private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("tub"); + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput outputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + public short progress; + protected short operationLength=Short.MAX_VALUE/2; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public short temperature=20; + public int visibleFluidId = -1; + public int visibleFluidAmount = 1; + + public ImpregnatingMachineTileEntity() { + super(); + this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 1, 64); + } + + @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 boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("tubBronze"); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List ret = super.getNetworkedFields(); + ret.add("visibleFluidId"); + ret.add("visibleFluidAmount"); + return ret; + } + + @Override + public void updateEntityServer() + { + if(this.fluidTank.getFluid()!=null) + { + if(this.fluidTank.getLigthestFluid().getFluid().isGaseous()) + { + this.fluidTank.drainLightest(10, true); + } + } + if(this.fluidTank.getFluid()!=null && (visibleFluidId!=this.fluidTank.getFluid().getFluid().getID() || visibleFluidAmount!=this.fluidTank.getFluidAmount())) + { + visibleFluidId = this.fluidTank.getFluid().getFluid().getID(); + visibleFluidAmount = this.fluidTank.getFluidAmount(); + IC2.network.get().updateTileEntityField(this, "visibleFluidId"); + IC2.network.get().updateTileEntityField(this, "visibleFluidAmount"); + } + else if(this.fluidTank.getFluid()==null && visibleFluidId!=-1) + { + visibleFluidId=-1; + IC2.network.get().updateTileEntityField(this, "visibleFluidId"); + } + temperature=(short) (this.fluidTank.getTemperature()-273); + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + boolean needsInvUpdate = false; + if (this.canOperate()) + { + this.setActive(true); + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + + this.progress+=this.operationLength/this.getOutput().getTime(); + if (this.progress >= this.operationLength) + { + this.operate(); + needsInvUpdate = true; + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) + { + FluidStack fstack = this.fluidTank.drain(amount, doDrain); + return fstack; + } + + + //1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return true; + } + + @Override + public String getInventoryName() { + return "impregnatingMachine"; + } + + private int mX() + { + switch(this.getFacing()) + { + case 4: + return -1; + case 5: + return 1; + default: + return 0; + } + } + + private int mZ() + { + switch(this.getFacing()) + { + case 3: + return 1; + case 2: + return -1; + case 4: + return 0; + case 5: + return 0; + default: + return -1; + } + } + + private short getFacingFromXZ(int x, int z) + { + switch(x) + { + case -1: + return (short)4; + case 1: + return (short)5; + default: + switch(z) + { + case 1: + return (short)3; + case -1: + return (short)2; + default: + return (short)2; + } + } + } + + public float getRenderLiquidLevel() + { + return (float)this.visibleFluidAmount/(float)this.fluidTank.getCapacity(); + } + + @Override + public void onNetworkEvent(int event) + { + } + + public int gaugeProgressScaled(int i) + { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new ImpregnatingMachineGui(new ImpregnatingMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + this.fluidTank.sortFluidsByDensity(); + return new ImpregnatingMachineContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) {} + + public boolean canOperate() + { + return getOutput()!=null && this.outputSlot.canAdd(getOutput().getItemOutputs()); + } + + public UniversalRecipeOutput getOutput() + { + return ImpregnatingMachineTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + public List[] getInput() + { + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addQuenchingRecipe(String nameHot, String nameQuenched) + { + addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {new FluidStack(FluidRegistry.WATER, 50)}), Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack(nameHot)})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStack(nameQuenched)}),2)); + } + + public IHLFluidTank getFluidTank() + { + return this.fluidTank; + } + + public static void addChemicalRecipe(UniversalRecipeInput universalRecipeInput, UniversalRecipeOutput universalRecipeOutput) + { + addRecipe(universalRecipeInput,universalRecipeOutput); + ChemicalReactorTileEntity.addRecipe(universalRecipeInput,universalRecipeOutput); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + + @Override + public int getTemperature() + { + return this.fluidTank.getTemperature(); + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/InjectionMoldBlock.java b/ihl/processing/metallurgy/InjectionMoldBlock.java new file mode 100644 index 0000000..68a9ea9 --- /dev/null +++ b/ihl/processing/metallurgy/InjectionMoldBlock.java @@ -0,0 +1,254 @@ +package ihl.processing.metallurgy; + +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.items_blocks.IHLItemBlock; +import ihl.metallurgy.constants.Details; +import ihl.utils.IHLUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +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.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class InjectionMoldBlock extends Block implements ITileEntityProvider{ + + IIcon textureSide; + + public static InjectionMoldBlock instance; + public static int moldDamageForRecipe=0; + public static String[] materials = new String[] {"Bronze","Steel","Gold","Magnesium", "Lithium", "TarPitch"}; + + public InjectionMoldBlock() + { + super(Material.rock); + this.setResistance(0.5F); + this.setHardness(0.5F); + this.setBlockName("injectionMold"); + this.setCreativeTab(IHLCreativeTab.tab); + instance=this; + } + + public static void init() + { + GameRegistry.registerBlock(new InjectionMoldBlock(),IHLItemBlock.class,"injectionMold"); + GameRegistry.registerTileEntity(InjectionMoldTileEntity.class,"injectionMoldTileEntity"); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag); + } + + + @Override + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) + { + ItemStack result = new ItemStack(item); + result.stackTagCompound=new NBTTagCompound(); + result.stackTagCompound.setString("resultSuffix", "ingot"); + itemList.add(result); + } + + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new InjectionMoldTileEntity(); + } + + @Override + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) + { + if(!world.isRemote) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te!=null && te instanceof InjectionMoldTileEntity) + { + InjectionMoldTileEntity gte = (InjectionMoldTileEntity) te; + gte.dropContents(); + } + } + super.onBlockPreDestroy(world, x, y, z, meta); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList drops = new ArrayList(); + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null) + { + InjectionMoldTileEntity te = (InjectionMoldTileEntity)t; + if(te.result!=null)drops.add(te.result); + if(te.result2!=null)drops.add(te.result2); + } + return drops; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":injectionMoldTop"); + this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":injectionMoldSide"); + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @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 InjectionMoldTileEntity) + { + InjectionMoldTileEntity te = (InjectionMoldTileEntity)t; + te.resultSuffix=itemStack.stackTagCompound.getString("resultSuffix"); + if(itemStack.stackTagCompound.hasKey("isContainStearin")) + { + te.isContainStearin=itemStack.stackTagCompound.getBoolean("isContainStearin"); + } + if(itemStack.stackTagCompound.hasKey("maxAmount")) + { + te.maxAmount=itemStack.stackTagCompound.getByte("maxAmount"); + } + + } + } + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z) + { + if(player.getCurrentEquippedItem()!=null && player.getCurrentEquippedItem().getItem() instanceof Crucible) + { + if(!world.isRemote) + { + return ((Crucible)player.getCurrentEquippedItem().getItem()).onItemUse(player.getCurrentEquippedItem(), player, world, x, y, z, 0, pos_x, pos_y, pos_z); + } + return true; + } + return false; + } + + + + /** + * Called when the block is placed in the world. + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + switch (side) + { + case 1: + return this.blockIcon; + case 0: + return this.textureSide; + case 2: + return this.textureSide; + case 3: + return this.textureSide; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + IIcon sideIcon = this.blockIcon; + switch (side) + { + case 1: + return this.blockIcon; + case 0: + return this.textureSide; + case 2: + return this.textureSide; + case 3: + return this.textureSide; + case 4: + return this.textureSide; + case 5: + return this.textureSide; + default: + return this.textureSide; + } + } + + public ItemStack getSandInjectionMoldForResult(String result1) + { + ItemStack stack = new ItemStack(this); + stack.stackTagCompound=new NBTTagCompound(); + stack.stackTagCompound.setString("resultSuffix", result1); + registerRecipes(result1, stack); + return stack; + } + + public ItemStack getGypsumInjectionMoldForResult(String result1) + { + ItemStack stack = new ItemStack(this); + stack.stackTagCompound=new NBTTagCompound(); + stack.stackTagCompound.setString("resultSuffix", result1); + stack.stackTagCompound.setByte("maxAmount", (byte)1); + stack.stackTagCompound.setBoolean("isContainStearin", true); + registerRecipes(result1, stack); + return stack; + } + + public static void registerRecipes(String result1,ItemStack stack1) + { + if (Loader.isModLoaded("NotEnoughItems")) + { + for(int i=0;i16) + { + if(this.timer--==0) + { + String formattedFluidName=this.getFormattedMaterialName(this.getFluidfromTank().getName()); + if(formattedFluidName!="") + { + int fluidAmountPerItem = Details.getMeltingFluidAmount(this.resultSuffix); + int fluidAmountPerItem2 = Details.getMeltingFluidAmount("nugget"); + ArrayList resultList = OreDictionary.getOres(this.resultSuffix+formattedFluidName); + if(resultList.isEmpty()) + { + resultList=new ArrayList(); + if(IHLUtils.getItemStackIfExist(this.resultSuffix+formattedFluidName)!=null)resultList.add(IHLUtils.getItemStackIfExist(this.resultSuffix+formattedFluidName)); + } + ArrayList resultList2 = OreDictionary.getOres("nugget"+formattedFluidName); + if(!resultList.isEmpty()) + { + if(fluidAmountPerItem>0) + { + int stackSize1=Math.min(this.maxAmount,this.getFluidStackfromTank().amount/fluidAmountPerItem); + if(stackSize1>0) + { + result=resultList.get(0).copy(); + result.stackSize=stackSize1; + } + } + } + if(!resultList2.isEmpty()) + { + int stackSize1=this.getFluidStackfromTank().amount/fluidAmountPerItem2; + if(result!=null) + { + stackSize1=(this.getFluidStackfromTank().amount % fluidAmountPerItem)/fluidAmountPerItem2; + } + if(stackSize1>0) + { + result2=resultList2.get(0).copy(); + result2.stackSize=stackSize1; + } + } + } + } + } + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid fluid1) { + return direction==ForgeDirection.UP && !isContainStearin; + } + + public String getInventoryName() { + return "injectionMold"; + } + + private String getFormattedMaterialName(String input) + { + if(input.length()<8) + { + return ""; + } + String input2 = input.replace("molten.", "").replace(".molten", ""); + String firstletter = String.valueOf(input2.charAt(0)).toUpperCase(); + input2 = input2.replaceFirst(".", firstletter); + return input2; + } + + public FluidTank getFluidTank() + { + return this.fluidTank; + } + + public FluidStack getFluidStackfromTank() + { + return this.getFluidTank().getFluid(); + } + + public Fluid getFluidfromTank() + { + return this.getFluidStackfromTank().getFluid(); + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + { + return this.canFill(from, resource.getFluid()) ? this.getFluidTank().fill(resource, doFill) : 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + { + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + return this.getFluidTank().drain(maxDrain, doDrain); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) + { + return new FluidTankInfo[] {this.getFluidTank().getInfo()}; + } + + public void dropContents() + { + if(result!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, result)); + if(result2!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, result2)); + } + + public static Map getRecipes() + { + return recipeManager.getRecipes(); + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/LatheContainer.java b/ihl/processing/metallurgy/LatheContainer.java new file mode 100644 index 0000000..c863f7b --- /dev/null +++ b/ihl/processing/metallurgy/LatheContainer.java @@ -0,0 +1,72 @@ +package ihl.processing.metallurgy; + +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 LatheContainer extends ContainerBase { + + public LathePart1TileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private final static int height=166; + + public LatheContainer(EntityPlayer entityPlayer, + LathePart1TileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + 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(lathePart1TileEntity.engine,0, 22, 55)); + } + + @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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) 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; + } + } + +} diff --git a/ihl/processing/metallurgy/LatheGui.java b/ihl/processing/metallurgy/LatheGui.java new file mode 100644 index 0000000..e09f414 --- /dev/null +++ b/ihl/processing/metallurgy/LatheGui.java @@ -0,0 +1,60 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class LatheGui extends GuiContainer { + + private LatheContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUILathe.png"); + + public LatheGui(LatheContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @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); + fontRendererObj.drawString(StatCollector.translateToLocal("ihl.gui.lathe"), 50, 10, 14722081); + this.mc.renderEngine.bindTexture(tex); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + 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, 1.0F); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(50),50); + this.drawTexturedModalRect(64, 63, 197, 0, i1 + 1, 13); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 47, 56, xOffset, yOffset); + } + } + + @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(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/LathePart1Model.java b/ihl/processing/metallurgy/LathePart1Model.java new file mode 100644 index 0000000..c08b3bf --- /dev/null +++ b/ihl/processing/metallurgy/LathePart1Model.java @@ -0,0 +1,93 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class LathePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + + public LathePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.NewShape4", 0, 0); + setTextureOffset("RotatingPart2.PipeN1", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.Shape1", 56, 19); + setTextureOffset("RotatingPart2.Shape5", 0, 8); + setTextureOffset("RotatingPart2.Shape8", 0, 11); + setTextureOffset("RotatingPart2.PipeN4", 0, 0); + setTextureOffset("RotatingPart2.Shape9", 0, 0); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 46, 0); + setTextureOffset("Belt2.Shape13", 46, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5.5F, -1.5F, -7F, 7, 9, 1); + Base.addBox("Shape2", -5.5F, -0.5F, -4F, 5, 8, 1); + Base.addBox("NewShape4", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN1", -1.5F, -1.5F, 0F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addBox("Shape1", 2F, -0.5F, 8.5F, 3, 1, 1); + RotatingPart2.addBox("Shape5", -0.5F, -5F, 8.5F, 1, 3, 1); + RotatingPart2.addBox("Shape8", -5F, -0.5F, 8.5F, 3, 1, 1); + RotatingPart2.addTube("PipeN4", -4F, -4F, 4F, 8, 8, 5, 0.3F,1F,ForgeDirection.NORTH); + RotatingPart2.addBox("Shape9", -0.5F, 2F, 8.5F, 1, 3, 1); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(0F, 21F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", 3F, -2F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", 4F, -1F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", 3F, -2F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/LathePart1TileEntity.java b/ihl/processing/metallurgy/LathePart1TileEntity.java new file mode 100644 index 0000000..9241ba1 --- /dev/null +++ b/ihl/processing/metallurgy/LathePart1TileEntity.java @@ -0,0 +1,98 @@ +package ihl.processing.metallurgy; + +import java.util.List; +import ic2.core.ContainerBase; +import ihl.interfaces.IWorkspaceElement; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class LathePart1TileEntity extends BasicElectricMotorTileEntity implements IWorkspaceElement{ + + public boolean ready=false; + + public LathePart1TileEntity() + { + super(); + this.isGuiScreenOpened=true; + } + + + @Override + public String getInventoryName() { + return "Lathe"; + } + + @Override + public void operate() + { + ready=true; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("lathePart1"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new LatheGui(new LatheContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new LatheContainer(player, this); + } + + + @Override + public List[] getInput() + { + return null; + } + + @Override + public boolean canOperate() + { + TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ); + if(te!=null && te instanceof LathePart2TileEntity) + { + return !ready; + } + return false; + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + @Override + public boolean canBeUsed() + { + return ready; + } + + @Override + public void use() + { + ready=false; + } + + @Override + public boolean getIsInvalid() + { + return this.isInvalid(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} diff --git a/ihl/processing/metallurgy/LathePart2Model.java b/ihl/processing/metallurgy/LathePart2Model.java new file mode 100644 index 0000000..40b9b2a --- /dev/null +++ b/ihl/processing/metallurgy/LathePart2Model.java @@ -0,0 +1,87 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class LathePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public LathePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.Shape2", 38, 5); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape4", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.PipeN7", 0, 0); + setTextureOffset("Base.Shape7", 0, 0); + setTextureOffset("Base.PipeW9", 0, 0); + setTextureOffset("Base.PipeW9", 0, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape12", 0, 0); + setTextureOffset("Base.PipeW13", 0, 0); + setTextureOffset("Base.PipeN13", 0, 0); + setTextureOffset("Base.Shape13", 0, 0); + setTextureOffset("Base.Shape14", 0, 0); + setTextureOffset("Base.PipeU15", 0, 0); + setTextureOffset("Base.PipeU16", 0, 0); + setTextureOffset("Base.PipeU17", 0, 0); + setTextureOffset("Base.PipeU18", 0, 0); + setTextureOffset("Base.Shape15", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.PipeW20", 0, 0); + setTextureOffset("Base.PipeW19", 0, 0); + setTextureOffset("Base.PipeN21", 0, 0); + setTextureOffset("Base.PipeN22", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 14, 1, 16); + Base.addBox("Shape1", 0F, 1F, 0F, 4, 1, 4); + Base.addBox("Shape2", -2F, 2F, 1F, 5, 1, 1); + Base.addBox("Shape3", 0F, 3F, 0F, 4, 2, 4); + Base.addBox("Shape4", 2F, 6F, -8F, 1, 1, 16); + Base.addBox("Shape5", 5F, 6F, -8F, 1, 1, 13); + Base.addTube("PipeN7", 3.5F, 6F, -7F, 1, 1, 12, 0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape7", 3F, 6F, -8F, 2, 1, 1); + Base.addTube("PipeW9", 6F, 5F, 5F, 1, 3, 3, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeW9", 7F, 6F, 5.2F, 1, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addBox("Shape9", 3F, 5F, 5F, 3, 2, 3); + Base.addBox("Shape10", -2F, 5F, 0F, 8, 1, 1); + Base.addBox("Shape11", -2F, 5F, 3F, 8, 1, 1); + Base.addBox("Shape12", 1F, 5F, 1F, 2, 1, 2); + Base.addTube("PipeW13", -1F, 5F, 1.5F, 6, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeN13", -4F, 1F, 3F, 2, 2, 3, 0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape13", -3.5F, 2F, 3.8F, 1, 5, 2); + Base.addBox("Shape14", -4.5F, 6F, 2F, 3, 1, 4); + Base.addTube("PipeU15", 0F, 2F, 3F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU16", 3F, 2F, 3F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU17", 3F, 2F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU18", 0F, 2F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addBox("Shape15", 5F, 5F, 1F, 1, 1, 2); + Base.addBox("Shape16", -2F, 5F, 1F, 1, 1, 2); + Base.addTube("PipeW20", 6F, 4F, 0.5F, 1, 3, 3, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeW19", 7F, 5F, 0.8F, 1, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeN21", -4.5F, 0.5F, 6F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN22", -3F, 1F, 7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + +} diff --git a/ihl/processing/metallurgy/LathePart2TileEntity.java b/ihl/processing/metallurgy/LathePart2TileEntity.java new file mode 100644 index 0000000..4543afa --- /dev/null +++ b/ihl/processing/metallurgy/LathePart2TileEntity.java @@ -0,0 +1,105 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class LathePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{ + + private short facing=2; + private short lastFacing=2; + + public LathePart2TileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("lathePart2"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } +} diff --git a/ihl/processing/metallurgy/MachineBaseContainer.java b/ihl/processing/metallurgy/MachineBaseContainer.java new file mode 100644 index 0000000..19985fe --- /dev/null +++ b/ihl/processing/metallurgy/MachineBaseContainer.java @@ -0,0 +1,74 @@ +package ihl.processing.metallurgy; + +import ic2.core.ContainerBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; + +public class MachineBaseContainer extends ContainerBase { + + protected MachineBaseTileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy; + private final static int height=166; + + public MachineBaseContainer(EntityPlayer entityPlayer, MachineBaseTileEntity 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)); + } + + } + + @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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastProgress = this.tileEntity.progress; + } + + @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/processing/metallurgy/MachineBaseTileEntity.java b/ihl/processing/metallurgy/MachineBaseTileEntity.java new file mode 100644 index 0000000..51df187 --- /dev/null +++ b/ihl/processing/metallurgy/MachineBaseTileEntity.java @@ -0,0 +1,282 @@ +package ihl.processing.metallurgy; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.audio.AudioSource; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.recipes.UniversalRecipeOutput; +import java.util.List; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class MachineBaseTileEntity extends TileEntityInventory implements IHasGui, IEnergySink +{ + public short progress; + protected short operationLength=200; + private AudioSource startAS; + private AudioSource loopAS; + private AudioSource stopAS; + protected double energy; + public int maxStorage; + public int energyConsume; + public final ApparatusProcessableInvSlot input; + private boolean addedToEnergyNet=false; + + public MachineBaseTileEntity(int inputCount) + { + input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, inputCount, 64); + maxStorage=128; + energyConsume=5; + } + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + return fields; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.progress = nbttagcompound.getShort("progress"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("progress", this.progress); + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + @Override + public void onUnloaded() + { + 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 void setFacing(short facing1) + { + if (IC2.platform.isSimulating()&&this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + super.setFacing(facing1); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + public abstract String getStartSoundFile(); + + public abstract String getLoopSoundFile(); + + public abstract String getStopSoundFile(); + + @Override + public void updateEntityServer() + { + if(this.energy>this.maxStorage) + { + this.energy=this.maxStorage; + } + + if (this.canOperate() && this.energy >= this.energyConsume) + { + this.setActive(true); + + if (this.progress == 0) + { + IC2.network.get().initiateTileEntityEvent(this, 0, true); + } + + ++this.progress; + this.energy -= this.energyConsume; + + if (this.progress >= this.operationLength) + { + this.operate(); + this.progress = 0; + IC2.network.get().initiateTileEntityEvent(this, 2, true); + } + } + else + { + if (this.progress != 0 && this.getActive()) + { + IC2.network.get().initiateTileEntityEvent(this, 1, true); + } + if (!this.canOperate()) + { + this.progress = 0; + } + this.setActive(false); + } + } + + protected int mX() + { + switch(this.getFacing()) + { + case 4: + return 1; + case 5: + return -1; + default: + return 0; + } + } + + protected int mY() + { + switch(this.getFacing()) + { + case 0: + return -1; + case 1: + return 1; + default: + return 0; + } + } + + protected int mZ() + { + switch(this.getFacing()) + { + case 2: + return 1; + case 3: + return -1; + default: + return 0; + } + } + + @Override + public abstract String getInventoryName(); + + @Override + @SideOnly(Side.CLIENT) + public abstract GuiScreen getGui(EntityPlayer arg0, boolean arg1); + + @Override + public abstract ContainerBase getGuiContainer(EntityPlayer arg0); + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public int gaugeProgressScaled(int i) + { + return this.progress * i / this.operationLength; + } + + public boolean canOperate() + { + return getOutput()!=null; + } + + public abstract UniversalRecipeOutput getOutput(); + + public List[] getInput() + { + return new List[]{null, this.input.getItemStackList()}; + } + + + @Override + public double getDemandedEnergy() + { + return this.maxStorage - this.energy; + } + + @Override + public int getSinkTier() + { + return 4; + } + + @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 boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) + { + return true; + } + + + public abstract void operate(); + public short getEnergy() { + return (short)this.energy; + } + public void setEnergy(int value) + { + this.energy=value; + } + public int getGUIEnergy(int i) { + if(this.energy 0D) + { + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(8, 14 + 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(44, 57, 197, 0, i1 + 1, 13); + } + fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("ihl.gui.muffleFurnace"), 40, 12, 16768125); + + } + + @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(muffleFurnaceBackground); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/MuffleFurnanceContainer.java b/ihl/processing/metallurgy/MuffleFurnanceContainer.java new file mode 100644 index 0000000..a36ac3c --- /dev/null +++ b/ihl/processing/metallurgy/MuffleFurnanceContainer.java @@ -0,0 +1,15 @@ +package ihl.processing.metallurgy; + +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; + +public class MuffleFurnanceContainer extends MachineBaseContainer { + + public MuffleFurnanceContainer(EntityPlayer entityPlayer, + MachineBaseTileEntity tileEntity1) { + super(entityPlayer, tileEntity1); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 51, 34)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 69, 34)); + } + +} diff --git a/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java b/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java new file mode 100644 index 0000000..73d12de --- /dev/null +++ b/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java @@ -0,0 +1,135 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.core.ContainerBase; +import ihl.IHLMod; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class MuffleFurnanceTileEntity extends MachineBaseTileEntity{ + + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("mufflefurnace"); + + public MuffleFurnanceTileEntity() + { + super(2); + } + + @Override + public String getStartSoundFile() { + return null; + } + + @Override + public String getLoopSoundFile() { + return null; + } + + @Override + public String getStopSoundFile() { + return null; + } + + @Override + public String getInventoryName() { + return "MuffleFurnance"; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new MuffleFurnaceGui(new MuffleFurnanceContainer(player, this)); + } + + @Override + 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 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 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) + { + recipeManager.addRecipe(universalRecipeInput, universalRecipeOutput); + } + + public static void addRecipe(ItemStack input1, ItemStack output, float f) { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack [] {input1})),new UniversalRecipeOutput(null, Arrays.asList(new RecipeOutputItemStack [] {new RecipeOutputItemStack(output,f)}),20)); + } +} diff --git a/ihl/processing/metallurgy/PassiveBlock.java b/ihl/processing/metallurgy/PassiveBlock.java new file mode 100644 index 0000000..74eb0e8 --- /dev/null +++ b/ihl/processing/metallurgy/PassiveBlock.java @@ -0,0 +1,99 @@ +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 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(50),50); + this.drawTexturedModalRect(64, 63, 197, 0, i1 + 1, 13); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 47, 56, xOffset, yOffset); + } + } + + @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(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/RollingMachinePart1Model.java b/ihl/processing/metallurgy/RollingMachinePart1Model.java new file mode 100644 index 0000000..460ff62 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachinePart1Model.java @@ -0,0 +1,97 @@ +package ihl.processing.metallurgy; + + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + + +public class RollingMachinePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer RotatingPart1; + IHLModelRenderer Plate; + + public RollingMachinePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 0, 0); + setTextureOffset("RotatingPart2.PipeN17", 0, 0); + setTextureOffset("RotatingPart2.Shape3", 0, 0); + setTextureOffset("RotatingPart2.Shape12", 0, 0); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("RotatingPart1.Shape1", 0, 0); + setTextureOffset("RotatingPart1.Shape2", 0, 0); + setTextureOffset("RotatingPart1.Shape13", 0, 0); + setTextureOffset("Plate.Shape14", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape16", -3F, -7F, -6F, 9, 14, 1); + Base.addBox("Shape5", 2F, -1F, -5F, 6, 1, 13); + Base.addBox("Shape8", -8F, -1F, -5F, 6, 1, 13); + Base.addBox("Shape11", 3F, 0F, 7F, 4, 7, 1); + Base.addBox("Shape9", -7F, 0F, 7F, 4, 7, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(0F, 16F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -5.5F, -5.5F, -0.9F, 11, 11, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN17", -2F, -2F, 2F, 4, 4, 26, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("Shape3", -2.5F, -2.5F, 0F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("Shape12", -1F, -1F, 28F, 2, 2, 3, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + RotatingPart1 = new IHLModelRenderer(this, "RotatingPart1"); + RotatingPart1.setRotationPoint(0F, 11.9F, -5F); + setRotation(RotatingPart1, 0F, 0F, 0F); + RotatingPart1.mirror = true; + RotatingPart1.addTube("Shape1", -2F, -2F, 0F, 4, 4, 26, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("Shape2", -2.5F, -2.5F, -1.9F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("Shape13", -1F, -1F, 26F, 2, 2, 3, 0F,1F,ForgeDirection.NORTH); + Plate = new IHLModelRenderer(this, "Plate"); + Plate.setRotationPoint(0F, 13.5F, 0F); + setRotation(Plate, 0F, 0F, 0F); + Plate.mirror = true; + Plate.addBox("Shape14", -18F, 0F, 0F, 16, 1, 16); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java b/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java new file mode 100644 index 0000000..9c02a47 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java @@ -0,0 +1,161 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RollingMachinePart1TileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + public boolean hasEngine; + public boolean assembled; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("rollingmachine"); + + public RollingMachinePart1TileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 1, 64); + output = new IHLInvSlotOutput(this, "output", 2, 1); + isGuiScreenOpened=true; + } + + public UniversalRecipeOutput getOutput() + { + return RollingMachinePart1TileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("assembled"); + fields.add("hasEngine"); + return fields; + } + + + @Override + public String getInventoryName() { + return "RollingMachine"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(assembled && !this.checkCorrectAccembly()) + { + assembled=false; + IC2.network.get().updateTileEntityField(this, "assembled"); + } + else if(!assembled && this.checkCorrectAccembly()) + { + assembled=true; + IC2.network.get().updateTileEntityField(this, "assembled"); + } + if(this.engine.isEmpty() && hasEngine==true) + { + this.hasEngine=false; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + else if(this.engine.correctContent() && hasEngine==false) + { + this.hasEngine=true; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + + if (this.getActive() && this.progress == 0 && !this.canOperate()) + { + this.setActive(false); + } + + if (!this.getActive() && this.progress>0 && this.canOperate()) + { + this.setActive(true); + } + + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("rollingMachinePart1"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new RollingMachineGui(new RollingMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new RollingMachineContainer(player, this); + } + + @Override + public void operate() + { + List output = RollingMachinePart1TileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + this.output.add(output); + this.input.consume(0, 1); + } + + @Override + public List[] getInput() + { + return new List[]{null, Arrays.asList(new ItemStack[] {input.get()})}; + } + + @Override + public boolean canOperate() + { + return this.engine.correctContent() && this.getOutput()!=null && this.output.canAdd(this.getOutput().getItemOutputs()) && checkCorrectAccembly(); + } + + private boolean checkCorrectAccembly() + { + TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ); + return te!=null && te instanceof RollingMachinePart2TileEntity && ((RollingMachinePart2TileEntity)te).getFacing()==this.getFacing(); + } + + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public static void addRecipe(ItemStack input, ItemStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack [] {input})), new UniversalRecipeOutput(null, Arrays.asList(new ItemStack[] {output}), 20)); + } + + + public static Map getRecipes() { + return recipeManager.getRecipes(); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/metallurgy/RollingMachinePart2Model.java b/ihl/processing/metallurgy/RollingMachinePart2Model.java new file mode 100644 index 0000000..b4bda67 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachinePart2Model.java @@ -0,0 +1,42 @@ +package ihl.processing.metallurgy; + + +import net.minecraft.client.model.ModelBase; +import ihl.model.IHLModelRenderer; + +public class RollingMachinePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public RollingMachinePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape9", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape16", -3F, -7F, 5F, 6, 14, 1); + Base.addBox("Shape5", 2F, -1F, -8F, 6, 1, 13); + Base.addBox("Shape8", -8F, -1F, -8F, 6, 1, 13); + Base.addBox("Shape11", 3F, 0F, -8F, 4, 7, 1); + Base.addBox("Shape9", -7F, 0F, -8F, 4, 7, 1); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java b/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java new file mode 100644 index 0000000..6bab8c4 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java @@ -0,0 +1,105 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class RollingMachinePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{ + + private short facing=2; + private short lastFacing=2; + + public RollingMachinePart2TileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("rollingMachinePart2"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } + +} diff --git a/ihl/processing/metallurgy/RollingMachineRender.java b/ihl/processing/metallurgy/RollingMachineRender.java new file mode 100644 index 0000000..ee8b567 --- /dev/null +++ b/ihl/processing/metallurgy/RollingMachineRender.java @@ -0,0 +1,84 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; + +public class RollingMachineRender extends TileEntitySpecialRenderer{ +private RollingMachinePart1Model model = new RollingMachinePart1Model(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png"); +private final float scale=1F/16F; + + public RollingMachineRender() {} + + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)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; + } + } + else + { + return; + } + RollingMachinePart1TileEntity cte = (RollingMachinePart1TileEntity)tile; + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + + bindTexture(tex); + model.Base.render(scale); + if(cte.getActive()) + { + model.RotatingPart1.rotateAngleZ-=0.01F; + model.RotatingPart2.rotateAngleZ+=0.01F; + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + model.MotorPart1.rotateAngleZ-=0.03F; + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + model.Plate.offsetX+=0.001F; + if(model.Plate.offsetX>1F){model.Plate.offsetX=0;} + model.Plate.render(scale); + } + else + { + model.Plate.offsetX=0F; + if(cte.assembled) + { + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + } + if(cte.hasEngine) + { + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + } + } + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java new file mode 100644 index 0000000..75c69e8 --- /dev/null +++ b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceContainer.java @@ -0,0 +1,77 @@ +package ihl.processing.metallurgy; + +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.minecraftforge.fluids.FluidStack; + +public class VacuumInductionMeltingFurnaceContainer extends ContainerBase { + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public short lastEnergy = -1; + public VacuumInductionMeltingFurnaceTileEntity tileEntity; + private final static int height=166; + public List 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 new file mode 100644 index 0000000..8b9ea9e --- /dev/null +++ b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceGui.java @@ -0,0 +1,87 @@ +package ihl.processing.metallurgy; + +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +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; + } + + @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) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + 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 new file mode 100644 index 0000000..3fc85a8 --- /dev/null +++ b/ihl/processing/metallurgy/VacuumInductionMeltingFurnaceTileEntity.java @@ -0,0 +1,260 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.Map; + +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.core.ContainerBase; +import ihl.IHLMod; +import ihl.processing.chemistry.GaedesMercuryRotaryPumpTileEntity; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.tunneling_shield.IMultiBlock; +import ihl.tunneling_shield.MultiBlockSpacerBlock; +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, IMultiBlock{ + + protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("vacuuminductionmeltingfurnace"); + public final IHLFluidTank fluidTank = new IHLFluidTank(864); + public boolean vacuumPumpConnected=false; + private GaedesMercuryRotaryPumpTileEntity lastGMRP; + private int minX,minY,minZ,maxX,maxY,maxZ; + + public VacuumInductionMeltingFurnaceTileEntity() + { + super(1); + } + + @Override + public void setFacing(short facing1) + { + short facing2 = (short) Math.max(facing1, 2); + super.setFacing(facing2); + switch(facing2) + { + case 0: + setupMultiblockStructure(-1,-2,0); + break; + case 1: + setupMultiblockStructure(-1,0,0); + break; + case 2: + setupMultiblockStructure(-1,0,-2); + break; + case 3: + setupMultiblockStructure(-1,0,0); + break; + case 4: + setupMultiblockStructure(-2,0,-1); + break; + case 5: + setupMultiblockStructure(0,0,-1); + break; + } + } + + @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); + } + + private void setupMultiblockStructure(int x0,int y0,int z0) + { + minX=xCoord+x0; + maxX=xCoord+x0+3; + minY=yCoord+y0; + maxY=yCoord+y0+3; + minZ=zCoord+z0; + maxZ=zCoord+z0+3; + for(int ix=xCoord+x0;ix=minX && x<=maxX && y>=minY && y<=maxY && z>=minZ && z<=maxZ; + } + + @Override + public boolean getIsInvalid() + { + return this.isInvalid(); + } + +} diff --git a/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java b/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java new file mode 100644 index 0000000..e3ab6c7 --- /dev/null +++ b/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java @@ -0,0 +1,54 @@ +package ihl.processing.metallurgy; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class VulcanizationExtrudingMoldModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public VulcanizationExtrudingMoldModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.PipeW161", 0, 0); + setTextureOffset("Base.PipeN16", 0, 0); + setTextureOffset("Base.PipeW15", 22, 22); + setTextureOffset("Base.PipeW17", 0, 0); + setTextureOffset("Base.Shape14", 0, 0); + setTextureOffset("Base.PipeN14", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape4", 42, 17); + setTextureOffset("Base.Shape5", 37, 17); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape16", 6.9F, 3F, -1.5F, 1, 4, 3); + Base.addTube("PipeW161", -7F, 0.5F, -1.5F, 15, 3, 3, 0.5F,1F,ForgeDirection.WEST); + Base.addTube("PipeN16", -4.5F, 0.5F, -6F, 3, 3, 6, 0.8F,1F,ForgeDirection.NORTH); + Base.addTube("PipeW15", -5.5F, -0.5F, -2.5F, 12, 5, 5, 0.5F,1F,ForgeDirection.WEST); + Base.addTube("PipeW17", -8F, -0.5F, -2.5F, 1, 5, 5, 0.1F,1F,ForgeDirection.WEST); + Base.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Base.addTube("PipeN14", -5.5F, -0.5F, -8F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + Base.addBox("Shape2", -7F, 3F, -1.5F, 1, 4, 3); + Base.addBox("Shape4", 5F, 3F, 1F, 1, 4, 1); + Base.addBox("Shape5", 5F, 6F, 2F, 3, 1, 1); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java b/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java new file mode 100644 index 0000000..6feca57 --- /dev/null +++ b/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java @@ -0,0 +1,280 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.items_blocks.FlexibleCableItem; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +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.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class VulcanizationExtrudingMoldTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IEnergySink, IProductionLine, IFluidHandler{ + + private short facing=2; + private short lastFacing=2; + public double energy; + public int maxStorage=64; + private double energyConsume=16D; + private boolean addedToEnergyNet=false; + private FluidTank fluidTank = new FluidTank(5000); + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("vulcanizationextrudingmold"); + + public VulcanizationExtrudingMoldTileEntity() + { + super(); + } + + public static void addRecipe(FluidStack inputFluid,ItemStack input,ItemStack output1) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new FluidStack[] {inputFluid}),Arrays.asList(new ItemStack[] {input})),new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output1}),200)); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public void invalidate() + { + if (IC2.platform.isSimulating()&&this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + super.invalidate(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + if (IC2.platform.isSimulating()&&this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("vulcanizationExtrudingMold"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + facing=nbttagcompound.getShort("facing"); + energy=nbttagcompound.getDouble("energy"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + nbttagcompound.setShort("facing", facing); + nbttagcompound.setDouble("energy", this.energy); + } + + @Override + public double getDemandedEnergy() + { + return this.maxStorage-this.energy; + } + + @Override + public int getSinkTier() { + return 4; + } + + @Override + public double injectEnergy(ForgeDirection directionFrom, double amount, + double voltage) { + if(this.energy getRecipes() + { + return recipeManager.getRecipes(); + } +} diff --git a/ihl/processing/metallurgy/WireMillContainer.java b/ihl/processing/metallurgy/WireMillContainer.java new file mode 100644 index 0000000..ec1ddc0 --- /dev/null +++ b/ihl/processing/metallurgy/WireMillContainer.java @@ -0,0 +1,113 @@ +package ihl.processing.metallurgy; + +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; +import net.minecraftforge.fluids.FluidStack; + +public class WireMillContainer extends ContainerBase { + + public WireMillTileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public int lastFluidAmount2 = -1; + public int lastNumberOfFluids2 = -1; + public int lastFluidAmount3 = -1; + public int lastNumberOfFluids3 = -1; + private final static int height=166; + public List fluidTankFluidList; + public List fluidTankFluidList2; + public List fluidTankFluidList3; + + public WireMillContainer(EntityPlayer entityPlayer, + WireMillTileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + fluidTankFluidList = this.tileEntity.waterFluidTank.getFluidList(); + fluidTankFluidList2 = this.tileEntity.oilFluidTank.getFluidList(); + fluidTankFluidList3 = this.tileEntity.metalFluidTank.getFluidList(); + 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(tileEntity.dice, 0, 99+18, 31)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.drainInputSlot, 0, 26+18, 14)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlot, 0, 26+18, 50)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 0, 26+18, 32)); + this.addSlotToContainer(new SlotInvSlot(tileEntity.engine,0, 8, 14)); + } + + @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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + + if (this.tileEntity.waterFluidTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.waterFluidTank.getNumberOfFluids() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.oilFluidTank.getFluidAmount() != this.lastFluidAmount2 || this.tileEntity.oilFluidTank.getNumberOfFluids() != this.lastNumberOfFluids2) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList2"); + } + + if (this.tileEntity.metalFluidTank.getFluidAmount() != this.lastFluidAmount3 || this.tileEntity.metalFluidTank.getNumberOfFluids() != this.lastNumberOfFluids3) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList3"); + } + } + this.lastNumberOfFluids = this.tileEntity.waterFluidTank.getNumberOfFluids(); + this.lastFluidAmount = this.tileEntity.waterFluidTank.getFluidAmount(); + this.lastNumberOfFluids2 = this.tileEntity.oilFluidTank.getNumberOfFluids(); + this.lastFluidAmount2 = this.tileEntity.oilFluidTank.getFluidAmount(); + this.lastNumberOfFluids3 = this.tileEntity.metalFluidTank.getNumberOfFluids(); + this.lastFluidAmount3 = this.tileEntity.metalFluidTank.getFluidAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) 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; + } + } + +} diff --git a/ihl/processing/metallurgy/WireMillGui.java b/ihl/processing/metallurgy/WireMillGui.java new file mode 100644 index 0000000..e09b4ab --- /dev/null +++ b/ihl/processing/metallurgy/WireMillGui.java @@ -0,0 +1,72 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class WireMillGui extends GuiContainer { + + private WireMillContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIWireMill.png"); + + public WireMillGui(WireMillContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + @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(tex); + 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(27, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(134, 33, 198, 0, i1 + 1, 13); + } + if (this.container.tileEntity.oilFluidTank.getFluid()!=null && this.container.tileEntity.oilFluidTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.oilFluidTank, 81, 16, 93, 63, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.waterFluidTank.getFluid()!=null && this.container.tileEntity.waterFluidTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.waterFluidTank, 64, 16, 76, 63, zLevel, par1, par2, xOffset, yOffset); + } + if (this.container.tileEntity.metalFluidTank.getFluid()!=null && this.container.tileEntity.metalFluidTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.metalFluidTank, 98, 16, 110, 63, zLevel, par1, par2, xOffset, yOffset); + } + + this.mc.renderEngine.bindTexture(tex); + if(!this.container.tileEntity.engine.correctContent()) + { + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 25, 14, xOffset, yOffset); + } + IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.wiremill.tip")); + } + + @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(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} diff --git a/ihl/processing/metallurgy/WireMillTileEntity.java b/ihl/processing/metallurgy/WireMillTileEntity.java new file mode 100644 index 0000000..16eaa4b --- /dev/null +++ b/ihl/processing/metallurgy/WireMillTileEntity.java @@ -0,0 +1,385 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.mutable.MutableObject; + +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.core.ContainerBase; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableItemStack; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.block.invslot.InvSlot.InvSide; +import ihl.IHLMod; +import ihl.items_blocks.IHLTool; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.recipes.IRecipeInputFluid; +import ihl.recipes.RecipeInputDie; +import ihl.recipes.RecipeInputFluidDictionary; +import ihl.recipes.RecipeInputFluidStack; +import ihl.recipes.RecipeOutputItemStack; +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.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class WireMillTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler{ + + public final ApparatusProcessableInvSlot dice; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + public final IHLFluidTank oilFluidTank = new IHLFluidTank(1100); + public final IHLFluidTank waterFluidTank = new IHLFluidTank(1100); + public final IHLFluidTank metalFluidTank = new IHLFluidTank(1100); + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("wiremill"); + protected static final UniversalRecipeManager recipeManagerMelting = new UniversalRecipeManager("wiremillMelting"); + + public WireMillTileEntity() + { + super(); + emptyFluidItemsSlot = new InvSlotOutput(this, "emptyWaterFluidItemsSlot", 2, 1); + fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Drain, "ingot"); + dice = new ApparatusProcessableInvSlot(this, "dice", 3, Access.IO, 1, 64); + this.isGuiScreenOpened=true; + this.operationLength=600; + } + + + @Override + public String getInventoryName() { + return "WireMill"; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("wireMill"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) + { + return new WireMillGui(new WireMillContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) + { + return new WireMillContainer(player, this); + } + + @Override + public void operate() + { + UniversalRecipeInput rInput = WireMillTileEntity.recipeManager.getRecipeInput(getInput()); + IRecipeInput rInputDice = rInput.getItemInputs().get(0); + UniversalRecipeOutput rOutput = this.getOutput(); + ItemStack rOutputItemStack=null; + if(!rOutput.getItemOutputs().isEmpty()) + { + rOutputItemStack = rOutput.getItemOutputs().get(0).itemStack.copy(); + } + List rInputFluidStacks = rInput.getFluidInputs(); + int consumeMoltenMetalAmount=1; + if(!rInputFluidStacks.isEmpty() && rOutputItemStack!=null && rInputDice!=null && rInputDice instanceof RecipeInputDie) + { + if(rInputFluidStacks.size()>=3) + { + consumeMoltenMetalAmount=rInputFluidStacks.get(2).getAmount(); + } + else + { + consumeMoltenMetalAmount=rInputFluidStacks.get(0).getAmount(); + } + if(rOutputItemStack!=null && rInputDice!=null && rInputDice instanceof RecipeInputDie) + { + consumeMoltenMetalAmount*=((RecipeInputDie)rInputDice).transformOutput(this.dice.get(), rOutputItemStack); + } + } + if(dice.get()!=null) + { + if(dice.get().getItem() instanceof IHLTool) + { + IHLUtils.damageItemViaNBTTag(dice.get(), 1); + if(dice.get().stackSize<=0) + { + dice.put(null); + } + } + else + { + dice.consume(0, 1); + } + } + if(this.drainInputSlot.get()!=null && !rInput.getItemInputs().isEmpty() && rInput.getItemInputs().get(0).matches(this.drainInputSlot.get())) + { + this.drainInputSlot.consume(1); + } + if(!rOutput.getFluidOutputs().isEmpty()) + { + this.metalFluidTank.fill(rOutput.getFluidOutputs().get(0), true); + } + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.DOWN); + TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ); + if(rOutputItemStack!=null && te instanceof IProductionLine) + { + if(!rInputFluidStacks.isEmpty()) + { + this.oilFluidTank.drain(1, true); + this.waterFluidTank.drain(1, true); + this.metalFluidTank.drain(consumeMoltenMetalAmount, true); + } + ((IProductionLine)te).process(rOutputItemStack); + } + } + + @Override + public List[] getInput() + { + return new List[]{Arrays.asList(new FluidStack[] {this.oilFluidTank.getFluid(),this.waterFluidTank.getFluid(),this.metalFluidTank.getFluid()}),Arrays.asList(new ItemStack[] {dice.get(),drainInputSlot.get()})}; + } + + public UniversalRecipeOutput getOutput() + { + return WireMillTileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + public static void addRecipe(FluidStack moltenMetal, IRecipeInput inputDice,ItemStack output1) + { + recipeManager.addRecipe(new UniversalRecipeInput(Arrays.asList(new IRecipeInputFluid[] {new RecipeInputFluidDictionary("lubricant", 1),new RecipeInputFluidDictionary("water", 1),new RecipeInputFluidStack(moltenMetal)}),Arrays.asList(new IRecipeInput[] {inputDice})),new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output1}),200)); + } + + public static void addRecipe(String string, FluidStack fluidStack) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new IRecipeInput [] {new RecipeInputOreDict(string)})),new UniversalRecipeOutput(Arrays.asList(new FluidStack[] {fluidStack}),null,200)); + } + + + @Override + public boolean canOperate() + { + UniversalRecipeOutput output = this.getOutput(); + if(output!=null) + { + ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.DOWN); + TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ); + if(te instanceof IProductionLine && !output.getItemOutputs().isEmpty()) + { + ItemStack isOut=this.getOutput().getItemOutputs().get(0).itemStack.copy(); + if(this.dice.get()!=null) + { + isOut.stackTagCompound.setInteger("transverseSection", this.dice.get().stackTagCompound.getInteger("transverseSection")); + } + return ForgeDirection.getOrientation(((IProductionLine)te).getFacing()).equals(dir) && ((IProductionLine)te).canProcess(isOut); + } + else if(!output.getFluidOutputs().isEmpty()) + { + FluidStack fstack = output.getFluidOutputs().get(0); + return metalFluidTank.fill(fstack, false)==fstack.amount; + } + } + return false; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.oilFluidTank.readFromNBT(nbttagcompound.getCompoundTag("oilFluidTank")); + this.waterFluidTank.readFromNBT(nbttagcompound.getCompoundTag("waterFluidTank")); + this.metalFluidTank.readFromNBT(nbttagcompound.getCompoundTag("metalFluidTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound oilFluidTankTag = new NBTTagCompound(); + this.oilFluidTank.writeToNBT(oilFluidTankTag); + nbttagcompound.setTag("oilFluidTank", oilFluidTankTag); + NBTTagCompound waterFluidTankTag = new NBTTagCompound(); + this.waterFluidTank.writeToNBT(waterFluidTankTag); + nbttagcompound.setTag("waterFluidTank", waterFluidTankTag); + NBTTagCompound metalFluidTankTag = new NBTTagCompound(); + this.metalFluidTank.writeToNBT(metalFluidTankTag); + nbttagcompound.setTag("metalFluidTank", metalFluidTankTag); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + FluidStack drainSlotContent = drainInputSlot.drain(null, Integer.MAX_VALUE, null, true); + if(drainSlotContent!=null) + { + String fluidDictionaryName = IHLMod.fluidDictionary.getFluidName(drainSlotContent.getFluid()); + if(fluidDictionaryName!=null && fluidDictionaryName.equals("lubricant")) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, oilFluidTank); + } + else if(fluidDictionaryName!=null && fluidDictionaryName.equals("water")) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, waterFluidTank); + } + else + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, metalFluidTank); + } + } + else + { + if(metalFluidTank.getNumberOfFluids()>0) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, metalFluidTank); + } + else if(oilFluidTank.getNumberOfFluids()>0) + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, oilFluidTank); + } + else + { + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, waterFluidTank); + } + } + + } + public int gaugeLiquidScaled(int i) { + if(this.oilFluidTank.getFluid()!=null) + { + return this.oilFluidTank.getFluidAmount() * i /this.oilFluidTank.getCapacity(); + } + else + { + return 0; + } + } + + @Override + public int gaugeProgressScaled(int i) + { + return this.progress * i / this.operationLength; + } + + public int gaugeWaterScaled(int i) + { + if(this.waterFluidTank.getFluid()!=null) + { + return this.waterFluidTank.getFluidAmount() * i /this.waterFluidTank.getCapacity(); + } + else + { + return 0; + } + } + + public static Map getRecipes() + { + return recipeManager.getRecipes(); + } + + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + + @Override + public boolean canFill(ForgeDirection arg0, Fluid arg1) { + return true; + } + + + @Override + public FluidStack drain(ForgeDirection direction, FluidStack arg1, boolean arg2) + { + if(direction.equals(ForgeDirection.DOWN)) + { + return this.metalFluidTank.drain(arg1, arg2); + } + else if(direction.equals(ForgeDirection.UP)) + { + return this.waterFluidTank.drain(arg1, arg2); + } + else + { + return this.oilFluidTank.drain(arg1, arg2); + } + } + + + @Override + public FluidStack drain(ForgeDirection direction, int arg1, boolean arg2) + { + if(direction.equals(ForgeDirection.DOWN)) + { + return this.metalFluidTank.drain(arg1, arg2); + } + else if(direction.equals(ForgeDirection.UP)) + { + return this.waterFluidTank.drain(arg1, arg2); + } + else + { + return this.oilFluidTank.drain(arg1, arg2); + } + } + + + @Override + public int fill(ForgeDirection direction, FluidStack arg1, boolean arg2) + { + if(direction.equals(ForgeDirection.DOWN)) + { + return this.metalFluidTank.fill(arg1, arg2); + } + else if(direction.equals(ForgeDirection.UP)) + { + return this.waterFluidTank.fill(arg1, arg2); + } + else + { + return this.oilFluidTank.fill(arg1, arg2); + } + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection direction) + { + if(direction.equals(ForgeDirection.DOWN)) + { + return new FluidTankInfo[] {this.metalFluidTank.getInfo()}; + } + else if(direction.equals(ForgeDirection.UP)) + { + return new FluidTankInfo[] {this.waterFluidTank.getInfo()}; + } + else + { + return new FluidTankInfo[] {this.oilFluidTank.getInfo()}; + } + } +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachineContainer.java b/ihl/processing/metallurgy/WoodenRollingMachineContainer.java new file mode 100644 index 0000000..100da1b --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachineContainer.java @@ -0,0 +1,77 @@ +package ihl.processing.metallurgy; + +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 WoodenRollingMachineContainer extends ContainerBase { + + public WoodenRollingMachinePart1TileEntity tileEntity; + public int lastProgress = -1; + private short lastEnergy = -1; + private final static int height=166; + + public WoodenRollingMachineContainer(EntityPlayer entityPlayer, + WoodenRollingMachinePart1TileEntity lathePart1TileEntity) { + super(lathePart1TileEntity); + tileEntity=lathePart1TileEntity; + 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(lathePart1TileEntity.output, 0, 54, 25)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 0, 123, 15)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 1, 123, 34)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 2, 123, 53)); + this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.engine,0, 22, 55)); + } + + @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.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = (short) 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; + } + } + +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachineGui.java b/ihl/processing/metallurgy/WoodenRollingMachineGui.java new file mode 100644 index 0000000..d7b3456 --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachineGui.java @@ -0,0 +1,69 @@ +package ihl.processing.metallurgy; + +import org.lwjgl.opengl.GL11; + +import ihl.utils.IHLRenderUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; + +public class WoodenRollingMachineGui extends GuiContainer { + + private WoodenRollingMachineContainer container; + protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIWoodenRollingMachine.png"); + + public WoodenRollingMachineGui(WoodenRollingMachineContainer latheContainer) { + super(latheContainer); + container = latheContainer; + } + + + @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(tex); + 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); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + if (this.container.tileEntity.progress > 0) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27); + this.drawTexturedModalRect(18, 22, getFrameX(i1), getFrameY(i1),24,24); + } + if(!this.container.tileEntity.engine.correctContent()) + { + this.mc.renderEngine.bindTexture(tex); + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 47, 56, xOffset, yOffset); + } + } + + @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(tex); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + private int getFrameY(int number) + { + return (number % 10) * 24 + 14; + } + + private int getFrameX(int number) + { + return (number / 10) * 24 + 176; + } +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java b/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java new file mode 100644 index 0000000..ac7799b --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java @@ -0,0 +1,122 @@ +// Date: 15.02.2015 11:28:39 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class WoodenRollingMachinePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer RotatingPart1; + IHLModelRenderer RotatingPart3; + IHLModelRenderer RotatingPart4; + IHLModelRenderer Belt1; + IHLModelRenderer Belt2; + + public WoodenRollingMachinePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 15); + setTextureOffset("Base.Shape16", 0, 23); + setTextureOffset("Base.PipeN18", 0, 0); + setTextureOffset("Base.PipeN19", 0, 0); + setTextureOffset("RotatingPart2.PipeN17", 0, 0); + setTextureOffset("RotatingPart2.PipeN21", 0, 0); + setTextureOffset("RotatingPart2.PipeN25", 0, 0); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN16", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("RotatingPart1.PipeN27", 0, 0); + setTextureOffset("RotatingPart1.PipN119", 0, 0); + setTextureOffset("RotatingPart1.pipeN24", 0, 0); + setTextureOffset("RotatingPart3.PipeN23", 0, 0); + setTextureOffset("RotatingPart3.PipeN22", 0, 0); + setTextureOffset("RotatingPart3.PipeN26", 0, 0); + setTextureOffset("RotatingPart4.PipeN28", 0, 0); + setTextureOffset("Belt1.Shape12", 60, 0); + setTextureOffset("Belt2.Shape17", 60, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape16", -6F, -1F, -7F, 12, 8, 1); + Base.addTube("PipeN18", -5F, -6.1F, -7.1F, 10, 10, 1, 0.9F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN19", -1.5F, -6F, -7F, 3, 3, 1, 0.25F,1F,ForgeDirection.NORTH);; + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-2.2F, 16F, -8F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN17", -2F, -2F, 2F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN21", -0.5F, -0.5F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN25", -0.5F, -0.5F, 30F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + RotatingPart1 = new IHLModelRenderer(this, "RotatingPart1"); + RotatingPart1.setRotationPoint(0F, 11.5F, -6F); + setRotation(RotatingPart1, 0F, 0F, 0F); + RotatingPart1.mirror = true; + RotatingPart1.addTube("PipeN27", -2F, -2F, 0F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("PipN119", -0.5F, -0.5F, -2F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("pipeN24", -0.5F, -0.5F, 28F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart3 = new IHLModelRenderer(this, "RotatingPart3"); + RotatingPart3.setRotationPoint(2.2F, 16F, -8F); + setRotation(RotatingPart3, 0F, 0F, 0F); + RotatingPart3.mirror = true; + RotatingPart3.addTube("PipeN23", -2F, -2F, 2F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart3.addTube("PipeN22", -1.5F, -1.5F, 0F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart3.addTube("PipeN26", -0.5F, -0.5F, 30F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart4 = new IHLModelRenderer(this, "RotatingPart4"); + RotatingPart4.setRotationPoint(0F, 15F, -5F); + setRotation(RotatingPart3, 0F, 0F, 0F); + RotatingPart4.mirror = true; + RotatingPart4.addTube("PipeN28", -0.5F, -0.5F, 0F, 1, 1, 27, 0F,1F,ForgeDirection.NORTH); + Belt1 = new IHLModelRenderer(this, "Belt1"); + Belt1.setRotationPoint(2.5F, 16F, -7.9F); + setRotation(Belt1, 0F, 0F, -0.45F); + Belt1.mirror = true; + Belt1.addBox("Shape12", 0F, 0F, 0F, 1, 5, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(2F, 16F, -7.9F); + setRotation(Belt2, 0F, 0F, -0.45F); + Belt2.mirror = true; + Belt2.addBox("Shape17", -1F, 0F, 0F, 1, 6, 1); + } + + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java b/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java new file mode 100644 index 0000000..eb40389 --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java @@ -0,0 +1,171 @@ +package ihl.processing.metallurgy; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import ic2.api.recipe.IRecipeInput; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ihl.processing.chemistry.ApparatusProcessableInvSlot; +import ihl.processing.invslots.IHLInvSlotOutput; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeManager; +import ihl.recipes.UniversalRecipeOutput; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class WoodenRollingMachinePart1TileEntity extends BasicElectricMotorTileEntity{ + + public final ApparatusProcessableInvSlot input; + public final IHLInvSlotOutput output; + public boolean hasEngine; + public boolean assembled; + protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("woodenrollingmachine"); + + public WoodenRollingMachinePart1TileEntity() + { + super(); + input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 3, 64); + output = new IHLInvSlotOutput(this, "output", 2, 1); + isGuiScreenOpened=true; + } + + public UniversalRecipeOutput getOutput() + { + return WoodenRollingMachinePart1TileEntity.recipeManager.getOutputFor(this.getInput(), false, false); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("assembled"); + fields.add("hasEngine"); + return fields; + } + + + @Override + public String getInventoryName() { + return "WoodenRollingMachine"; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(assembled && !this.checkCorrectAccembly()) + { + assembled=false; + IC2.network.get().updateTileEntityField(this, "assembled"); + } + else if(!assembled && this.checkCorrectAccembly()) + { + assembled=true; + IC2.network.get().updateTileEntityField(this, "assembled"); + } + if(this.engine.isEmpty() && hasEngine==true) + { + this.hasEngine=false; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + else if(this.engine.correctContent() && hasEngine==false) + { + this.hasEngine=true; + IC2.network.get().updateTileEntityField(this, "hasEngine"); + } + + if (this.getActive() && this.progress == 0 && !this.canOperate()) + { + this.setActive(false); + } + + if (!this.getActive() && this.progress>0 && this.canOperate()) + { + this.setActive(true); + } + + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("woodenRollingMachinePart1"); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new WoodenRollingMachineGui(new WoodenRollingMachineContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new WoodenRollingMachineContainer(player, this); + } + + @Override + public void operate() + { + List rInput = WoodenRollingMachinePart1TileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs(); + List rOutput = WoodenRollingMachinePart1TileEntity.recipeManager.getOutputFor(getInput(), false, false).getItemOutputs(); + this.output.add(rOutput); + for(int i=0;i getRecipes() { + return recipeManager.getRecipes(); + } + + public static void addRecipe(ItemStack input, ItemStack input3, ItemStack output) + { + recipeManager.addRecipe(new UniversalRecipeInput(null, Arrays.asList(new ItemStack[] {input,input3})), new UniversalRecipeOutput(null,Arrays.asList(new ItemStack[] {output}),20)); + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java b/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java new file mode 100644 index 0000000..2673124 --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java @@ -0,0 +1,44 @@ +// Date: 15.02.2015 11:31:12 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.metallurgy; + +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; +import ihl.model.IHLModelRenderer; + +public class WoodenRollingMachinePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public WoodenRollingMachinePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 15); + setTextureOffset("Base.Shape16", 0, 23); + setTextureOffset("Base.PipeN18", 0, 0); + setTextureOffset("Base.PipeN19", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape16", -6F, -1F, 6F, 12, 8, 1); + Base.addTube("PipeN18", -5F, -6.1F, 6.1F, 10, 10, 1, 0.9F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN19", -1.5F, -6F, 6F, 3, 3, 1, 0.25F,1F,ForgeDirection.NORTH);; + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java b/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java new file mode 100644 index 0000000..165d84b --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java @@ -0,0 +1,105 @@ +package ihl.processing.metallurgy; + +import java.util.ArrayList; +import java.util.List; + +import ic2.api.network.INetworkDataProvider; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.network.NetworkManager; +import ihl.utils.IHLUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class WoodenRollingMachinePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{ + + private short facing=2; + private short lastFacing=2; + + public WoodenRollingMachinePart2TileEntity() + { + super(); + } + + public boolean enableUpdateEntity() + { + return IC2.platform.isSimulating(); + } + + @Override + public List getNetworkedFields() + { + List fields = new ArrayList(); + fields.add("facing"); + return fields; + } + + @Override + public void updateEntity() + { + super.updateEntity(); + if(lastFacing!=facing) + { + IC2.network.get().updateTileEntityField(this, "facing"); + lastFacing=facing; + } + } + + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=side; + } + + + @Override + public short getFacing() { + return this.facing; + } + + + @Override + public void setFacing(short facing1) + { + facing=(short) Math.max(2,facing1); + if(IC2.platform.isSimulating()) + { + IC2.network.get().updateTileEntityField(this, "facing"); + } + } + + + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + + @Override + public float getWrenchDropRate() { + return 1F; + } + + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("woodenRollingMachinePart2"); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + facing=nbttagcompound.getShort("facing"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setShort("facing", facing); + } + +} diff --git a/ihl/processing/metallurgy/WoodenRollingMachineRender.java b/ihl/processing/metallurgy/WoodenRollingMachineRender.java new file mode 100644 index 0000000..84fbcd6 --- /dev/null +++ b/ihl/processing/metallurgy/WoodenRollingMachineRender.java @@ -0,0 +1,94 @@ +package ihl.processing.metallurgy; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import ic2.api.tile.IWrenchable; +import ihl.IHLModInfo; + +public class WoodenRollingMachineRender extends TileEntitySpecialRenderer{ +private WoodenRollingMachinePart1Model model = new WoodenRollingMachinePart1Model(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/woodenRollingMachine.png"); +private final float scale=1F/16F; + + public WoodenRollingMachineRender() {} + + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8) + { + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (((IWrenchable)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; + } + } + else + { + return; + } + WoodenRollingMachinePart1TileEntity cte = (WoodenRollingMachinePart1TileEntity)tile; + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + + bindTexture(tex); + model.Base.render(scale); + if(cte.getActive()) + { + model.RotatingPart1.rotateAngleZ+=0.01F; + model.RotatingPart2.rotateAngleZ+=0.01F; + model.RotatingPart3.rotateAngleZ+=0.01F; + model.RotatingPart4.rotateAngleZ-=0.01F; + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + model.RotatingPart3.render(scale); + model.RotatingPart4.render(scale); + model.MotorPart1.rotateAngleZ-=0.03F; + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + model.Belt1.render(scale); + model.Belt2.render(scale); + } + else + { + model.RotatingPart1.rotateAngleZ=0.0F; + model.RotatingPart2.rotateAngleZ=0.0F; + model.RotatingPart3.rotateAngleZ=0.0F; + model.RotatingPart4.rotateAngleZ=0.0F; + if(cte.assembled) + { + model.RotatingPart1.render(scale); + model.RotatingPart2.render(scale); + model.RotatingPart3.render(scale); + model.RotatingPart4.render(scale); + } + if(cte.hasEngine) + { + model.MotorPart1.render(scale); + model.MotorPart2.render(scale); + model.Belt1.render(scale); + model.Belt2.render(scale); + } + } + GL11.glPopMatrix(); //end + + } +} \ No newline at end of file diff --git a/ihl/recipes/IRecipeInputFluid.java b/ihl/recipes/IRecipeInputFluid.java new file mode 100644 index 0000000..8faf15d --- /dev/null +++ b/ihl/recipes/IRecipeInputFluid.java @@ -0,0 +1,12 @@ +package ihl.recipes; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public interface IRecipeInputFluid { + public boolean matches(FluidStack subject); + public int getAmount(); + public List getInputs(); +} diff --git a/ihl/recipes/IronWorkbenchRecipe.java b/ihl/recipes/IronWorkbenchRecipe.java new file mode 100644 index 0000000..8ecb8df --- /dev/null +++ b/ihl/recipes/IronWorkbenchRecipe.java @@ -0,0 +1,182 @@ +package ihl.recipes; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.item.ItemStack; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeInputOreDict; +import ihl.interfaces.IWire; +import ihl.utils.IHLUtils; + +public class IronWorkbenchRecipe { + public List workspaceElements=new ArrayList(); + public List tools=new ArrayList(); + public List materials=new ArrayList(); + public List outputs = new ArrayList(); + + public IronWorkbenchRecipe(List tools1, List materials1, List output1_1) + { + if(tools1!=null) + { + Iterator iTools1 = tools1.iterator(); + while(iTools1.hasNext()) + { + Object tool = iTools1.next(); + if(tool instanceof ItemStack) + { + ItemStack stack = (ItemStack) tool; + String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack); + if(!oreDictName.isEmpty() && oreDictName.length()>3) + { + tools.add(new RecipeInputOreDict(oreDictName)); + } + else + { + tools.add(new RecipeInputItemStack(stack)); + } + } + else + { + tools.add((IRecipeInput) tool); + } + } + } + Iterator iMaterials1 = materials1.iterator(); + while(iMaterials1.hasNext()) + { + Object material = iMaterials1.next(); + if(material instanceof ItemStack) + { + ItemStack stack = (ItemStack) material; + String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack); + if(stack.getItem() instanceof IWire) + { + materials.add(new RecipeInputWire(stack)); + } + else if(!oreDictName.isEmpty() && oreDictName.length()>3) + { + materials.add(new RecipeInputOreDict(oreDictName,stack.stackSize)); + } + else + { + materials.add(new RecipeInputItemStack(stack)); + } + } + else + { + materials.add((IRecipeInput) material); + } + + } + this.outputs.addAll(output1_1); + if(tools.size()>8 || materials.size()>12) + { + throw new IllegalArgumentException("Iron workbench recipe cannot contain more than 8 tools or more than 12 materials!"); + } + } + + public IronWorkbenchRecipe(List asList, List asList2, List asList3, List workspaceElements1) { + this(asList, asList2, asList3); + this.workspaceElements.addAll(workspaceElements1); + } + + public boolean isCanBeCrafted(List tools1, List materials1, List workspaceElements1) + { + if(workspaceElements!=null && !workspaceElements.isEmpty()) + { + if(workspaceElements1==null||workspaceElements1.isEmpty()) + { + return false; + } + Iterator i1 = workspaceElements.iterator(); + while(i1.hasNext()) + { + ItemStack tool = i1.next(); + if(!this.isItemStackInList(tool, workspaceElements1)) + { + return false; + } + } + } + + if(tools!=null && !tools.isEmpty()) + { + if(tools1==null||tools1.isEmpty()) + { + return false; + } + Iterator i1 = tools.iterator(); + while(i1.hasNext()) + { + IRecipeInput tool = i1.next(); + if(!this.isItemStackInList(tool, tools1)) + { + return false; + } + } + } + if(materials!=null && !materials.isEmpty()) + { + Iterator i1 = materials.iterator(); + while(i1.hasNext()) + { + IRecipeInput material = i1.next(); + if(!this.isItemStackInList(material, materials1)) + { + return false; + } + } + } + return true; + } + + private boolean isItemStackInList(IRecipeInput tool, List tools1) { + Iterator it = tools1.iterator(); + while(it.hasNext()) + { + ItemStack tool2 = it.next(); + if(tool.matches(tool2)) + { + if(tool2.getItem() instanceof IWire) + { + if(IHLUtils.getWireLength(tool2)>=tool.getAmount()) + { + return true; + } + } + else if(tool2.stackSize>=tool.getAmount()) + { + return true; + } + } + } + return false; + } + + private boolean isItemStackInList(ItemStack tool, List tools1) + { + Iterator it = tools1.iterator(); + while(it.hasNext()) + { + ItemStack tool2 = it.next(); + if(IHLUtils.isItemStacksIsEqual(tool,tool2,true)) + { + if(tool2.getItem() instanceof IWire) + { + if(IHLUtils.getWireLength(tool2)>=IHLUtils.getWireLength(tool)) + { + return true; + } + } + else if(tool2.stackSize>=tool.stackSize) + { + return true; + } + } + } + return false; + } + +} diff --git a/ihl/recipes/RecipeInputDie.java b/ihl/recipes/RecipeInputDie.java new file mode 100644 index 0000000..c8356ca --- /dev/null +++ b/ihl/recipes/RecipeInputDie.java @@ -0,0 +1,98 @@ +package ihl.recipes; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import ic2.api.recipe.IRecipeInput; +import ihl.interfaces.IWire; +import ihl.items_blocks.FlexibleCableItem; +import ihl.utils.IHLUtils; +import net.minecraft.item.ItemStack; + +public class RecipeInputDie implements IRecipeInput +{ + public final ItemStack input; + public final int transverseSection; + + public RecipeInputDie(String string, int transverseSection) + { + this(IHLUtils.getItemStackWithTag(string, "transverseSection", transverseSection)); + } + + public RecipeInputDie(ItemStack itemStack) + { + input=itemStack; + transverseSection=itemStack.stackTagCompound.getInteger("transverseSection"); + } + + @Override + public boolean matches(ItemStack subject) + { + return subject.getItem() == this.input.getItem() && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767); + } + + @Override + public int getAmount() + { + return 1; + } + + @Override + public List getInputs() + { + return Arrays.asList(new ItemStack[] {this.input}); + } + + @Override + public String toString() + { + ItemStack stack = this.input.copy(); + return "RInputDice<" + stack + ">"; + } + + public List transformOutput(ItemStack matchedItemStack, List outputs) + { + List newOutputs = new ArrayList(); + int misTS = matchedItemStack.stackTagCompound.getInteger("transverseSection"); + ItemStack material; + for(ItemStack material1:outputs) + { + if(material1.getItem() instanceof IWire) + { + material=material1.copy(); + int length = material.stackTagCompound.getInteger("length"); + length = length * transverseSection / misTS; + material.stackTagCompound.setInteger("length", length); + material.stackTagCompound.setInteger("fullLength", length); + material.stackTagCompound.setInteger("transverseSection", misTS); + newOutputs.add(material); + } + else + { + newOutputs.add(material1); + } + } + return newOutputs; + } + + public int transformOutput(ItemStack matchedItemStack, ItemStack material) + { + int consumeAmountMultiplier=1; + int misTS = matchedItemStack.stackTagCompound.getInteger("transverseSection"); + if(misTS<=transverseSection) + { + int length = material.stackTagCompound.getInteger("length"); + length = length * transverseSection / misTS; + material.stackTagCompound.setInteger("length", length); + material.stackTagCompound.setInteger("fullLength", length); + } + else + { + consumeAmountMultiplier=misTS/transverseSection+1; + } + material.stackTagCompound.setInteger("transverseSection", misTS); + return consumeAmountMultiplier; + } +} + diff --git a/ihl/recipes/RecipeInputFluidDictionary.java b/ihl/recipes/RecipeInputFluidDictionary.java new file mode 100644 index 0000000..46c51eb --- /dev/null +++ b/ihl/recipes/RecipeInputFluidDictionary.java @@ -0,0 +1,43 @@ +package ihl.recipes; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import ic2.api.recipe.IRecipeInput; +import ihl.IHLMod; + +public class RecipeInputFluidDictionary implements IRecipeInputFluid +{ + private final String input; + private final int amount; + public RecipeInputFluidDictionary(String input1, int amount1) + { + this.input=input1; + this.amount=amount1; + } + + @Override + public boolean matches(FluidStack subject) + { + if(subject==null) + { + return false; + } + String fName = IHLMod.fluidDictionary.getFluidName(subject.getFluid()); + return fName==null?false:fName.equals(input); + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List getInputs() { + return IHLMod.fluidDictionary.getFluids(input); + } + +} diff --git a/ihl/recipes/RecipeInputFluidStack.java b/ihl/recipes/RecipeInputFluidStack.java new file mode 100644 index 0000000..a7b5d0e --- /dev/null +++ b/ihl/recipes/RecipeInputFluidStack.java @@ -0,0 +1,41 @@ +package ihl.recipes; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import ic2.api.recipe.IRecipeInput; + +public class RecipeInputFluidStack implements IRecipeInputFluid +{ + private final Fluid fluid; + private final int amount; + public RecipeInputFluidStack(FluidStack fstack) + { + this.fluid=fstack.getFluid(); + this.amount=fstack.amount; + } + + @Override + public boolean matches(FluidStack subject) + { + if(subject==null || subject.getFluid()==null) + { + return false; + } + return fluid.getName().equals(subject.getFluid().getName()); + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List getInputs() { + return Arrays.asList(new FluidStack[] {new FluidStack(fluid,amount)}); + } + +} diff --git a/ihl/recipes/RecipeInputObjectInstance.java b/ihl/recipes/RecipeInputObjectInstance.java new file mode 100644 index 0000000..eeadc5c --- /dev/null +++ b/ihl/recipes/RecipeInputObjectInstance.java @@ -0,0 +1,46 @@ +package ihl.recipes; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; +import ic2.api.recipe.IRecipeInput; +import ihl.interfaces.IWire; +import ihl.items_blocks.FlexibleCableItem; +import ihl.utils.IHLUtils; + +public class RecipeInputObjectInstance implements IRecipeInput +{ + public final ItemStack input; + + public RecipeInputObjectInstance(ItemStack aInput) + { + this.input = aInput; + } + + @Override + public boolean matches(ItemStack subject) + { + return this.input==subject; + } + + @Override + public int getAmount() + { + return IHLUtils.getAmountOf(input); + } + + @Override + public List getInputs() + { + return Arrays.asList(new ItemStack[] {this.input}); + } + + @Override + public String toString() + { + ItemStack stack = this.input.copy(); + return "RInputWireItemStack<" + stack + ">"; + } + +} diff --git a/ihl/recipes/RecipeInputOreDictionaryList.java b/ihl/recipes/RecipeInputOreDictionaryList.java new file mode 100644 index 0000000..3c4b551 --- /dev/null +++ b/ihl/recipes/RecipeInputOreDictionaryList.java @@ -0,0 +1,149 @@ +package ihl.recipes; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import ic2.api.recipe.IRecipeInput; +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; + } + + @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 = (ItemStack)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$ = (ItemStack)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 = (ItemStack)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 getInputs() + { + return Arrays.asList(new ItemStack[] {this.input}); + } + + @Override + public String toString() + { + ItemStack stack = this.input.copy(); + return "RInputWireItemStack<" + stack + ">"; + } +} + diff --git a/ihl/recipes/RecipeOutputItemStack.java b/ihl/recipes/RecipeOutputItemStack.java new file mode 100644 index 0000000..c765b1d --- /dev/null +++ b/ihl/recipes/RecipeOutputItemStack.java @@ -0,0 +1,65 @@ +package ihl.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class RecipeOutputItemStack +{ + public final ItemStack itemStack; + public final float quantity; + public RecipeOutputItemStack(ItemStack itemStack1, float quantity1) + { + itemStack=itemStack1; + quantity=quantity1; + itemStack.stackSize=1; + } + + public RecipeOutputItemStack(ItemStack itemStack1) + { + this(itemStack1, itemStack1.stackSize); + } + + public boolean matches(RecipeOutputItemStack is1) + { + if(is1==null||(itemStack.getItem()!=is1.itemStack.getItem())) + { + return false; + } + else if(is1.itemStack.getItemDamage()!=OreDictionary.WILDCARD_VALUE && + itemStack.getItemDamage()!=is1.itemStack.getItemDamage()) + { + return false; + } + return true; + } + + public RecipeOutputItemStack copy(int mulipier) + { + return new RecipeOutputItemStack(itemStack, quantity*mulipier); + } + + public RecipeOutputItemStack copy() + { + return new RecipeOutputItemStack(itemStack, quantity); + } + + @Override + public String toString() + { + return this.itemStack.getUnlocalizedName()+":"+this.quantity; + } + + public boolean matches(ItemStack is1) + { + if(is1==null||(itemStack.getItem()!=is1.getItem())) + { + return false; + } + else if(is1.getItemDamage()!=OreDictionary.WILDCARD_VALUE && + itemStack.getItemDamage()!=is1.getItemDamage()) + { + return false; + } + return false; + } +} diff --git a/ihl/recipes/UniversalRecipeInput.java b/ihl/recipes/UniversalRecipeInput.java new file mode 100644 index 0000000..f0b42e2 --- /dev/null +++ b/ihl/recipes/UniversalRecipeInput.java @@ -0,0 +1,305 @@ +package ihl.recipes; + +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeInputOreDict; +import ihl.interfaces.IWire; +import ihl.utils.IHLUtils; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class UniversalRecipeInput{ + + private final List fluidInputs=new ArrayList(); + private final List itemInputs=new ArrayList(); + private boolean sharp=true; + private int temperatureMin = 273; + private int temperatureMax = Integer.MAX_VALUE; + private float speedFactor=-1.0f;//=-Ea/R (k=k0*exp(-Ea/(RT))) + private int multiplier=Integer.MAX_VALUE; + + + public UniversalRecipeInput(List fluidInputs1, List itemInputs1, boolean sharp1) + { + this(fluidInputs1, itemInputs1); + this.sharp=false; + } + + public UniversalRecipeInput(List fluidInputs1, List itemInputs1) + { + if(fluidInputs1!=null) + { + Iterator ifluidInputs1 = fluidInputs1.iterator(); + while(ifluidInputs1.hasNext()) + { + Object material = ifluidInputs1.next(); + if(material==null) + { + throw new NullPointerException("Recipe input cannot be null!"); + } + if(material instanceof FluidStack) + { + fluidInputs.add(new RecipeInputFluidStack((FluidStack)material)); + } + else + { + fluidInputs.add((IRecipeInputFluid) material); + } + } + } + if(itemInputs1!=null) + { + Iterator iitemInputs1 = itemInputs1.iterator(); + while(iitemInputs1.hasNext()) + { + Object material = iitemInputs1.next(); + if(material==null) + { + throw new NullPointerException("Recipe input cannot be null!"); + } + if(material instanceof ItemStack) + { + ItemStack stack = (ItemStack)material; + String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack); + if(stack.getItem() instanceof IWire) + { + itemInputs.add(new RecipeInputWire(stack)); + } + else if(!oreDictName.isEmpty() && oreDictName.length()>3) + { + itemInputs.add(new RecipeInputOreDict(oreDictName,stack.stackSize)); + } + else + { + itemInputs.add(new RecipeInputItemStack(stack)); + } + } + else + { + itemInputs.add((IRecipeInput) material); + } + } + } + } + + public boolean matches(List fluidInputs1, List itemInputs1) + { + return this.adjustAmounts(fluidInputs1, itemInputs1, false, false); + } + + public List getFluidInputs() { + return fluidInputs; + } + + public List getItemInputs() { + return itemInputs; + } + + public boolean matches(UniversalRecipeInput input) { + List rInputs = input.getItemInputs(); + Iterator ii = rInputs.iterator(); + List rInputsItems = new ArrayList(); + while(ii.hasNext()) + { + IRecipeInput is = ii.next(); + rInputsItems.add(is.getInputs().get(0)); + } + List rInputsFluids = new ArrayList(); + List rInputsF = input.getFluidInputs(); + Iterator iiF = rInputsF.iterator(); + while(iiF.hasNext()) + { + IRecipeInputFluid is = iiF.next(); + rInputsFluids.add(is.getInputs().get(0)); + } + return this.matches(rInputsFluids, rInputsItems); + } + + public boolean adjustAmounts(List fluidInputs1, List itemInputs1, boolean doCheckAmounts, boolean doAdjustAmounts) + { + this.multiplier=Integer.MAX_VALUE; + if(incorrectInputAmount(fluidInputs1, itemInputs1)) + { + return false; + } + if(fluidInputs1!=null) + { + Iterator fi = fluidInputs.iterator(); + while(fi.hasNext()) + { + IRecipeInputFluid fs = fi.next(); + FluidStack fs1 = getMatchedFluidStack(fs,fluidInputs1); + if(fs1==null || !fs.matches(fs1)) + { + multiplier=0; + return false; + } + else if(doCheckAmounts && fs1.amount0) + { + int multiplier1=fs1.amount/fs.getAmount(); + if(multiplier1 ii = itemInputs.iterator(); + while(ii.hasNext()) + { + IRecipeInput is = ii.next(); + ItemStack is1 = getMatchedItemStack(is, itemInputs1); + if(is1==null || !is.matches(is1)) + { + multiplier=0; + return false; + } + else if(doCheckAmounts && is1.stackSize0) + { + int multiplier1=is1.stackSize/is.getAmount(); + if(multiplier1 itemInputs1) + { + for(ItemStack is1:itemInputs1) + { + if(is1!=null) + { + if(is.matches(is1)) + { + return is1; + } + } + } + return null; + } + + private FluidStack getMatchedFluidStack(IRecipeInputFluid fs, List fluidInputs1) + { + for(FluidStack fs1:fluidInputs1) + { + if(fs.matches(fs1)) + { + return fs1; + } + } + return null; + } + + public boolean adjustAmounts(UniversalRecipeInput input, boolean doAdjustAmounts) { + List rInputs = input.getItemInputs(); + Iterator ii = rInputs.iterator(); + List rInputsItems = new ArrayList(); + while(ii.hasNext()) + { + IRecipeInput is = ii.next(); + rInputsItems.add(is.getInputs().get(0)); + } + List rInputsFluids = new ArrayList(); + List rInputsF = input.getFluidInputs(); + Iterator iiF = rInputsF.iterator(); + while(iiF.hasNext()) + { + IRecipeInputFluid is = iiF.next(); + rInputsFluids.add(is.getInputs().get(0)); + } + return this.adjustAmounts(rInputsFluids, rInputsItems, true, doAdjustAmounts); + } + + public int getMultiplierAndAdjustAmounts(List fluidInputs1, List itemInputs1) + { + if(this.adjustAmounts(fluidInputs1, itemInputs1, true, true)) + { + if(multiplier ii = itemInputs.iterator(); + while(ii.hasNext()) + { + IRecipeInput is = ii.next(); + if(is.matches(ingredient)) + { + return true; + } + } + return false; + } + + public boolean containFluidStack(FluidStack fluidStack) + { + if(fluidInputs==null || fluidInputs.isEmpty()) + { + return false; + } + Iterator ii = fluidInputs.iterator(); + while(ii.hasNext()) + { + IRecipeInputFluid is = ii.next(); + if(is!=null && is.matches(fluidStack)) + { + return true; + } + } + return false; + } + + private boolean incorrectInputAmount(List fluidInputs1, List itemInputs1) + { + return (fluidInputs.size()>0 && fluidInputs1==null)|| + (itemInputs.size()>0 && itemInputs1==null)|| + (fluidInputs1!=null && fluidInputs.size()>fluidInputs1.size())|| + (itemInputs1!=null && itemInputs.size()>itemInputs1.size()); + } +} diff --git a/ihl/recipes/UniversalRecipeManager.java b/ihl/recipes/UniversalRecipeManager.java new file mode 100644 index 0000000..443a67f --- /dev/null +++ b/ihl/recipes/UniversalRecipeManager.java @@ -0,0 +1,229 @@ +package ihl.recipes; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import ic2.api.recipe.IRecipeInput; +import ihl.utils.IHLUtils; + +public class UniversalRecipeManager { + + 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!"); + } + machineRecipeManagers.put(machine1, this); + } + + private final Map recipes = 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)) + { + Iterator ilist1 = existingInput.getItemInputs().iterator(); + Iterator ilist2 = input.getItemInputs().iterator(); + while(ilist1.hasNext()) + { + IRecipeInput is = ilist1.next(); + } + System.out.println("recipe 2:"); + while(ilist2.hasNext()) + { + IRecipeInput is = ilist2.next(); + } + throw new RuntimeException("Ambiguous recipe."); + } + } + + this.recipes.put(input, output); + } + + + 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 = (Entry)i$.next(); + UniversalRecipeInput recipeInput = (UniversalRecipeInput)entry.getKey(); + + if (!recipeInput.matches(fluidInputs, itemInputs)) + { + continue; + } + + if (recipeInput.adjustAmounts(fluidInputs, itemInputs,true, false)) + { + UniversalRecipeOutput output = (UniversalRecipeOutput)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 UniversalRecipeInput getRecipeInput(List fluidInputs1, List itemInputs1) { + { + Iterator i$ = this.recipes.entrySet().iterator(); + + while (true) + { + if (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + UniversalRecipeInput recipeInput = (UniversalRecipeInput)entry.getKey(); + + if (!recipeInput.matches(fluidInputs1,itemInputs1)) + { + continue; + } + + if (recipeInput.adjustAmounts(fluidInputs1,itemInputs1,true, false)) + { + return recipeInput; + } + } + + return null; + } + } + } + + + public UniversalRecipeOutput getOutputFor(List[] input, boolean adjustInput, boolean inputAffectOutput) + { + return this.getOutputFor(input[0], input[1], adjustInput, inputAffectOutput); + } + + + public UniversalRecipeInput getRecipeInput(List[] input) + { + return this.getRecipeInput(input[0], input[1]); + } + + + public void removeRecipeByInput(UniversalRecipeInput uRecipeInput) + { + Entry entryToRemove = null; + List fluidInputs = IHLUtils.convertRecipeInputToFluidStackList(uRecipeInput.getFluidInputs()); + List itemInputs = IHLUtils.convertRecipeInputToItemStackList(uRecipeInput.getItemInputs()); + { + Iterator i$ = this.recipes.entrySet().iterator(); + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + UniversalRecipeInput recipeInput = (UniversalRecipeInput)entry.getKey(); + if (recipeInput.matches(fluidInputs, itemInputs)) + { + i$.remove(); + break; + } + } + } + } + + public void removeRecipeByOutput(UniversalRecipeOutput uRecipeOutput) + { + Entry entryToRemove = null; + Iterator i$ = this.recipes.entrySet().iterator(); + while (i$.hasNext()) + { + Entry entry = (Entry)i$.next(); + UniversalRecipeOutput recipeOutput = (UniversalRecipeOutput)entry.getValue(); + if (recipeOutputHasCommonEntries(recipeOutput,uRecipeOutput)) + { + i$.remove(); + } + } + } + + public boolean recipeOutputHasCommonEntries(UniversalRecipeOutput out, UniversalRecipeOutput out1) + { + List fluidOutputs = out.getFluidOutputs(); + List itemOutputs = out.getItemOutputs(); + if(!fluidOutputs.isEmpty() && !out1.getFluidOutputs().isEmpty()) + { + FluidStack fs1 = out1.getFluidOutputs().get(0); + Iterator fi = fluidOutputs.iterator(); + while(fi.hasNext()) + { + FluidStack fs = fi.next(); + if(fs.getFluid()==fs1.getFluid()) + { + return true; + } + } + } + if(!itemOutputs.isEmpty() && !out1.getItemOutputs().isEmpty()) + { + RecipeOutputItemStack is1 = out1.getItemOutputs().get(0); + Iterator ii = itemOutputs.iterator(); + while(ii.hasNext()) + { + RecipeOutputItemStack is = ii.next(); + if(is.matches(is1)) + { + return true; + } + } + } + return false; + } +} diff --git a/ihl/recipes/UniversalRecipeOutput.java b/ihl/recipes/UniversalRecipeOutput.java new file mode 100644 index 0000000..bda2bcf --- /dev/null +++ b/ihl/recipes/UniversalRecipeOutput.java @@ -0,0 +1,145 @@ +package ihl.recipes; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public class UniversalRecipeOutput{ + + private final List fluidOutputs=new ArrayList(); + private final List itemOutputs=new ArrayList(); + private final int time; + public final boolean specialConditions; + + public UniversalRecipeOutput(List fluidOutputs1, List itemOutputs1, int time1) + { + this(fluidOutputs1, itemOutputs1, time1,false); + } + + public UniversalRecipeOutput(List fluidOutputs1, List itemOutputs1, int time1, boolean specialConditions1) + { + if(fluidOutputs1!=null) + { + Iterator ioi = fluidOutputs1.iterator(); + while(ioi.hasNext()) + { + FluidStack fStack = ioi.next(); + if(fStack==null) + { + throw new NullPointerException("Recipe cannot contain null elements!"); + } + fluidOutputs.add(fStack); + } + } + if(itemOutputs1!=null) + { + Iterator ioi = itemOutputs1.iterator(); + while(ioi.hasNext()) + { + Object io = ioi.next(); + if(io==null) + { + throw new NullPointerException("Recipe output cannot be null!"); + } + if(io instanceof ItemStack) + { + this.itemOutputs.add(new RecipeOutputItemStack((ItemStack) io)); + } + else + { + this.itemOutputs.add((RecipeOutputItemStack) io); + } + } + } + specialConditions=specialConditions1; + time=time1; + } + + public boolean matches(List fluidOutputs1, List itemOutputs1) + { + if(fluidOutputs.size()!=fluidOutputs1.size()||itemOutputs.size()!=itemOutputs.size()) + { + return false; + } + Iterator fi1 = fluidOutputs1.iterator(); + Iterator ii1 = itemOutputs1.iterator(); + Iterator fi = fluidOutputs.iterator(); + Iterator ii = itemOutputs.iterator(); + while(fi.hasNext()) + { + FluidStack fs = fi.next(); + FluidStack fs1 = fi1.next(); + if(fs.getFluid()!=fs1.getFluid()) + { + return false; + } + } + while(ii.hasNext()) + { + RecipeOutputItemStack is = ii.next(); + ItemStack is1 = ii1.next(); + if(!is.matches(is1)) + { + return false; + } + } + return true; + } + + public List getFluidOutputs() { + return fluidOutputs; + } + + public List getItemOutputs() { + return itemOutputs; + } + + public UniversalRecipeOutput copyWithMultiplier(int mulipier) { + ArrayList fluidStacks = new ArrayList(); + ArrayList itemStacks = new ArrayList(); + if(fluidOutputs!=null && !fluidOutputs.isEmpty()) + { + Iterator fi = fluidOutputs.iterator(); + while(fi.hasNext()) + { + FluidStack fs = fi.next(); + FluidStack newFs = fs.copy(); + newFs.amount*=mulipier; + fluidStacks.add(newFs); + } + } + if(itemOutputs!=null && !itemOutputs.isEmpty()) + { + Iterator ii = itemOutputs.iterator(); + while(ii.hasNext()) + { + RecipeOutputItemStack is = ii.next(); + RecipeOutputItemStack newIs = is.copy(mulipier); + itemStacks.add(newIs); + } + } + return new UniversalRecipeOutput(fluidStacks,itemStacks, getTime(),false); + } + + public int getTime() { + return time; + } + + @Override + public String toString() + { + StringBuffer out = new StringBuffer(); + for(FluidStack fluid: this.fluidOutputs) + { + out.append(fluid.getLocalizedName()+": "+fluid.amount+"/n"); + } + for(RecipeOutputItemStack stack: this.itemOutputs) + { + out.append(stack.itemStack.getDisplayName()+": "+stack.quantity+"/n"); + } + return out.toString(); + } +} diff --git a/ihl/servitor/BoneBlock.java b/ihl/servitor/BoneBlock.java new file mode 100644 index 0000000..1c88b37 --- /dev/null +++ b/ihl/servitor/BoneBlock.java @@ -0,0 +1,107 @@ +package ihl.servitor; + +import java.util.List; + +import ihl.IHLModInfo; +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.creativetab.CreativeTabs; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BoneBlock extends Block { + IIcon textureSide2,textureSide3,textureSide4,textureTop; + + public BoneBlock(Material material) { + super(material); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockSide1"); + this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockTop"); + this.textureSide2 = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockSide2"); + this.textureSide3 = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockSide3"); + this.textureSide4 = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockSide4"); + } + + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + if(!world.isRemote) + { + if(world.getBlock(x, y+1, z)==Blocks.fire) + { + AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y+1D, z, x+1D, y+2D, z+1D); + List pigList = world.getEntitiesWithinAABB(EntityPig.class, aabb); + if(pigList!=null && pigList.size()>0) + { + EntityPig pig = (EntityPig) pigList.get(0); + DamageSource ds = DamageSource.wither; + pig.attackEntityFrom(ds, 10F); + LostHeadEntity lh = new LostHeadEntity(world); + lh.setPosition(pig.posX,pig.posY,pig.posZ); + world.spawnEntityInWorld(lh); + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + Block topBlock = world.getBlock(x, y+1, z); + Block bottomBlock = world.getBlock(x, y-1, z); + IIcon sideIcon = this.blockIcon; + if(topBlock==this && bottomBlock==this) + { + sideIcon = this.textureSide4; + } + else if(topBlock==this) + { + sideIcon = this.textureSide3; + } + else if(bottomBlock==this) + { + sideIcon = this.textureSide2; + } + switch (side) + { + case 0: + return this.textureTop; + case 1: + return this.textureTop; + default: + return sideIcon; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + IIcon sideIcon = this.blockIcon; + switch (side) + { + case 0: + return this.textureTop; + case 1: + return this.textureTop; + default: + return sideIcon; + } + } +} diff --git a/ihl/servitor/FlameEntityFX.java b/ihl/servitor/FlameEntityFX.java new file mode 100644 index 0000000..783476e --- /dev/null +++ b/ihl/servitor/FlameEntityFX.java @@ -0,0 +1,87 @@ +package ihl.servitor; + +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +public class FlameEntityFX extends EntityFX { + + public FlameEntityFX(World world, double x, double y, double z) + { + super(world, x, y, z); + this.renderDistanceWeight = 5.0D; + } + + public FlameEntityFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + this.particleScale *= par14; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.noClip = false; + this.renderDistanceWeight = 6.0D; + } + + @Override + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float var8 = this.particleTextureIndexX / 4.0F; + float var9 = var8 + 0.0624375F*4F; + float var10 = this.particleTextureIndexY / 4.0F; + float var11 = var10 + 0.0624375F*4F; + float var12 = 0.1F * this.particleScale; + + float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX); + float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY); + float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ); + par1Tessellator.addVertexWithUV(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12, var9, var11); + par1Tessellator.addVertexWithUV(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12, var9, var10); + par1Tessellator.addVertexWithUV(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12, var8, var10); + par1Tessellator.addVertexWithUV(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12, var8, var11); + } + + @Override + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + this.setParticleTextureIndex(this.particleAge * 15 / this.particleMaxAge); + this.motionY += 0.004D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.posY == this.prevPosY) + { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } + + @Override + public void setParticleTextureIndex(int par1) + { + this.particleTextureIndexX = par1 % 4; + this.particleTextureIndexY = par1 / 4; + } + +} diff --git a/ihl/servitor/FlameRenderFX.java b/ihl/servitor/FlameRenderFX.java new file mode 100644 index 0000000..1b587b7 --- /dev/null +++ b/ihl/servitor/FlameRenderFX.java @@ -0,0 +1,55 @@ +package ihl.servitor; + +import ihl.IHLModInfo; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class FlameRenderFX extends Render{ + private ResourceLocation tex; + +public FlameRenderFX(String textureLocation) +{ + super(); + tex = new ResourceLocation(textureLocation); +} + +@Override +public void doRender(Entity entity, double x, double y, double z, + float arg4, float arg5) +{ + float var3 = ActiveRenderInfo.rotationX; + float var4 = ActiveRenderInfo.rotationZ; + float var5 = ActiveRenderInfo.rotationYZ; + float var6 = ActiveRenderInfo.rotationXY; + float var7 = ActiveRenderInfo.rotationXZ; + EntityFX.interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * arg4; + EntityFX.interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * arg4; + EntityFX.interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * arg4; + this.renderManager.renderEngine.bindTexture(tex); + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslatef((float)x, (float)y, (float)z); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + Tessellator var9 = Tessellator.instance; + var9.startDrawingQuads(); + EntityFX var11 = (EntityFX) entity; + var11.renderParticle(var9, arg4, var3, var7, var4, var5, var6); + var9.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glPopMatrix(); +} + + @Override + protected ResourceLocation getEntityTexture(Entity arg0) + { + return tex; + } +} \ No newline at end of file diff --git a/ihl/servitor/LostHeadEntity.java b/ihl/servitor/LostHeadEntity.java new file mode 100644 index 0000000..2734d4a --- /dev/null +++ b/ihl/servitor/LostHeadEntity.java @@ -0,0 +1,478 @@ +package ihl.servitor; + +import ic2.api.item.IC2Items; +import ihl.IHLMod; +import ihl.IHLModInfo; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityFlying; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class LostHeadEntity extends EntityFlying implements IMob +{ + public int courseChangeCooldown; + public double waypointX; + public double waypointY; + public double waypointZ; + private Entity targetedEntity; + + /** Cooldown time between target loss and new target aquirement. */ + private int aggroCooldown; + public int prevAttackCounter; + public int attackCounter; + public int attackCounterIncrement; + + private final double psr = 0.5D; + private final double delta = 0.35D; + + private final double damage = 4D; + private final double knockbackStrength=2D; + + + public LostHeadEntity(World par1World) + { + super(par1World); + this.setSize(1.0F, 1.0F); + this.isImmuneToFire = true; + this.experienceValue = 5; + } + + public boolean func_110182_bF() + { + return this.dataWatcher.getWatchableObjectByte(16) != 0; + } + + /** + * Called when the entity is attacked. + */ + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + @Override + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); + } + + @Override + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); + } + + @Override + public void onLivingUpdate() + { + super.onLivingUpdate(); + if(worldObj.isRemote) + { + double x1,y1,z1,x2,z2; + x1=this.prevPosX+psr*Math.sin(-rotationYaw/180D*Math.PI+delta+Math.random()*0.1D-0.05D); + z1=this.prevPosZ+psr*Math.cos(-rotationYaw/180D*Math.PI+delta+Math.random()*0.1D-0.05D); + x2=this.prevPosX+psr*Math.sin(-rotationYaw/180D*Math.PI-delta+Math.random()*0.1D-0.05D); + z2=this.prevPosZ+psr*Math.cos(-rotationYaw/180D*Math.PI-delta+Math.random()*0.1D-0.05D); + y1=this.prevPosY+psr*Math.sin(rotationPitch/180D*Math.PI+Math.random()*0.1D-0.05D)+0.4D; + IHLMod.proxy.spawnParticle(0,worldObj, x1,y1,z1,0D,0.1D,0D,1F); + IHLMod.proxy.spawnParticle(0,worldObj, x2,y1,z2,0D,0.1D,0D,1F); + } + //this part was mindlessly taken from EntityArrow. + Vec3 var17 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 var3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition var4 = this.worldObj.func_147447_a(var17, var3, false, true, false); + var17 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + var3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (var4 != null) + { + var3 = Vec3.createVectorHelper(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord); + } + + Entity var5 = null; + List var6 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double var7 = 0.0D; + int var9; + float var11; + + for (var9 = 0; var9 < var6.size(); ++var9) + { + Entity var10 = (Entity)var6.get(var9); + + if (var10.canBeCollidedWith()) + { + var11 = 0.3F; + AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11); + MovingObjectPosition var13 = var12.calculateIntercept(var17, var3); + + if (var13 != null) + { + double var14 = var17.distanceTo(var13.hitVec); + + if (var14 < var7 || var7 == 0.0D) + { + var5 = var10; + var7 = var14; + } + } + } + } + + + if (var5 != null) + { + var4 = new MovingObjectPosition(var5); + } + + float var19; + float var26; + + if (var4 != null) + { + if (var4.entityHit != null) + { + var19 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + int var23 = MathHelper.ceiling_double_int(var19 * this.damage); + + DamageSource var21 = DamageSource.causeThrownDamage(this, this); + + if (var4.entityHit.attackEntityFrom(var21, var23)) + { + if (var4.entityHit instanceof EntityLivingBase) + { + EntityLivingBase var24 = (EntityLivingBase)var4.entityHit; + + var26 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + if (var26 > 0.0F) + { + var4.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6D / var26, 0.1D, this.motionZ * this.knockbackStrength * 0.6D / var26); + } + } + } + } + } + } + + + @Override + protected void updateEntityActionState() + { + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) + { + this.setDead(); + } + + this.despawnEntity(); + this.prevAttackCounter = this.attackCounter; + double var1 = this.waypointX - this.posX; + double var3 = this.waypointY - this.posY; + double var5 = this.waypointZ - this.posZ; + double var7 = var1 * var1 + var3 * var3 + var5 * var5; + + if (var7 < 1.0D || var7 > 3600.0D) + { + this.waypointX = this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F; + this.waypointY = this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F; + this.waypointZ = this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F; + } + + if (this.courseChangeCooldown-- <= 0) + { + this.courseChangeCooldown += this.rand.nextInt(5) + 2; + var7 = MathHelper.sqrt_double(var7); + + if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, var7)) + { + this.motionX += var1 / var7 * 0.02D; + this.motionY += var3 / var7 * 0.02D; + this.motionZ += var5 / var7 * 0.02D; + } + else + { + this.waypointX = this.posX; + this.waypointY = this.posY; + this.waypointZ = this.posZ; + } + } + + if (this.targetedEntity != null && this.targetedEntity.isDead) + { + if (!this.worldObj.isRemote) + { + this.playSound(IHLModInfo.MODID+":lostHeadLaughtLong", 10F, this.getSoundPitch()); + } + this.targetedEntity = null; + } + + if (this.targetedEntity == null || this.aggroCooldown-- <= 0) + { + this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); + + if (this.targetedEntity != null) + { + this.aggroCooldown = 20; + } + } + + double var9 = 64.0D; + + if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < var9 * var9) + { + double var11 = this.targetedEntity.posX - this.posX; + double var13 = this.targetedEntity.boundingBox.minY + this.targetedEntity.height / 2.0F - (this.posY + this.height / 2.0F); + double var15 = this.targetedEntity.posZ - this.posZ; + this.renderYawOffset = this.rotationYaw = -((float)Math.atan2(var11, var15)) * 180.0F / (float)Math.PI; + + if (this.canEntityBeSeen(this.targetedEntity)) + { + if (this.attackCounter == 70) + { + //play attack scream before attack + if (!this.worldObj.isRemote) + { + this.playSound(IHLModInfo.MODID+":lostHeadLaught", 10F, this.getSoundPitch()); + } + } + + ++this.attackCounter; + + if (this.attackCounter == 80) + { + //play fire sound before attack + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1008, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + double vX = this.targetedEntity.posX-this.posX; + double vY = this.targetedEntity.posY+this.targetedEntity.height-this.posY; + double vZ = this.targetedEntity.posZ-this.posZ; + this.motionX=vX*0.1D; + this.motionY=vY*0.1D; + this.motionZ=vZ*0.1D; + this.courseChangeCooldown=40; + this.attackCounter = -60; + } + } + else if (this.attackCounter > 0) + { + --this.attackCounter; + } + } + else + { + 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.2F; + + if (this.attackCounter > 0) + { + --this.attackCounter; + } + } + + if (!this.worldObj.isRemote) + { + byte var21 = this.dataWatcher.getWatchableObjectByte(16); + byte var12 = (byte)(this.attackCounter > 10 ? 1 : 0); + + if (var21 != var12) + { + this.dataWatcher.updateObject(16, Byte.valueOf(var12)); + } + } + } + + /** + * True if the ghast has an unobstructed line of travel to the waypoint. + */ + private boolean isCourseTraversable(double par1, double par3, double par5, double par7) + { + double var9 = (this.waypointX - this.posX) / par7; + double var11 = (this.waypointY - this.posY) / par7; + double var13 = (this.waypointZ - this.posZ) / par7; + AxisAlignedBB var15 = this.boundingBox.copy(); + + for (int var16 = 1; var16 < par7; ++var16) + { + var15.offset(var9, var11, var13); + + if (!this.worldObj.getCollidingBoundingBoxes(this, var15).isEmpty()) + { + return false; + } + } + + return true; + } + + /** + * Returns the sound this mob makes while it's alive. + */ + @Override + protected String getLivingSound() + { + return IHLModInfo.MODID+":lostHeadCry"; + } + + @Override + public int getTalkInterval() + { + return 400; + } + /** + * Returns the sound this mob makes when it is hurt. + */ + @Override + protected String getHurtSound() + { + return IHLModInfo.MODID+":lostHeadScream"; + } + + /** + * Returns the sound this mob makes on death. + */ + @Override + protected String getDeathSound() + { + return IHLModInfo.MODID+":lostHeadDeath"; + } + + /** + * Drop 0-2 items of this living's type + */ + @Override + protected void dropFewItems(boolean par1, int par2) + { + int var3 = this.rand.nextInt(2) + this.rand.nextInt(1 + par2); + int var4; + + if(var3==0) + { + this.entityDropItem(new ItemStack(IHLMod.ihlSkull,1), 1); + } + else + { + for (var4 = 0; var4 < var3; ++var4) + { + this.entityDropItem(new ItemStack(Items.dye, 1, 15), 1); + } + } + + var3 = this.rand.nextInt(3) + this.rand.nextInt(1 + par2); + + for (var4 = 0; var4 < var3; ++var4) + { + this.entityDropItem(IC2Items.getItem("smallTinDust"), 1); + } + } + + /** + * Returns the volume for the sounds this mob makes. + */ + @Override + protected float getSoundVolume() + { + return 1.0F; + } + + /** + * Checks if the entity's current position is a valid location to spawn this entity. + */ + @Override + public boolean getCanSpawnHere() + { + return this.rand.nextInt(20) == 0 && super.getCanSpawnHere() && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL; + } + + /** + * Will return how many at most can spawn in a chunk at once. + */ + @Override + public int getMaxSpawnedInChunk() + { + return 1; + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + @Override + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + @Override + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + } + + @Override + public void moveEntityWithHeading(float par1, float par2) + { + if (this.isInWater()) + { + this.moveFlying(par1, par2, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + } + else if (this.handleLavaMovement()) + { + this.moveFlying(par1, par2, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } + else + { + float var3 = 0.91F; + + if (this.onGround) + { + var3 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; + } + + float var4 = 0.16277136F / (var3 * var3 * var3); + this.moveFlying(par1, par2, this.onGround ? 0.1F * var4 : 0.02F); + var3 = 0.98F; + + if (this.onGround) + { + var3 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; + } + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= var3; + this.motionY *= var3; + this.motionZ *= var3; + } + } +} diff --git a/ihl/servitor/LostHeadRender.java b/ihl/servitor/LostHeadRender.java new file mode 100644 index 0000000..5f8ee96 --- /dev/null +++ b/ihl/servitor/LostHeadRender.java @@ -0,0 +1,39 @@ +package ihl.servitor; + +import ihl.IHLModInfo; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class LostHeadRender extends Render{ + private SkullModel model = new SkullModel(); + private ResourceLocation tex; + private float scale; + +public LostHeadRender() +{ + super(); + scale = 1F/80F; + tex = new ResourceLocation(IHLModInfo.MODID+":textures/items/skull.png"); +} + +@Override +public void doRender(Entity entity, double x, double y, double z, + float arg4, float arg5) +{ + bindTexture(tex); + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glRotated(entity.rotationYaw+180D, 0D, 1.0D, 0D); + model.Base.render(scale); + GL11.glPopMatrix(); +} + + @Override + protected ResourceLocation getEntityTexture(Entity arg0) + { + return tex; + } +} \ No newline at end of file diff --git a/ihl/servitor/SkullItemRender.java b/ihl/servitor/SkullItemRender.java new file mode 100644 index 0000000..3d00df1 --- /dev/null +++ b/ihl/servitor/SkullItemRender.java @@ -0,0 +1,77 @@ +package ihl.servitor; + +import ihl.IHLModInfo; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; + +public class SkullItemRender implements IItemRenderer{ + private SkullModel model = new SkullModel(); + private ResourceLocation tex; + private float scale; + +public SkullItemRender() +{ + super(); + scale = 1F/80F; + tex = new ResourceLocation(IHLModInfo.MODID+":textures/items/skull.png"); +} + +@Override +public void renderItem(ItemRenderType type, ItemStack item, Object... data) +{ + GL11.glPushMatrix(); + switch(type) + { + case EQUIPPED_FIRST_PERSON: + GL11.glRotatef(80F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0F, 0.18F, 1F); + GL11.glScalef(1.5F, -1.5F, -1.5F); + break; + case ENTITY: + GL11.glTranslatef(0F, 1.0F, 0F); + GL11.glScalef(1.0F, -1F, -1F); + break; + case INVENTORY: + GL11.glRotatef(210F, 0F, 1.0F, -0.15F); + GL11.glTranslatef(0.0F,-0.75F,0.0F); + GL11.glScalef(1.5F, -1.5F, -1.5F); + 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); + 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/servitor/SkullModel.java b/ihl/servitor/SkullModel.java new file mode 100644 index 0000000..1bdbdcf --- /dev/null +++ b/ihl/servitor/SkullModel.java @@ -0,0 +1,153 @@ +package ihl.servitor; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class SkullModel extends ModelBase +{ + //fields + ModelRenderer Base; + + public SkullModel() + { + textureWidth = 256; + textureHeight = 256; + setTextureOffset("Base.Shape2", 110, 11); + setTextureOffset("Base.Shape3", 59, 62); + setTextureOffset("Base.Shape4", 83, 59); + setTextureOffset("Base.Shape5", 83, 59); + setTextureOffset("Base.Shape6", 0, 18); + setTextureOffset("Base.Shape8", 0, 26); + setTextureOffset("Base.Shape9", 2, 33); + setTextureOffset("Base.Shape10", 26, 37); + setTextureOffset("Base.Shape11", 28, 157); + setTextureOffset("Base.Shape12", 83, 111); + setTextureOffset("Base.Shape13", 67, 110); + setTextureOffset("Base.Shape14", 72, 99); + setTextureOffset("Base.Shape15", 92, 114); + setTextureOffset("Base.Shape16", 102, 112); + setTextureOffset("Base.Shape17", 82, 107); + setTextureOffset("Base.Shape18", 71, 108); + setTextureOffset("Base.Shape19", 89, 114); + setTextureOffset("Base.Shape20", 90, 124); + setTextureOffset("Base.Shape21", 106, 31); + setTextureOffset("Base.Shape22", 77, 139); + setTextureOffset("Base.Shape23", 115, 193); + setTextureOffset("Base.Shape24", 1, 163); + setTextureOffset("Base.Shape25", 127, 117); + setTextureOffset("Base.Shape26", 81, 116); + setTextureOffset("Base.Shape27", 81, 115); + setTextureOffset("Base.Shape28", 81, 114); + setTextureOffset("Base.Shape29", 6, 167); + setTextureOffset("Base.Shape1", 0, 154); + setTextureOffset("Base.Shape7", 92, 124); + setTextureOffset("Base.Shape30", 89, 124); + setTextureOffset("Base.Shape31", 128, 193); + setTextureOffset("Base.Shape32", 106, 88); + setTextureOffset("Base.Shape33", 109, 70); + setTextureOffset("Base.Shape34", 166, 109); + setTextureOffset("Base.Shape35", 100, 53); + setTextureOffset("Base.Shape36", 169, 98); + setTextureOffset("Base.Shape37", 99, 81); + setTextureOffset("Base.Shape38", 101, 108); + setTextureOffset("Base.Shape39", 92, 85); + setTextureOffset("Base.Shape40", 22, 89); + setTextureOffset("Base.Shape41", 62, 151); + setTextureOffset("Base.Shape42", 37, 97); + setTextureOffset("Base.Shape43", 9, 101); + setTextureOffset("Base.Shape44", 77, 15); + setTextureOffset("Base.Shape45", 18, 145); + setTextureOffset("Base.Shape46", 28, 156); + setTextureOffset("Base.Shape47", 28, 155); + setTextureOffset("Base.Shape48", 106, 104); + setTextureOffset("Base.Shape49", 77, 129); + setTextureOffset("Base.Shape50", 25, 82); + setTextureOffset("Base.Shape51", 46, 33); + setTextureOffset("Base.Shape52", 101, 85); + setTextureOffset("Base.Shape53", 141, 38); + setTextureOffset("Base.Shape54", 24, 149); + setTextureOffset("Base.Shape55", 83, 132); + setTextureOffset("Base.Shape56", 99, 132); + setTextureOffset("Base.Shape57", 30, 186); + setTextureOffset("Base.Shape58", 142, 220); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, -30F, -30F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = false; + Base.addBox("Shape2", -25F, -24F, 18F, 8, 24, 34); + Base.addBox("Shape3", -23F, -28F, 13F, 46, 4, 38); + Base.addBox("Shape4", -22F, -30F, 14F, 44, 2, 37); + Base.addBox("Shape5", -21F, -32F, 12F, 42, 2, 39); + Base.addBox("Shape6", -19F, -34F, 9F, 38, 2, 43); + Base.addBox("Shape8", -17F, -36F, 11F, 34, 2, 46); + Base.addBox("Shape9", -15F, -38F, 13F, 28, 2, 42); + Base.addBox("Shape10", -9F, -40F, 21F, 20, 2, 24); + Base.addBox("Shape11", -13F, -24F, 1F, 26, 26, 3); + Base.addBox("Shape12", -16F, -11.2F, 66F, 14, 4, 2); + Base.addBox("Shape13", 2F, -11.2F, 66F, 14, 4, 2); + Base.addBox("Shape14", -9F, -24F, 66F, 18, 17, 1); + Base.addBox("Shape15", -2F, -7F, 65F, 4, 7, 3); + Base.addBox("Shape16", -2F, -4F, 68F, 4, 4, 1); + Base.addBox("Shape17", 2F, -10F, 64F, 3, 4, 5); + Base.addBox("Shape18", -5F, -10F, 64F, 3, 4, 5); + Base.addBox("Shape19", -6F, 0F, 65F, 4, 1, 1); + Base.addBox("Shape20", -16F, 1F, 63F, 12, 5, 4); + Base.addBox("Shape21", -24F, 0F, 18F, 8, 4, 38); + Base.addBox("Shape22", -8F, 10F, 66F, 16, 5, 2); + Base.addBox("Shape23", -16F, 4F, 7F, 9, 3, 56); + Base.addBox("Shape24", -10F, 7F, 16F, 8, 3, 52); + Base.addBox("Shape25", -10F, 16F, 17F, 20, 1, 12); + Base.addBox("Shape26", -10F, 15F, 15F, 20, 1, 15); + Base.addBox("Shape27", -11F, 14F, 13F, 22, 1, 18); + Base.addBox("Shape28", -11F, 13F, 11F, 22, 1, 21); + Base.addBox("Shape29", -12F, 7.1F, 8F, 24, 6, 26); + Base.addBox("Shape1", 2F, 7F, 16F, 8, 3, 52); + Base.addBox("Shape7", 2F, 0F, 65F, 4, 1, 1); + Base.addBox("Shape30", 4F, 1F, 63F, 12, 5, 4); + Base.addBox("Shape31", 7F, 4F, 7F, 9, 3, 56); + Base.addBox("Shape32", 16F, 0F, 18F, 8, 4, 38); + Base.addBox("Shape33", 17F, -24F, 18F, 8, 24, 34); + Base.addBox("Shape34", 18F, -7F, 52F, 6, 7, 9); + Base.addBox("Shape35", -24F, -7F, 52F, 6, 7, 9); + Base.addBox("Shape36", 16F, -13F, 56F, 6, 16, 6); + Base.addBox("Shape37", 18F, -24F, 52F, 2, 17, 12); + Base.addBox("Shape38", -22F, -13F, 56F, 6, 16, 6); + Base.addBox("Shape39", -20F, -24F, 52F, 2, 17, 12); + Base.addBox("Shape40", -18F, -28F, 51F, 36, 4, 13); + Base.addBox("Shape41", -17.5F, -30F, 34F, 35, 2, 29); + Base.addBox("Shape42", -18F, -24F, 62F, 36, 17, 4); + Base.addBox("Shape43", -17F, -32F, 7F, 34, 2, 54); + Base.addBox("Shape44", -16.2F, -34F, 51F, 32, 2, 8); + Base.addBox("Shape45", -19.5F, -33F, 8F, 39, 37, 8); + Base.addBox("Shape46", -14F, -26F, 2F, 28, 30, 1); + Base.addBox("Shape47", -15F, -28F, 3F, 30, 32, 2); + Base.addBox("Shape48", -18F, -1F, 56F, 3, 5, 8); + Base.addBox("Shape49", 15F, -1F, 56F, 3, 5, 8); + Base.addBox("Shape50", -5F, -39F, 15F, 12, 1, 6); + Base.addBox("Shape51", -6F, -39F, 45F, 12, 1, 6); + Base.addBox("Shape52", -21.5F, -31F, 11F, 43, 34, 6); + Base.addBox("Shape53", -23.5F, -24F, 13F, 47, 26, 5); + Base.addBox("Shape54", -17F, -30F, 5F, 34, 34, 3); + Base.addBox("Shape55", 8F, 10F, 58F, 2, 4, 9); + Base.addBox("Shape56", -10F, 10F, 58F, 2, 4, 8); + Base.addBox("Shape57", -9F, 4F, 3F, 18, 5, 5); + Base.addBox("Shape58", -8F, 10F, 41F, 16, 1, 25); + } + + @Override +public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/ihl/servitor/SkullModel.txt b/ihl/servitor/SkullModel.txt new file mode 100644 index 0000000..be648bd --- /dev/null +++ b/ihl/servitor/SkullModel.txt @@ -0,0 +1,165 @@ +// Date: 12.07.2014 13:37:52 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + + + + + + +package net.minecraft.src; + +public class ModelShieldModel extends ModelBase +{ + //fields + ModelRenderer Base; + + public ModelShieldModel() + { + textureWidth = 256; + textureHeight = 256; + setTextureOffset("Base.Shape2", 110, 11); + setTextureOffset("Base.Shape3", 59, 62); + setTextureOffset("Base.Shape4", 83, 59); + setTextureOffset("Base.Shape5", 83, 59); + setTextureOffset("Base.Shape6", 0, 18); + setTextureOffset("Base.Shape8", 0, 26); + setTextureOffset("Base.Shape9", 2, 33); + setTextureOffset("Base.Shape10", 26, 37); + setTextureOffset("Base.Shape11", 28, 157); + setTextureOffset("Base.Shape12", 83, 111); + setTextureOffset("Base.Shape13", 67, 110); + setTextureOffset("Base.Shape14", 72, 99); + setTextureOffset("Base.Shape15", 92, 114); + setTextureOffset("Base.Shape16", 102, 112); + setTextureOffset("Base.Shape17", 82, 107); + setTextureOffset("Base.Shape18", 71, 108); + setTextureOffset("Base.Shape19", 89, 114); + setTextureOffset("Base.Shape20", 90, 124); + setTextureOffset("Base.Shape21", 106, 31); + setTextureOffset("Base.Shape22", 77, 139); + setTextureOffset("Base.Shape23", 115, 193); + setTextureOffset("Base.Shape24", 1, 163); + setTextureOffset("Base.Shape25", 127, 117); + setTextureOffset("Base.Shape26", 81, 116); + setTextureOffset("Base.Shape27", 81, 115); + setTextureOffset("Base.Shape28", 81, 114); + setTextureOffset("Base.Shape29", 6, 167); + setTextureOffset("Base.Shape1", 0, 154); + setTextureOffset("Base.Shape7", 92, 124); + setTextureOffset("Base.Shape30", 89, 124); + setTextureOffset("Base.Shape31", 128, 193); + setTextureOffset("Base.Shape32", 106, 88); + setTextureOffset("Base.Shape33", 109, 70); + setTextureOffset("Base.Shape34", 166, 109); + setTextureOffset("Base.Shape35", 100, 53); + setTextureOffset("Base.Shape36", 169, 98); + setTextureOffset("Base.Shape37", 99, 81); + setTextureOffset("Base.Shape38", 101, 108); + setTextureOffset("Base.Shape39", 92, 85); + setTextureOffset("Base.Shape40", 22, 89); + setTextureOffset("Base.Shape41", 62, 151); + setTextureOffset("Base.Shape42", 37, 97); + setTextureOffset("Base.Shape43", 9, 101); + setTextureOffset("Base.Shape44", 77, 15); + setTextureOffset("Base.Shape45", 18, 145); + setTextureOffset("Base.Shape46", 28, 156); + setTextureOffset("Base.Shape47", 28, 155); + setTextureOffset("Base.Shape48", 106, 104); + setTextureOffset("Base.Shape49", 77, 129); + setTextureOffset("Base.Shape50", 25, 82); + setTextureOffset("Base.Shape51", 46, 33); + setTextureOffset("Base.Shape52", 101, 85); + setTextureOffset("Base.Shape53", 141, 38); + setTextureOffset("Base.Shape54", 24, 149); + setTextureOffset("Base.Shape55", 83, 132); + setTextureOffset("Base.Shape56", 99, 132); + setTextureOffset("Base.Shape57", 30, 186); + setTextureOffset("Base.Shape58", 142, 220); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, -30F, -30F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape2", -25F, -24F, 18F, 8, 24, 34); + Base.addBox("Shape3", -23F, -28F, 13F, 46, 4, 38); + Base.addBox("Shape4", -22F, -30F, 14F, 44, 2, 37); + Base.addBox("Shape5", -21F, -32F, 12F, 42, 2, 39); + Base.addBox("Shape6", -19F, -34F, 9F, 38, 2, 43); + Base.addBox("Shape8", -17F, -36F, 11F, 34, 2, 46); + Base.addBox("Shape9", -15F, -38F, 13F, 28, 2, 42); + Base.addBox("Shape10", -9F, -40F, 21F, 20, 2, 24); + Base.addBox("Shape11", -13F, -24F, 1F, 26, 26, 3); + Base.addBox("Shape12", -16F, -11,2F, 66F, 14, 4, 2); + Base.addBox("Shape13", 2F, -11,2F, 66F, 14, 4, 2); + Base.addBox("Shape14", -9F, -24F, 66F, 18, 17, 1); + Base.addBox("Shape15", -2F, -7F, 65F, 4, 7, 3); + Base.addBox("Shape16", -2F, -4F, 68F, 4, 4, 1); + Base.addBox("Shape17", 2F, -10F, 64F, 3, 4, 5); + Base.addBox("Shape18", -5F, -10F, 64F, 3, 4, 5); + Base.addBox("Shape19", -6F, 0F, 65F, 4, 1, 1); + Base.addBox("Shape20", -16F, 1F, 63F, 12, 5, 4); + Base.addBox("Shape21", -24F, 0F, 18F, 8, 4, 38); + Base.addBox("Shape22", -8F, 10F, 66F, 16, 5, 2); + Base.addBox("Shape23", -16F, 4F, 7F, 9, 3, 56); + Base.addBox("Shape24", -10F, 7F, 16F, 8, 3, 52); + Base.addBox("Shape25", -10F, 16F, 17F, 20, 1, 12); + Base.addBox("Shape26", -10F, 15F, 15F, 20, 1, 15); + Base.addBox("Shape27", -11F, 14F, 13F, 22, 1, 18); + Base.addBox("Shape28", -11F, 13F, 11F, 22, 1, 21); + Base.addBox("Shape29", -12F, 7,1F, 8F, 24, 6, 26); + Base.addBox("Shape1", 2F, 7F, 16F, 8, 3, 52); + Base.addBox("Shape7", 2F, 0F, 65F, 4, 1, 1); + Base.addBox("Shape30", 4F, 1F, 63F, 12, 5, 4); + Base.addBox("Shape31", 7F, 4F, 7F, 9, 3, 56); + Base.addBox("Shape32", 16F, 0F, 18F, 8, 4, 38); + Base.addBox("Shape33", 17F, -24F, 18F, 8, 24, 34); + Base.addBox("Shape34", 18F, -7F, 52F, 6, 7, 9); + Base.addBox("Shape35", -24F, -7F, 52F, 6, 7, 9); + Base.addBox("Shape36", 16F, -13F, 56F, 6, 16, 6); + Base.addBox("Shape37", 18F, -24F, 52F, 2, 17, 12); + Base.addBox("Shape38", -22F, -13F, 56F, 6, 16, 6); + Base.addBox("Shape39", -20F, -24F, 52F, 2, 17, 12); + Base.addBox("Shape40", -18F, -28F, 51F, 36, 4, 13); + Base.addBox("Shape41", -17,5F, -30F, 34F, 35, 2, 29); + Base.addBox("Shape42", -18F, -24F, 62F, 36, 17, 4); + Base.addBox("Shape43", -17F, -32F, 7F, 34, 2, 54); + Base.addBox("Shape44", -16,24F, -34,04F, 51F, 32, 2, 8); + Base.addBox("Shape45", -19,5F, -33F, 8F, 39, 37, 8); + Base.addBox("Shape46", -14F, -26F, 2F, 28, 30, 1); + Base.addBox("Shape47", -15F, -28F, 3F, 30, 32, 2); + Base.addBox("Shape48", -18F, -1F, 56F, 3, 5, 8); + Base.addBox("Shape49", 15F, -1F, 56F, 3, 5, 8); + Base.addBox("Shape50", -5F, -39F, 15F, 12, 1, 6); + Base.addBox("Shape51", -6F, -39F, 45F, 12, 1, 6); + Base.addBox("Shape52", -21,5F, -31F, 11F, 43, 34, 6); + Base.addBox("Shape53", -23,5F, -24F, 13F, 47, 26, 5); + Base.addBox("Shape54", -17F, -30F, 5F, 34, 34, 3); + Base.addBox("Shape55", 8F, 10F, 58F, 2, 4, 9); + Base.addBox("Shape56", -10F, 10F, 58F, 2, 4, 8); + Base.addBox("Shape57", -9F, 4F, 3F, 18, 5, 5); + Base.addBox("Shape58", -8F, 10F, 41F, 16, 1, 25); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5); + Base.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5); + } + +} diff --git a/ihl/trans_dimensional_item_teleporter/TDITBlock.java b/ihl/trans_dimensional_item_teleporter/TDITBlock.java new file mode 100644 index 0000000..584692d --- /dev/null +++ b/ihl/trans_dimensional_item_teleporter/TDITBlock.java @@ -0,0 +1,132 @@ +package ihl.trans_dimensional_item_teleporter; + +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 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.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class TDITBlock extends Block implements ITileEntityProvider{ + + IIcon textureLeft, textureRight, textureBack, textureBottom; + + public TDITBlock(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 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 TDITTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditTop"); + this.textureBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditBack"); + this.textureLeft = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditLeft"); + this.textureRight = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditRight"); + this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditBottom"); + } + + @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 TDITTileEntity) + { + TDITTileEntity bte = (TDITTileEntity)te; + if (bte == null || entityPlayer.isSneaking()) { + return false; + } + else if(entityPlayer.getCurrentEquippedItem()==null || !(entityPlayer.getCurrentEquippedItem().getItem() instanceof TDITFrequencyTransmitter)) + { + return bte.getGui(entityPlayer); + } + } + return false; + } + + /** + * Called when the block is placed in the world. + */ + + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + switch (side) + { + case 0: + return this.textureBottom; + case 1: + return this.blockIcon; + case 2: + return this.textureBack; + case 3: + return this.textureBack; + case 4: + return this.textureLeft; + case 5: + return this.textureRight; + default: + return this.blockIcon; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + switch (side) + { + case 0: + return this.textureBottom; + case 1: + return this.blockIcon; + case 2: + return this.textureBack; + case 3: + return this.textureBack; + case 4: + return this.textureLeft; + case 5: + return this.textureRight; + default: + return this.blockIcon; + } + } + +} diff --git a/ihl/trans_dimensional_item_teleporter/TDITContainer.java b/ihl/trans_dimensional_item_teleporter/TDITContainer.java new file mode 100644 index 0000000..6afac87 --- /dev/null +++ b/ihl/trans_dimensional_item_teleporter/TDITContainer.java @@ -0,0 +1,93 @@ +package ihl.trans_dimensional_item_teleporter; + +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 TDITContainer extends ContainerBase { + + protected TDITTileEntity tileEntity; + public int lastStorage = -1; + private final static int height=166; + + public TDITContainer(EntityPlayer entityPlayer, TDITTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + 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.dischargeSlot, 0, 8, 44)); + for(row=0;row<=3;row++) + { + this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, row, 152, 8+row*18)); + } + for(row=0;row<=2;row++) + { + for(col=0;col<=2;col++) + { + this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, row+col*3, 31+col*18, 8+row*18)); + } + } + for(row=0;row<=2;row++) + { + for(col=0;col<=2;col++) + { + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, row+col*3, 89+col*18, 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/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java b/ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java new file mode 100644 index 0000000..3ccf1dd --- /dev/null +++ b/ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java @@ -0,0 +1,173 @@ +package ihl.trans_dimensional_item_teleporter; + +import java.util.LinkedList; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import ic2.api.item.IItemHudInfo; +import ic2.core.IC2; +import ic2.core.util.StackUtil; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +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.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class TDITFrequencyTransmitter extends Item implements IItemHudInfo { + + IIcon textureDamaged; + + public TDITFrequencyTransmitter() + { + super(); + this.setCreativeTab(IHLCreativeTab.tab); + this.maxStackSize=1; + this.setMaxDamage(0); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + if (IC2.platform.isSimulating()) + { + if (itemstack.getItemDamage() == 0) + { + NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemstack); + + if (nbtData.getBoolean("targetSet")) + { + nbtData.setBoolean("targetSet", false); + IC2.platform.messagePlayer(entityplayer, "TDIT Frequency Transmitter unlinked", new Object[0]); + } + } + else + { + itemstack.setItemDamage(0); + } + } + + return itemstack; + } + + @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 TDITTileEntity && IC2.platform.isSimulating()) + { + NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemstack); + boolean targetSet = nbtData.getBoolean("targetSet"); + int dimesionID = nbtData.getInteger("dimesionID"); + int targetX = nbtData.getInteger("targetX"); + int targetY = nbtData.getInteger("targetY"); + int targetZ = nbtData.getInteger("targetZ"); + TDITTileEntity tp = (TDITTileEntity)tileEntity; + + if (!targetSet) + { + targetSet = true; + dimesionID = world.provider.dimensionId; + targetX = tp.xCoord; + targetY = tp.yCoord; + targetZ = tp.zCoord; + IC2.platform.messagePlayer(entityPlayer, "TDIT Frequency Transmitter linked to TDIT.", new Object[0]); + } + else if (tp.xCoord == targetX && tp.yCoord == targetY && tp.zCoord == targetZ) + { + IC2.platform.messagePlayer(entityPlayer, "Can\'t link TDIT to itself.", new Object[0]); + } + else if (tp.targetSet && tp.targetX == targetX && tp.targetY == targetY && tp.targetZ == targetZ) + { + IC2.platform.messagePlayer(entityPlayer, "TDIT link unchanged.", new Object[0]); + } + else + { + tp.setTarget(targetX, targetY, targetZ, dimesionID); + + TileEntity te1 = MinecraftServer.getServer().worldServerForDimension(dimesionID).getTileEntity(targetX, targetY, targetZ); + + if (te1 instanceof TDITTileEntity) + { + TDITTileEntity tp21 = (TDITTileEntity)te1; + + if (!tp21.targetSet) + { + tp21.setTarget(tp.xCoord, tp.yCoord, tp.zCoord, dimesionID); + } + } + + IC2.platform.messagePlayer(entityPlayer, "Teleportation link established.", new Object[0]); + } + + nbtData.setBoolean("targetSet", targetSet); + nbtData.setInteger("dimesionID", dimesionID); + nbtData.setInteger("targetX", targetX); + nbtData.setInteger("targetY", targetY); + nbtData.setInteger("targetZ", targetZ); + itemstack.setItemDamage(1); + return false; + } + else + { + return false; + } + } + + @Override + public List getHudInfo(ItemStack itemStack) { + LinkedList info = new LinkedList(); + if(itemStack.stackTagCompound!=null) + { + NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemStack); + boolean targetSet = nbtData.getBoolean("targetSet"); + if(targetSet) + { + int dimesionID = nbtData.getInteger("dimesionID"); + int targetX = nbtData.getInteger("targetX"); + int targetY = nbtData.getInteger("targetY"); + int targetZ = nbtData.getInteger("targetZ"); + info.add("Dimesion ID: " + dimesionID); + info.add("X coord: " + targetX); + info.add("Y coord: " + targetY); + info.add("Z coord: " + targetZ); + } + else + { + info.add("Memory clean"); + } + } + return info; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon=iconRegister.registerIcon(IHLModInfo.MODID + ":itemTDITFT"); + this.textureDamaged=iconRegister.registerIcon(IHLModInfo.MODID + ":itemTDITFT_1"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int meta) + { + switch(meta) + { + case 0: + return this.itemIcon; + case 1: + return this.textureDamaged; + default: + return this.itemIcon; + } + } +} diff --git a/ihl/trans_dimensional_item_teleporter/TDITGui.java b/ihl/trans_dimensional_item_teleporter/TDITGui.java new file mode 100644 index 0000000..5d4dcfd --- /dev/null +++ b/ihl/trans_dimensional_item_teleporter/TDITGui.java @@ -0,0 +1,57 @@ +package ihl.trans_dimensional_item_teleporter; + +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 TDITGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUITDIT.png"); + private TDITContainer container; + + public TDITGui (TDITContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + } + + @Override + protected void drawGuiContainerForegroundLayer(int param1, int param2) + { + //the parameters for drawString are: string, x, y, color + String status = StatCollector.translateToLocal("ihl.gui.tdit.message" + this.container.tileEntity.currentStatus); + fontRendererObj.drawString(status, 12, 68, 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/trans_dimensional_item_teleporter/TDITTileEntity.java b/ihl/trans_dimensional_item_teleporter/TDITTileEntity.java new file mode 100644 index 0000000..df0cb6f --- /dev/null +++ b/ihl/trans_dimensional_item_teleporter/TDITTileEntity.java @@ -0,0 +1,501 @@ +package ihl.trans_dimensional_item_teleporter; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; + +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.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +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.api.network.NetworkHelper; +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.InvSlotOutput; +import ic2.core.block.invslot.InvSlotUpgrade; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.upgrade.IUpgradableBlock; +import ic2.core.upgrade.IUpgradeItem; +import ic2.core.upgrade.UpgradableProperty; +import ihl.IHLMod; +import ihl.utils.IHLInvSlotDischarge; + +public class TDITTileEntity extends TileEntityInventory implements IEnergySink, IHasGui, IUpgradableBlock +{ + private int startUpCounter=0; + private int tier=4; + private int defaultTier=4; + public int maxStorage=12000; + private int defaultMaxStorage=12000; + private double energy=0D; + private double energyConsume=12000D;//per full stack + public boolean addedToEnergyNet = false; + public final InvSlotUpgrade upgradeSlot; + public final IHLInvSlotDischarge dischargeSlot; + public final InvSlotOutput outputSlot; + public final InvSlot inputSlot; + + public int updateChecksum=-1; + private Random rand = new Random(); + + private AudioSource startAS; + public boolean targetSet=false; + public int targetDimension; + public int targetX; + public int targetY; + public int targetZ; + /** 0 - Ready, 100% + * 1 - Not enough energy + * 2 - Receiver not responding + * 3 - Receiver not defined + * 4 - Clean receiver chamber! + */ + public int currentStatus=0; + public int lastStatus=0; + private int timer=0; + + + public TDITTileEntity() + { + this.defaultTier=IHLMod.config.tditTier; + this.defaultMaxStorage=IHLMod.config.tditMaxEnergyStorage; + this.energyConsume=IHLMod.config.tditEnergyConsumePerStack; + this.dischargeSlot = new IHLInvSlotDischarge(this, 0, Access.IO, this.tier, InvSlot.InvSide.SIDE); + this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 1, 4); + this.outputSlot = new InvSlotOutput(this, "output", 2, 9); + this.inputSlot = new InvSlot(this, "input", 2, InvSlot.Access.I, 9, InvSlot.InvSide.TOP); + } + + @Override + public List getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("tier"); + fields.add("maxStorage"); + fields.add("currentStatus"); + 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; + } + } + this.targetSet = nbttagcompound.getBoolean("targetSet"); + this.targetDimension = nbttagcompound.getInteger("targetDimension"); + this.targetX = nbttagcompound.getInteger("targetX"); + this.targetY = nbttagcompound.getInteger("targetY"); + this.targetZ = nbttagcompound.getInteger("targetZ"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + nbttagcompound.setDouble("energy", this.energy); + nbttagcompound.setBoolean("targetSet", this.targetSet); + nbttagcompound.setInteger("targetDimension", this.targetDimension); + nbttagcompound.setInteger("targetX", this.targetX); + nbttagcompound.setInteger("targetY", this.targetY); + nbttagcompound.setInteger("targetZ", this.targetZ); + } + + @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.startAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(),false,false, 1F); + } + } + + @Override + public void onUnloaded() + { + if (IC2.platform.isRendering() && this.startAS != null) + { + this.startAS.stop(); + this.startAS = 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 false; + } + + @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.tditBlock,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 updateEntityServer() + { + + if (IC2.platform.isSimulating()) + { + this.setOverclockRates(); + if(this.timer>0) + { + this.timer--; + } + else + { + this.timer=60; + int energyToOperate=this.countEnergyToOperate(); + if(energyToOperate>0 && energyToOperate<=this.energy) + { + this.sendItemStack(); + this.energy-=energyToOperate; + } + else if(energyToOperate==0 && this.energy>100D) + { + this.currentStatus=0; + } + else + { + this.currentStatus=1; + } + if(this.currentStatus!=this.lastStatus) + { + NetworkHelper.updateTileEntityField(this, "currentStatus"); + this.lastStatus=this.currentStatus; + } + + } + + } + if(this.dischargeSlot.tier!=this.tier) + { + this.dischargeSlot.tier=this.tier; + } + 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.isRendering() && this.startAS!=null) + { + if(this.getActive()) + { + this.startAS.play(); + } + else + { + this.startAS.stop(); + } + } + + } + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, + ForgeDirection direction) { + return true; + } + + @Override + public String getInventoryName() { + return "tdit"; + } + + 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 TDITGui(new TDITContainer(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 TDITContainer(arg0, this); + } + @Override + public void onGuiClosed(EntityPlayer arg0) {} + + public void setOverclockRates() + { + 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; + } + } + + public void setTarget(int targetX2, int targetY2, int targetZ2, int dimesionID) { + this.targetSet=true; + this.targetX=targetX2; + this.targetY=targetY2; + this.targetZ=targetZ2; + this.targetDimension=dimesionID; + } + + public boolean canRecieve(List itemStackList) + { + int countEmptySlots=0; + for(int i=0;i=itemStackList.size(); + } + + public void recieveItemStack(List itemStackList) + { + this.outputSlot.add(itemStackList); + for (int i = 0; i < this.upgradeSlot.size(); ++i) + { + ItemStack stack = this.upgradeSlot.get(i); + + if (stack != null && stack.getItem() instanceof ic2.core.upgrade.IUpgradeItem && ((IUpgradeItem)stack.getItem()).onTick(stack, this)) + { + //needsInvUpdate = true; + } + } + } + + private int countEnergyToOperate() + { + int energy = 0; + for(int i=0;i itemStackList = new ArrayList(); + for(int i=0;i getUpgradableProperties() + { + Set properties = new HashSet(); + properties.add(UpgradableProperty.ItemProducing); + properties.add(UpgradableProperty.EnergyStorage); + return properties; + } + + @Override + public double getEnergy() { + return this.energy; + } + + @Override + public boolean useEnergy(double arg0) { + if(this.energy>=arg0) + { + this.energy-=arg0; + return true; + } + else + { + return false; + } + + } +} \ No newline at end of file diff --git a/ihl/tunneling_shield/BlockItemRender.java b/ihl/tunneling_shield/BlockItemRender.java new file mode 100644 index 0000000..27b0f04 --- /dev/null +++ b/ihl/tunneling_shield/BlockItemRender.java @@ -0,0 +1,206 @@ +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>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 new file mode 100644 index 0000000..e7e1c90 --- /dev/null +++ b/ihl/tunneling_shield/DriverEntity.java @@ -0,0 +1,69 @@ +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 new file mode 100644 index 0000000..c7c8664 --- /dev/null +++ b/ihl/tunneling_shield/DriverGui.java @@ -0,0 +1,102 @@ +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; +import ic2.core.network.NetworkManager; + +@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; + } + + @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 new file mode 100644 index 0000000..edb8aa8 --- /dev/null +++ b/ihl/tunneling_shield/DriverModel.java @@ -0,0 +1,161 @@ +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 new file mode 100644 index 0000000..e2c6802 --- /dev/null +++ b/ihl/tunneling_shield/DriverRender.java @@ -0,0 +1,50 @@ +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 new file mode 100644 index 0000000..127c9a3 --- /dev/null +++ b/ihl/tunneling_shield/DriverRenderEntity.java @@ -0,0 +1,150 @@ +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 rotationSpeed=0F; + private float rotationAmount=1F; + private float rotationAmount2=0F; + private float shiftCorrection=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 new file mode 100644 index 0000000..2c3f2d8 --- /dev/null +++ b/ihl/tunneling_shield/DriverTileEntity.java @@ -0,0 +1,1138 @@ +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.network.NetworkManager; +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; + } + } + + + @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(); + } + } + + @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=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 new file mode 100644 index 0000000..8048d45 --- /dev/null +++ b/ihl/tunneling_shield/HorizontalMiningPipe.java @@ -0,0 +1,276 @@ +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 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.engine, 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 new file mode 100644 index 0000000..263d2e1 --- /dev/null +++ b/ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java @@ -0,0 +1,63 @@ +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); + if(!this.container.tileEntity.engine.correctContent()) + { + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 33, xOffset, yOffset); + } + } + + @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 new file mode 100644 index 0000000..e1d2b39 --- /dev/null +++ b/ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java @@ -0,0 +1,273 @@ +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.isGuiScreenOpened=true; + 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/this.engine.getEfficiency(); + } + + @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 new file mode 100644 index 0000000..e4d32d7 --- /dev/null +++ b/ihl/tunneling_shield/IMultiBlock.java @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..511d8cd --- /dev/null +++ b/ihl/tunneling_shield/MultiBlockSpacerBlock.java @@ -0,0 +1,226 @@ +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 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; + } + + @Override + public ArrayList getDrops(World world,int x, int y, int z, int meta, int flag) + { + ArrayList nothing = new ArrayList(); + nothing.clear(); + return nothing; + } + + /** + * 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/ChunkAndWorldLoadEventHandler.java b/ihl/utils/ChunkAndWorldLoadEventHandler.java new file mode 100644 index 0000000..3fb51f7 --- /dev/null +++ b/ihl/utils/ChunkAndWorldLoadEventHandler.java @@ -0,0 +1,63 @@ +package ihl.utils; + +import ihl.IHLMod; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.world.ChunkCoordIntPair; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class ChunkAndWorldLoadEventHandler +{ + public static ChunkAndWorldLoadEventHandler instance; + 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); + long cc = ChunkCoordIntPair.chunkXZ2Int(event.getChunk().xPosition, event.getChunk().zPosition); + if(bwdata.data.containsKey(cc)) + { + Long[][] bwArray = bwdata.data.remove(cc); + Set svset = new HashSet(16); + int sourceIndex=0; + for(int i1=0;i1<16;i1++) + { + if(bwArray[i1][0]!=null && !bwArray[i1][0].equals(0)) + { + sourceIndex=i1; + svset.add(bwArray[i1][0]); + IHLMod.explosionHandler.setPower(bwArray[i1][0], bwArray[i1][4].intValue()); + } + } + IHLMod.explosionHandler.doExplosion(event.world, bwArray[sourceIndex][1].intValue(), bwArray[sourceIndex][2].intValue(), bwArray[sourceIndex][3].intValue(), svset); + } + } + } + + @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); + } + } + + @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)); + } + } +} diff --git a/ihl/utils/EntityDropEventHandler.java b/ihl/utils/EntityDropEventHandler.java new file mode 100644 index 0000000..f4021ef --- /dev/null +++ b/ihl/utils/EntityDropEventHandler.java @@ -0,0 +1,16 @@ +package ihl.utils; + +import net.minecraft.entity.passive.EntitySheep; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class EntityDropEventHandler +{ + @SubscribeEvent + public void onEntityDropEvent(net.minecraftforge.event.entity.living.LivingDropsEvent event) + { + if(event.entityLiving instanceof EntitySheep && !event.entityLiving.isChild()) + { + event.entityLiving.entityDropItem(IHLUtils.getThisModItemStackWithSize("muttonLard", event.entityLiving.worldObj.rand.nextInt(1)+1), 1f); + } + } +} diff --git a/ihl/utils/EntityIHLExplosion.java b/ihl/utils/EntityIHLExplosion.java new file mode 100644 index 0000000..df0dc18 --- /dev/null +++ b/ihl/utils/EntityIHLExplosion.java @@ -0,0 +1,187 @@ +package ihl.utils; + +import ihl.IHLMod; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +public class EntityIHLExplosion extends Entity { + private Explosion explosion; + private boolean explosionDone=false; + public Set effectBorderBlocks; + public Set effectBorderBlocksWithLowPosition; + public Set blocksConnectedWithBedrock; + public Set blocksNotConnectedWithBedrock; + public int explosionPower; + public int x; + public int y; + public int z; + private Map entityCache = new HashMap(); + + public EntityIHLExplosion(World world,int x1,int y1,int z1, int explosionPower1) { + super(world); + this.effectBorderBlocks=new HashSet(); + this.effectBorderBlocksWithLowPosition=new HashSet(); + this.blocksConnectedWithBedrock=new HashSet(); + this.blocksNotConnectedWithBedrock=new HashSet(); + this.isImmuneToFire=true; + this.noClip=true; + this.setSize(0F, 0F); + this.x=x1; + this.y=y1; + this.z=z1; + this.setPosition(x+0.5d, y+0.5d, z+0.5d); + this.explosionPower = explosionPower1; + } + + + + @Override + public void onUpdate() + { + if(!worldObj.isRemote) + { + if(!effectBorderBlocks.isEmpty()) + { + boolean hasSomeBlocksStickedToAir=false; + Iterator ebbi = effectBorderBlocks.iterator(); + while(ebbi.hasNext()) + { + long longNumber = ebbi.next(); + int[] xyz = IHLUtils.decodeXYZ(longNumber); + Block block = worldObj.getBlock(x+xyz[0], y+xyz[1], z+xyz[2]); + if(block!=Blocks.air && !block.isAir(worldObj, x+xyz[0], y+xyz[1], z+xyz[2])) + { + if(block.getMaterial().isLiquid()) + { + block.onNeighborBlockChange(worldObj, x+xyz[0], y+xyz[1], z+xyz[2], block); + } + else if(!this.isBlockConnectedWithBedrock(longNumber)) + { + hasSomeBlocksStickedToAir=true; + } + } + } + Iterator bnctbi = this.blocksNotConnectedWithBedrock.iterator(); + while(bnctbi.hasNext()) + { + long longNumber5 = bnctbi.next(); + int[] xyz = IHLUtils.decodeXYZ(longNumber5); + Block block = worldObj.getBlock(x+xyz[0], y+xyz[1], z+xyz[2]); + float bh = block.getBlockHardness(worldObj, x+xyz[0], y+xyz[1], z+xyz[2]); + if(bh>=0f && bh path = new HashSet(); + Iterator pathi = path.iterator(); + Set deadlockBlocks = new HashSet(); + int[] xyz = IHLUtils.decodeXYZ(longNumber); + int absX=x+xyz[0]; + int absY=y+xyz[1]; + int absZ=z+xyz[2]; + path.add(longNumber); + while(absY>4) + { + int xyzi[] = {0,0,-1,0,0,1,0,0}; + Block block; + int x2,y2,z2; + boolean deadlock = true; + for(int i=0;i<=5;i++) + { + x2=absX+xyzi[i]; + y2=absY+xyzi[i+2]; + z2=absZ+xyzi[i+1]; + long longNumber2 = IHLUtils.encodeXYZ(x2-x, y2-y, z2-z); + if(this.blocksConnectedWithBedrock.contains(longNumber2)) + { + this.blocksConnectedWithBedrock.addAll(path); + return true; + } + if(!path.contains(longNumber2)) + { + block = worldObj.getBlock(x2,y2,z2); + if(block!=Blocks.air && !block.isAir(worldObj, x2,y2,z2) && !block.getMaterial().isLiquid()) + { + absX=x2; + absY=y2; + absZ=z2; + path.add(longNumber2); + if(absY<=4) + { + this.blocksConnectedWithBedrock.addAll(path); + return true; + } + deadlock = false; + break; + } + } + } + if(deadlock) + { + long longNumber3 = IHLUtils.encodeXYZ(absX-x, absY-y, absZ-z); + deadlockBlocks.add(longNumber3); + boolean deadEnd=true; + while(pathi.hasNext()) + { + long longNumber4 = pathi.next(); + if(!deadlockBlocks.contains(longNumber4)) + { + int[] xyz2 = IHLUtils.decodeXYZ(longNumber4); + absX=x+xyz2[0]; + absY=y+xyz2[1]; + absZ=z+xyz2[2]; + deadEnd=false; + break; + } + } + if(deadEnd) + { + this.blocksNotConnectedWithBedrock.addAll(path); + return false; + } + } + } + this.blocksConnectedWithBedrock.addAll(path); + return true; + } + + + @Override + protected void entityInit() {} + + @Override + protected void readEntityFromNBT(NBTTagCompound arg0) {} + + @Override + protected void writeEntityToNBT(NBTTagCompound arg0) {} + + +} diff --git a/ihl/utils/ExplosionVector.java b/ihl/utils/ExplosionVector.java new file mode 100644 index 0000000..d341fd3 --- /dev/null +++ b/ihl/utils/ExplosionVector.java @@ -0,0 +1,453 @@ +package ihl.utils; + +import ihl.IHLMod; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S26PacketMapChunkBulk; +import net.minecraft.util.DamageSource; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.NibbleArray; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; + +public class ExplosionVector +{ + public Set startVectors = new HashSet(); + private Set sv; + private Set chunksToUpdate=new HashSet(64); + public Map> vectors = new HashMap(32786); + public Map explosions = new HashMap(); + public Map explosionPower = new HashMap(); + public Map explosionPowerDampingFactor = new HashMap(32786); + public Map cachedEBS = new HashMap(128); + public Map cachedEBSHardness = new HashMap(128); + public Map> cachedEBSDrops = new HashMap(128); + public Map> cachedEBSEntity = new HashMap(128); + public Map blastWaveByDimensionId = new HashMap(); + + private Random random = new Random(); + + public ExplosionVector() + { + this.precalculateExplosion(); + } + + public void precalculateExplosion() + { + int maxExplosionRadius=32; + for(int levelRadius=1; levelRadiusMath.round(levelRadius*1.8f)) + { + prevX=IHLUtils.reduceVariableByAbsoluteValue(prevX); + prevY=IHLUtils.reduceVariableByAbsoluteValue(prevY); + prevZ=IHLUtils.reduceVariableByAbsoluteValue(prevZ); + } + else if(Math.abs(ix)<=Math.abs(iy) && Math.abs(ix)<=Math.abs(iz)) + { + prevY=IHLUtils.reduceVariableByAbsoluteValue(prevY); + prevZ=IHLUtils.reduceVariableByAbsoluteValue(prevZ); + } + else if(Math.abs(iy)<=Math.abs(ix) && Math.abs(iy)<=Math.abs(iz)) + { + prevX=IHLUtils.reduceVariableByAbsoluteValue(prevX); + prevZ=IHLUtils.reduceVariableByAbsoluteValue(prevZ); + } + else if(Math.abs(iz)<=Math.abs(ix) && Math.abs(iz)<=Math.abs(iy)) + { + prevY=IHLUtils.reduceVariableByAbsoluteValue(prevY); + prevX=IHLUtils.reduceVariableByAbsoluteValue(prevX); + } + long prevKey = IHLUtils.encodeXYZ(prevX,prevY,prevZ); + if(prevX==ix && prevY==iy && prevZ==iz && levelRadius>1) + { + IHLMod.log.error("Was:"+ix+"/" +iy+"/" +iz+"/"); + IHLMod.log.error("Now:"+prevX+"/" +prevY+"/" +prevZ+"/"); + throw new ArithmeticException("Variables are out of expected range. \n Expected are not equal: "+ix+"="+prevX+" "+iy+"="+prevY+" "+iz+"="+prevZ); + } + if(levelRadius==1) + { + startVectors.add(coordinateKey); + this.addElement(coordinateKey, prevX, prevY, prevZ, ix, iy, iz); + } + else if(vectors.containsKey(prevKey)) + { + //prevKey=this.getParentWithLowestDescendantsRate(prevKey, prevX, prevY, prevZ, levelRadius); + vectors.get(prevKey).add(coordinateKey); + this.addElement(coordinateKey, prevX, prevY, prevZ, ix, iy, iz); + } + else + { + IHLMod.log.error("Was:"+ix+"/" +iy+"/" +iz+"/"); + IHLMod.log.error("Now:"+prevX+"/" +prevY+"/" +prevZ+"/"); + IHLMod.log.info("ExplosionVector is missing parent! Help him!"); + } + } + } + } + } + } + } + } + + private void addElement(long coordinateKey, int prevX, int prevY, int prevZ, int ix, int iy, int iz) + { + vectors.put(coordinateKey, new HashSet()); + float df = (float)(prevX*prevX+prevY*prevY+prevZ*prevZ+1)/(float)(ix*ix+iy*iy+iz*iz+1); + explosionPowerDampingFactor.put(coordinateKey,df); + } + + public void setPower(Set sv2, int power1) + { + for(long ev:sv2) + { + this.setPower(ev, power1); + } + } + + public void setPower(Long ev, int power1) { + this.explosionPower.put(ev, power1); + } +/* + public Set breakBlocksAndGetDescendants(World world, EntityIHLExplosion exploder, Explosion explosion, long longNumber) + { + int multiplier = exploder.multiplier; + int[] xyz = IHLUtils.decodeXYZ(longNumber); + int power1 = explosionPower.get(longNumber); + int repeat=0; + //System.out.println("Power before " + power1); + if(Math.abs(xyz[0])>=Math.abs(xyz[1]) && Math.abs(xyz[0])>=Math.abs(xyz[2])) + { + for(int ix=xyz[0]>0?0:multiplier-1;ix=0;ix=xyz[0]>0?ix+1:ix-1) + { + for(int iy=xyz[1]>0?0:multiplier-1;iy=0;iy=xyz[1]>0?iy+1:iy-1) + { + for(int iz=xyz[2]>0?0:multiplier-1;iz=0;iz=xyz[2]>0?iz+1:iz-1) + { + power1 = this.getNewPowerAndProcessBlocks(world, exploder, explosion, xyz, multiplier, ix, iy, iz, power1); + } + } + } + } + else if(Math.abs(xyz[1])>=Math.abs(xyz[0]) && Math.abs(xyz[1])>=Math.abs(xyz[2])) + { + for(int iy=xyz[1]>0?0:multiplier-1;iy=0;iy=xyz[1]>0?iy+1:iy-1) + { + for(int ix=xyz[0]>0?0:multiplier-1;ix=0;ix=xyz[0]>0?ix+1:ix-1) + { + for(int iz=xyz[2]>0?0:multiplier-1;iz=0;iz=xyz[2]>0?iz+1:iz-1) + { + power1 = this.getNewPowerAndProcessBlocks(world, exploder, explosion, xyz, multiplier, ix, iy, iz, power1); + } + } + } + } + else + { + for(int iz=xyz[2]>0?0:multiplier-1;iz=0;iz=xyz[2]>0?iz+1:iz-1) + { + for(int ix=xyz[0]>0?0:multiplier-1;ix=0;ix=xyz[0]>0?ix+1:ix-1) + { + for(int iy=xyz[1]>0?0:multiplier-1;iy=0;iy=xyz[1]>0?iy+1:iy-1) + { + power1 = this.getNewPowerAndProcessBlocks(world, exploder, explosion, xyz, multiplier, ix, iy, iz, power1); + } + } + } + } + power1=Math.round(power1*explosionPowerDampingFactor.get(longNumber)-0.5f); + //System.out.println("Power after " + power1 + " \n repeats "+repeat); + if(power1<=1 || !vectors.containsKey(longNumber)|| vectors.get(longNumber).isEmpty()) + { + exploder.effectBorderBlocks.add(longNumber); + if(xyz[1]<0 || (exploder.y<=6 && xyz[1]<=6)) + { + exploder.effectBorderBlocksWithLowPosition.add(longNumber); + } + return null; + } + else + { + for(long d1:vectors.get(longNumber)) + { + explosionPower.put(d1, power1); + } + return vectors.get(longNumber); + } + } + */ + + public Set breakBlocksAndGetDescendantsForEBS(World world, int sourceX,int sourceY,int sourceZ, Explosion explosion, long longNumber) + { + int[] xyz = IHLUtils.decodeXYZ(longNumber); + int power1 = explosionPower.remove(longNumber); + power1 = this.getNewPowerAndProcessBlocksEBS(world, longNumber, sourceX, sourceY, sourceZ, explosion, xyz, power1); + power1=Math.round(power1*explosionPowerDampingFactor.get(longNumber)-0.5f); + if(power1<=1 || !vectors.containsKey(longNumber)|| vectors.get(longNumber).isEmpty()) + { + return null; + } + else + { + for(long d1:vectors.get(longNumber)) + { + explosionPower.put(d1, power1); + } + return vectors.get(longNumber); + } + + } +/* + private int getNewPowerAndProcessBlocks(World world, EntityIHLExplosion exploder, Explosion explosion, int xyz[], int multiplier, int ix, int iy, int iz, int power2) + { + int power1=power2; + int x = exploder.x+xyz[0]*multiplier+ix; + int y = exploder.y+xyz[1]*multiplier+iy; + int z = exploder.z+xyz[2]*multiplier+iz; + if(y<=4 || y>256) + { + return 0; + } + Block block = exploder.getBlock(x, y, z); + int explosionResistance = Math.round(block.getExplosionResistance(exploder, world, x, y, z, exploder.x, exploder.y, exploder.z)*10f); + if(explosionResistance>=power1) + { + power1=0; + } + else + { + power1-=Math.round(block.getExplosionResistance(exploder, world, x, y, z, exploder.x, exploder.y, exploder.z)*10f); + Entity entity = exploder.getEntity(x, y, z); + if(entity!=null) + { + entity.attackEntityFrom(exploder.damageSource, power1/10f); + } + block.onBlockDestroyedByExplosion(world, x, y, z, explosion); + exploder.setBlockToAir(x, y, z); + } + return power1; + } + */ + private int getNewPowerAndProcessBlocksEBS(World world, long longNumber, int sourceX, int sourceY, int sourceZ, Explosion explosion, int xyz[], int power2) + { + int power1=power2; + int absEBSX = xyz[0] + (sourceX>>4); + int absEBSY = xyz[1] + (sourceY>>4); + int absEBSZ = xyz[2] + (sourceZ>>4); + long chunkXZKey = ChunkCoordIntPair.chunkXZ2Int(absEBSX, absEBSZ); + if(absEBSY<0 || absEBSY>=16) + { + return 0; + } + if(world.getChunkProvider().chunkExists(absEBSX, absEBSZ)) + { + long absEBShash = IHLUtils.getXYZHash(absEBSX, absEBSY, absEBSZ); + int explosionResistance = this.getEBSResistance(world, absEBShash, absEBSX, absEBSY, absEBSZ, sourceX, sourceY, sourceZ); + if(explosionResistance>=power1) + { + power1=0; + } + else + { + power1-=explosionResistance; + if(this.cachedEBSEntity.containsKey(absEBShash)) + { + List entityList = this.cachedEBSEntity.get(absEBShash); + for(Object entity:entityList.toArray()) + { + if(entity!=null) + { + ((Entity) entity).attackEntityFrom(DamageSource.setExplosionSource(explosion), power1/10f); + } + } + } + this.onEBSDestroy(world, absEBShash, absEBSX, absEBSY, absEBSZ); + } + } + else + { + WorldSavedDataBlastWave blastWave = null; + int dimensionId = world.provider.dimensionId; + if(this.blastWaveByDimensionId.containsKey(dimensionId)) + { + blastWave=this.blastWaveByDimensionId.get(dimensionId); + } + else + { + blastWave=new WorldSavedDataBlastWave("blastWave"); + this.blastWaveByDimensionId.put(dimensionId, blastWave); + } + blastWave.scheduleExplosionEffectsOnChunkLoad(chunkXZKey, longNumber, sourceX, sourceY, sourceZ, power1, absEBSY); + } + return power1; + } + + public int getEBSResistance(World world, long absEBShash, int absEBSX, int absEBSY, int absEBSZ, int sourceX, int sourceY, int sourceZ) + { + + if(this.cachedEBSHardness.containsKey(absEBShash)) + { + return this.cachedEBSHardness.get(absEBShash); + } + else + { + this.precacheChunk(world, absEBSX,absEBSZ, sourceX, sourceY, sourceZ); + return this.cachedEBSHardness.containsKey(absEBShash)?this.cachedEBSHardness.get(absEBShash):0; + } + } + + public void precacheChunk(World world, int absEBSX, int absEBSZ, int sourceX, int sourceY, int sourceZ) + { + Chunk chunk = world.getChunkProvider().provideChunk(absEBSX, absEBSZ); + ExtendedBlockStorage[] ebsA = chunk.getBlockStorageArray(); + for(int y3=0;y3 drops = new HashMap(); + for(int i4=0;i4>8) & 15, (i4>>4) & 15) << 8; + } + int blockWorldX = (i4 & 15)+(absEBSX<<4); + int blockWorldY = ((i4>>8) & 15)+(y3<<4); + int blockWorldZ = ((i4>>4) & 15)+(absEBSZ<<4); + Block block = Block.getBlockById(var4); + List dropsList = (block.getDrops(world, blockWorldX, blockWorldY, blockWorldZ, ebs.getExtBlockMetadata(i4 & 15, (i4>>8) & 15, (i4>>4) & 15), 0)); + if(dropsList!=null) + { + for(ItemStack drop:dropsList) + { + long key = (Item.getIdFromItem(drop.getItem())<<16)|drop.getItemDamage(); + if(drops.containsKey(key)) + { + int ss = drops.get(key); + drops.put(key, drop.stackSize+ss); + } + else + { + drops.put(key, drop.stackSize); + } + } + } + if(block.getBlockHardness(world, blockWorldX, blockWorldY, blockWorldZ)<0) + { + ebsHardness=Integer.MAX_VALUE; + break; + } + else + { + ebsHardness+=Math.round(block.getExplosionResistance(null, world, blockWorldX, blockWorldY, blockWorldZ, sourceX, sourceY, sourceZ)*10f); + } + } + this.cachedEBSDrops.put(absEBShash1, drops); + this.cachedEBSEntity.put(absEBShash1, chunk.entityLists[y3]); + this.cachedEBSHardness.put(absEBShash1, ebsHardness); + this.cachedEBS.put(absEBShash1, ebs); + } + } + } + + public void onEBSDestroy(World world,long absEBShash,int absEBSX,int absEBSY,int absEBSZ) + { + if(this.cachedEBS.containsKey(absEBShash)) + { + ExtendedBlockStorage ebs = this.cachedEBS.get(absEBShash); + ebs.setBlockMSBArray(new NibbleArray(4096, 4)); + ebs.setBlockLSBArray(new byte[4096]); + this.cachedEBS.remove(absEBShash); + this.cachedEBSDrops.remove(absEBShash); + this.cachedEBSEntity.remove(absEBShash); + this.cachedEBSHardness.remove(absEBShash); + this.chunksToUpdate.add(world.getChunkProvider().provideChunk(absEBSX, absEBSZ)); + } + } + + public void sendChunkUpdateToPlayersInExplosionAffectedZone(World world) + { + for(Object player:world.playerEntities) + { + if(player instanceof EntityPlayerMP) + { + EntityPlayerMP playerMP = (EntityPlayerMP)player; + List chunks = new ArrayList(); + chunks.addAll(this.chunksToUpdate); + playerMP.playerNetServerHandler.sendPacket(new S26PacketMapChunkBulk(chunks)); + this.chunksToUpdate.clear(); + } + } + } + + public void doExplosion(World world, int sourceX, int sourceY, int sourceZ, Set startVectors1) + { + boolean doExplosion=true; + long sourceHash = IHLUtils.getXYZHash(sourceX, sourceY, sourceZ); + Explosion explosion = new Explosion(world, null, sourceX, sourceY, sourceZ, 100f); + explosions.put(sourceHash, explosion); + while(doExplosion) + { + Set sv2=new HashSet(); + if(sv==null) + { + sv = startVectors1; + } + for(long ev:sv) + { + Set sv3 = this.breakBlocksAndGetDescendantsForEBS(world, sourceX, sourceY, sourceZ, explosion, ev); + if(sv3!=null) + { + sv2.addAll(sv3); + } + } + if(sv2.isEmpty()) + { + doExplosion=false; + sv = null; + sendChunkUpdateToPlayersInExplosionAffectedZone(world); + break; + } + else + { + sv=sv2; + } + } + + + } + + +} diff --git a/ihl/utils/FluidDictionary.java b/ihl/utils/FluidDictionary.java new file mode 100644 index 0000000..fa5b96a --- /dev/null +++ b/ihl/utils/FluidDictionary.java @@ -0,0 +1,42 @@ +package ihl.utils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class FluidDictionary +{ + private Map> nameToStack = new HashMap(); + private Map fluidToName = new HashMap(); + public FluidDictionary(){} + + public List getFluids(String fdName) + { + return nameToStack.get(fdName); + } + + public void registerFluidStack(String fdName, FluidStack fstack) + { + if(nameToStack.containsKey(fdName)) + { + nameToStack.get(fdName).add(fstack); + } + else + { + List list = new ArrayList(); + list.add(fstack); + nameToStack.put(fdName, list); + } + fluidToName.put(fstack.getFluid(), fdName); + } + + public String getFluidName(Fluid f) + { + return fluidToName.get(f); + } + +} diff --git a/ihl/utils/IHLFluidTank.java b/ihl/utils/IHLFluidTank.java new file mode 100644 index 0000000..aef2b46 --- /dev/null +++ b/ihl/utils/IHLFluidTank.java @@ -0,0 +1,439 @@ +package ihl.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import ihl.recipes.IRecipeInputFluid; +import ihl.worldgen.ores.IHLFluid; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidTank; + +public class IHLFluidTank implements IFluidTank +{ + private final List fluidList = new ArrayList(); + private final int capacity; + private boolean isOpenVessel=false; + private int temperature=293; + + public IHLFluidTank(int capacity) + { + this.capacity = capacity; + } + + public IHLFluidTank(int capacity, boolean isOpenVessel1) + { + this.isOpenVessel=isOpenVessel1; + this.capacity = capacity; + } + + public IHLFluidTank readFromNBT(NBTTagCompound nbt) + { + if (!nbt.hasKey("Empty")) + { + NBTTagList fluidList1 = nbt.getTagList("fluids", 10); + for(int i=0;i fli = fluidList.iterator(); + while(fli.hasNext()) + { + FluidStack fluid=fli.next(); + if(fluid!=null) + { + NBTTagCompound fluidNBT1 = new NBTTagCompound(); + fluid.writeToNBT(fluidNBT1); + fluids.appendTag(fluidNBT1); + } + } + nbt.setTag("fluids", fluids); + nbt.setInteger("temperature", temperature); + } + else + { + nbt.setString("Empty", ""); + } + return nbt; + } + + /* IFluidTank */ + @Override + public FluidStack getFluid() + { + if(this.fluidList.isEmpty()) + { + return null; + } + return this.fluidList.get(0); + } + + public FluidStack getLigthestFluid() + { + if(this.fluidList.isEmpty()) + { + return null; + } + return this.fluidList.get(this.fluidList.size()-1); + } + + @Override + public int getFluidAmount() + { + int amount=0; + Iterator fli = fluidList.iterator(); + while(fli.hasNext()) + { + FluidStack fluid=fli.next(); + if(fluid!=null) + { + amount+=fluid.amount; + } + } + return amount; + } + + @Override + public int getCapacity() + { + return capacity; + } + + @Override + public FluidTankInfo getInfo() + { + return new FluidTankInfo(this); + } + + @Override + public int fill(FluidStack resource, boolean doFill) + { + if (resource == null || resource.getFluid() == null || resource.amount<=0) + { + return 0; + } + if (!doFill) + { + if (fluidList.isEmpty()) + { + return Math.min(capacity, resource.amount); + } + return Math.min(capacity - this.getFluidAmount(), resource.amount); + } + if (fluidList.isEmpty()) + { + FluidStack fluid = copyWithSize(resource,Math.min(capacity, resource.amount)); + fluidList.add(fluid); + this.temperature=fluid.getFluid().getTemperature(); + return fluid.amount; + } + this.temperature=alignTemperatures(resource); + FluidStack fluid = getFluidStackWithSameFluid(resource); + if(fluid!=null) + { + int amount1=Math.min(capacity - this.getFluidAmount(), resource.amount); + fluid.amount+=amount1; + return amount1; + } + fluid = copyWithSize(resource,Math.min(capacity, resource.amount)); + fluidList.add(fluid); + this.sortFluidsByDensity(); + return fluid.amount; + } + + private int alignTemperatures(FluidStack resource) + { + int amountOfFluidInTank = this.getFluidAmount(); + int averageT=(this.temperature*amountOfFluidInTank+resource.getFluid().getTemperature()*resource.amount)/(amountOfFluidInTank+resource.amount); + return averageT; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) + { + if (fluidList.isEmpty()) + { + return null; + } + FluidStack fstack = this.getFluid().copy(); + fstack.amount=maxDrain; + return this.drain(fstack, doDrain); + } + + + public FluidStack drainLightest(int maxDrain, boolean doDrain) + { + if (fluidList.isEmpty()) + { + return null; + } + FluidStack fstack = this.getLigthestFluid().copy(); + fstack.amount=maxDrain; + return this.drain(fstack, doDrain); + } + + public FluidStack drain(Object fluidStack, boolean doDrain) + { + if (fluidList.isEmpty()) + { + return null; + } + int drained = 0; + if(fluidStack instanceof FluidStack) + { + drained = ((FluidStack)fluidStack).amount; + } + else + { + drained = ((IRecipeInputFluid)fluidStack).getAmount(); + } + FluidStack fluid = this.getFluidStackWithSameFluid(fluidStack); + if (fluid==null) + { + return null; + } + if (fluid.amount < drained) + { + drained = fluid.amount; + } + FluidStack stack = copyWithSize(fluid,drained); + if (doDrain) + { + fluid.amount -= drained; + if (fluid.amount <= 0) + { + this.fluidList.remove(fluid); + fluid = null; + } + } + return stack; + } + + public FluidStack getFluidStackWithSameFluid(Object fluidStack) + { + Iterator fli = fluidList.iterator(); + while(fli.hasNext()) + { + FluidStack fluid=fli.next(); + if(fluid!=null) + { + if(fluidStack instanceof FluidStack) + { + if(fluid.isFluidEqual((FluidStack)fluidStack)) + { + return fluid; + } + } + else + { + if(((IRecipeInputFluid)fluidStack).matches(fluid)) + { + return fluid; + } + } + } + } + return null; + } + + public int getNumberOfFluids() + { + return this.fluidList.size(); + } + + public void setFluidAmount(int amount1, int index) + { + if(this.fluidList.size()<=index) + { + while(this.fluidList.size()<=index) + { + this.fluidList.add(new FluidStack(FluidRegistry.WATER,1)); + } + } + this.fluidList.get(index).amount=amount1; + } + + public int getFluidAmount(int index) + { + if(this.fluidList.size()<=index || this.fluidList.get(index)==null) + { + return 0; + } + return this.fluidList.get(index).amount; + } + + public int getFluidID(int i) + { + if(this.fluidList.get(i)==null) + { + return -1; + } + return this.fluidList.get(i).getFluid().getID(); + } + + public void sortFluidsByDensity() + { + Map sortMap = new HashMap(); + int[] keysArray = new int[fluidList.size()]; + Iterator fli = fluidList.iterator(); + while(fli.hasNext()) + { + FluidStack fluid=fli.next(); + if(fluid==null) + { + return; + } + int key = Math.round(IHLFluid.getRealDensity(fluid.getFluid())*100F); + while(sortMap.containsKey(key)) + { + key++; + } + sortMap.put(key, fluid); + keysArray[fluidList.indexOf(fluid)]=key; + } + Arrays.sort(keysArray); + ArrayList newFluidList = new ArrayList(); + for(int i=keysArray.length-1;i>=0;i--) + { + newFluidList.add(sortMap.get(keysArray[i])); + } + this.fluidList.clear(); + this.fluidList.addAll(newFluidList); + } + + public FluidStack getFluid(int i) + { + return this.fluidList.get(i); + } + + public void setTag(String string, int t1_1) + { + if(this.getFluid().tag==null) + { + this.getFluid().tag=new NBTTagCompound(); + } + this.getFluid().tag.setInteger(string, t1_1); + } + + public void setEmpty() + { + this.fluidList.clear(); + } + + public int getTemperature() + { + return this.temperature; + } + + public void setTemperature(int t1) + { + this.temperature=t1; + } + + public List getFluidList() + { + return this.fluidList; + } + + public void drain(List fluidInputs, boolean doDrain) + { + if(fluidInputs!=null && !fluidInputs.isEmpty()) + { + Iterator fsi = fluidInputs.iterator(); + while(fsi.hasNext()) + { + this.drain(fsi.next(), doDrain); + } + } + } + + public void fill(List fluidOutputs, boolean doFill) + { + if(fluidOutputs!=null && !fluidOutputs.isEmpty()) + { + Iterator fsi = fluidOutputs.iterator(); + while(fsi.hasNext()) + { + this.fill(fsi.next(), doFill); + } + } + } + + private FluidStack copyWithSize(FluidStack resource, int amount1) + { + FluidStack fluid = resource.copy(); + fluid.amount=amount1; + if(resource.tag!=null) + { + fluid.tag=(NBTTagCompound) resource.tag.copy(); + } + return fluid; + } + + public FluidStack drain(IRecipeInputFluid fluidStack, int amount, boolean doDrain) + { + if (fluidList.isEmpty()) + { + return null; + } + int drained = amount; + FluidStack fluid = this.getFluidStackWithSameFluid(fluidStack); + if (fluid==null) + { + return null; + } + if (fluid.amount < drained) + { + drained = fluid.amount; + } + FluidStack stack = copyWithSize(fluid,drained); + if (doDrain) + { + fluid.amount -= drained; + if (fluid.amount <= 0) + { + this.fluidList.remove(fluid); + fluid = null; + } + } + return stack; + } + + public void checkCorrectState() + { + if(!this.fluidList.isEmpty()) + { + Iterator fsi=this.fluidList.iterator(); + while(fsi.hasNext()) + { + FluidStack fs = fsi.next(); + if(fs.amount<=0) + { + fsi.remove(); + } + } + } + } +} diff --git a/ihl/utils/IHLInvSlotDischarge.java b/ihl/utils/IHLInvSlotDischarge.java new file mode 100644 index 0000000..4ebb488 --- /dev/null +++ b/ihl/utils/IHLInvSlotDischarge.java @@ -0,0 +1,83 @@ +package ihl.utils; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; + +public class IHLInvSlotDischarge extends InvSlot +{ + public int tier; + public boolean allowRedstoneDust; + + public IHLInvSlotDischarge(TileEntityInventory base, int oldStartIndex, InvSlot.Access access, int tier) + { + this(base, oldStartIndex, access, tier, InvSlot.InvSide.ANY); + } + + public IHLInvSlotDischarge(TileEntityInventory base, int oldStartIndex, InvSlot.Access access, int tier, InvSlot.InvSide preferredSide) + { + this(base, oldStartIndex, access, tier, true, preferredSide); + } + + public IHLInvSlotDischarge(TileEntityInventory base, int oldStartIndex, InvSlot.Access access, int tier, boolean allowRedstoneDust, InvSlot.InvSide preferredSide) + { + super(base, "discharge", oldStartIndex, access, 1, preferredSide); + this.allowRedstoneDust = true; + this.tier = tier; + this.allowRedstoneDust = allowRedstoneDust; + } + + @Override + public boolean accepts(ItemStack stack) + { + return stack == null ? false : (stack.getItem() == Items.redstone && !this.allowRedstoneDust ? false : Info.itemEnergy.getEnergyValue(stack) > 0.0D || ElectricItem.manager.discharge(stack, Double.POSITIVE_INFINITY, this.tier, true, true, true) > 0.0D); + } + + public double discharge(double amount, boolean ignoreLimit) + { + if (amount <= 0.0D) + { + throw new IllegalArgumentException("Amount must be > 0."); + } + else + { + ItemStack stack = this.get(0); + + if (stack == null) + { + return 0.0D; + } + else + { + double realAmount = ElectricItem.manager.discharge(stack, amount, this.tier, ignoreLimit, true, false); + + if (realAmount <= 0.0D) + { + realAmount = Info.itemEnergy.getEnergyValue(stack); + + if (realAmount <= 0.0D) + { + return 0.0D; + } + + --stack.stackSize; + + if (stack.stackSize <= 0) + { + this.put(0, (ItemStack)null); + } + } + + return realAmount; + } + } + } + + public void setTier(int tier1) + { + this.tier = tier1; + } +} \ No newline at end of file diff --git a/ihl/utils/IHLItemRenderer.java b/ihl/utils/IHLItemRenderer.java new file mode 100644 index 0000000..caed0a3 --- /dev/null +++ b/ihl/utils/IHLItemRenderer.java @@ -0,0 +1,294 @@ +package ihl.utils; + +import java.util.Random; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.client.IItemRenderer.ItemRenderType; + +public class IHLItemRenderer { + private Random random = new Random(); + private RenderBlocks renderBlocks = new RenderBlocks(); + private boolean noRotation=false; + + public IHLItemRenderer(){} + + public IHLItemRenderer(boolean b) + { + noRotation=b; + } + + public void doRender(RenderManager renderManager, ItemStack stack, double x, double y, double z) + { + if(stack!=null) + { + if(stack.getItem().isFull3D()) + { + ItemRenderType type = ItemRenderType.ENTITY; + IItemRenderer itemRenderer = MinecraftForgeClient.getItemRenderer(stack, type); + if(itemRenderer!=null) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x, (float)y-0.5F, (float)z); + GL11.glScalef(0.5F, 0.5F, 0.5F); + Object[] data={null,null}; + itemRenderer.renderItem(type, stack, data); + GL11.glPopMatrix(); + } + else + { + this.doRenderNative(renderManager, stack, x, y-0.1F, z); + } + } + else + { + this.doRenderNative(renderManager, stack, x, y-0.1F, z); + } + } + } + + public void doRenderNative(RenderManager renderManager, ItemStack var10, double par2, double par4, double par6) + { + float scale=0.8F; + if (var10.getItem() != null) + { + renderManager.renderEngine.bindTexture(renderManager.renderEngine.getResourceLocation(var10.getItemSpriteNumber())); + this.random.setSeed(187L); + GL11.glPushMatrix(); + byte var13 = 1; + + if (var10.stackSize > 1) + { + var13 = 2; + } + + if (var10.stackSize > 5) + { + var13 = 3; + } + + if (var10.stackSize > 20) + { + var13 = 4; + } + + if (var10.stackSize > 40) + { + var13 = 5; + } + + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float var19; + float var18; + int var24; + + if (var10.getItemSpriteNumber() == 0 && var10.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(var10.getItem()).getRenderType())) + { + Block var21 = Block.getBlockFromItem(var10.getItem()); + + float var25 = 0.25F*scale; + var24 = var21.getRenderType(); + + if (var24 == 1 || var24 == 19 || var24 == 12 || var24 == 2) + { + var25 = 0.5F*scale; + } + + if (var21.getRenderBlockPass() > 0) + { + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + + GL11.glScalef(var25, var25, var25); + + for (int var26 = 0; var26 < var13; ++var26) + { + GL11.glPushMatrix(); + + if (var26 > 0) + { + var18 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var25; + var19 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var25; + float var20 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var25; + GL11.glTranslatef(var18, var19, var20); + } + + this.renderBlocks.renderBlockAsItem(var21, var10.getItemDamage(), 1.0F); + GL11.glPopMatrix(); + } + + if (var21.getRenderBlockPass() > 0) + { + GL11.glDisable(GL11.GL_BLEND); + } + } + else + { + float var17; + + if (var10.getItemSpriteNumber() == 1 && var10.getItem().requiresMultipleRenderPasses()) + { + GL11.glScalef(0.5F*scale, 0.5F*scale, 0.5F*scale); + + for (int var23 = 0; var23 <= 1; ++var23) + { + this.random.setSeed(187L); + IIcon var22 = var10.getItem().getIconFromDamageForRenderPass(var10.getItemDamage(), var23); + var24 = var10.getItem().getColorFromItemStack(var10, var23); + var17 = (var24 >> 16 & 255) / 255.0F; + var18 = (var24 >> 8 & 255) / 255.0F; + var19 = (var24 & 255) / 255.0F; + GL11.glColor4f(var17, var18, var19, 1.0F); + this.renderDroppedItem(renderManager, var10, var22, var13, var17, var18, var19); + + } + } + else + { + if (var10 != null && var10.getItem() instanceof ItemCloth) + { + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + GL11.glScalef(0.5F*scale, 0.5F*scale, 0.5F*scale); + IIcon var14 = var10.getIconIndex(); + int var15 = var10.getItem().getColorFromItemStack(var10, 0); + float var16 = (var15 >> 16 & 255) / 255.0F; + var17 = (var15 >> 8 & 255) / 255.0F; + var18 = (var15 & 255) / 255.0F; + this.renderDroppedItem(renderManager, var10, var14, var13, var16, var17, var18); + if (var10 != null && var10.getItem() instanceof ItemCloth) + { + GL11.glDisable(GL11.GL_BLEND); + } + } + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + private void renderDroppedItem(RenderManager renderManager, ItemStack stack, IIcon par2Icon, int par3, float par5, float par6, float par7) + { + Tessellator var8 = Tessellator.instance; + + if (par2Icon == null) + { + TextureManager var9 = Minecraft.getMinecraft().getTextureManager(); + ResourceLocation var10 = var9.getResourceLocation(stack.getItemSpriteNumber()); + par2Icon = ((TextureMap)var9.getTexture(var10)).getAtlasSprite("missingno"); + } + + float var25 = par2Icon.getMinU(); + float var26 = par2Icon.getMaxU(); + float var11 = par2Icon.getMinV(); + float var12 = par2Icon.getMaxV(); + float var13 = 1.0F; + float var14 = 0.5F; + float var15 = 0.25F; + float var17; + + if (renderManager.options.fancyGraphics) + { + GL11.glPushMatrix(); + + //GL11.glRotatef((this.random .nextFloat() * 2.0F - 1.0F) * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + + float var16 = 0.0625F; + var17 = 0.021875F; + ItemStack var18 = stack; + int var19 = var18.stackSize; + byte var24; + + if (var19 < 2) + { + var24 = 1; + } + else if (var19 < 16) + { + var24 = 2; + } + else if (var19 < 32) + { + var24 = 3; + } + else + { + var24 = 4; + } + + GL11.glTranslatef(-var14, -var15, -((var16 + var17) * var24 / 2.0F)); + + for (int var20 = 0; var20 < var24; ++var20) + { + GL11.glTranslatef(0.0F, 0.0F, var16 + var17); + + if (var18.getItemSpriteNumber() == 0) + { + renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + } + else + { + renderManager.renderEngine.bindTexture(TextureMap.locationItemsTexture); + } + + GL11.glColor4f(par5, par6, par7, 1.0F); + ItemRenderer.renderItemIn2D(var8, var26, var11, var25, var12, par2Icon.getIconWidth(), par2Icon.getIconHeight(), var16); + } + + GL11.glPopMatrix(); + } + else + { + for (int var27 = 0; var27 < par3; ++var27) + { + GL11.glPushMatrix(); + + if (var27 > 0) + { + var17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float var29 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float var28 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + GL11.glTranslatef(var17, var29, var28); + } + if(!noRotation) + { + GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + } + GL11.glColor4f(par5, par6, par7, 1.0F); + var8.startDrawingQuads(); + var8.setNormal(0.0F, 1.0F, 0.0F); + var8.addVertexWithUV(0.0F - var14, 0.0F - var15, 0.0D, var25, var12); + var8.addVertexWithUV(var13 - var14, 0.0F - var15, 0.0D, var26, var12); + var8.addVertexWithUV(var13 - var14, 1.0F - var15, 0.0D, var26, var11); + var8.addVertexWithUV(0.0F - var14, 1.0F - var15, 0.0D, var25, var11); + var8.draw(); + GL11.glPopMatrix(); + } + } + } + +} diff --git a/ihl/utils/IHLMathUtils.java b/ihl/utils/IHLMathUtils.java new file mode 100644 index 0000000..cfd6931 --- /dev/null +++ b/ihl/utils/IHLMathUtils.java @@ -0,0 +1,48 @@ +package ihl.utils; + +public class IHLMathUtils +{ + private final static int accuracy_level=65536; + private static float[] sin_table=new float[accuracy_level]; + private static float[] atan_table=new float[accuracy_level]; + private final static float PI=(float)Math.PI; + + public static float sin(float angle) + { + float angle1 = angle % (2*PI); + if(angle1<0) + { + angle1+=2*PI; + } + return sin_table[(int)(angle1*accuracy_level/2/PI)]; + } + + public static float atan(float tan_value) + { + if(tan_value<-32f) + { + return -1.54f; + } + else if(tan_value>32f) + { + return 1.54f; + } + else + { + return atan_table[(int)((tan_value+32f)*accuracy_level/64f)]; + } + } + + + static + { + for(int i=0;i frameTooltipMap; + private int displayScaledWidth=-1; + private int displayScaledHeight=-1; + private int guiXPos=-1; + private int guiYPos=-1; + private int prevDisplayWidth=-1; + private int prevDisplayHeight=-1; + private final int guiContainerWidth = 166; + private final int guiContainerHeight = 176; + private float lastPlayerYaw; + private float lastPlayerPitch; + private double lastPlayerPosY; + private double lastPlayerPosZ; + private double lastPlayerPosX; + private double renderMinX=0d; + private double renderMaxX=1d; + private double renderMinY=0d; + private double renderMaxY=1d; + private double renderMinZ=0d; + private double renderMaxZ=1d; + public boolean renderFromInside=false; + private float rotationPointX; + private float rotationPointY; + private float rotationPointZ; + private double renderPositionX; + private double renderPositionY; + private double renderPositionZ; + private float rotationX; + private float rotationY; + private float rotationZ; + private float scale=1/16f; + public boolean swapXandZ=false; + public boolean swapXandY=false; + public boolean swapYandZ=false; + public boolean swapRenderBoundsX=false; + public boolean swapRenderBoundsY=false; + public boolean swapRenderBoundsZ=false; + public int scaleFactor=1; + public static IHLRenderUtils instance; + + public IHLRenderUtils() + { + instance=this; + colorBuffer = GLAllocation.createDirectFloatBuffer(16); + frameTooltipMap = new HashMap(); + } + + public void renderIHLFluidTank(IHLFluidTank fluidTank, int x1, int y1, int x2, int y2, float zLevel, int par1, int par2, int xOffset, int yOffset) + { + int liquidHeight = 0; + int prevLiquidHeight = 0; + int i = y2-y1; + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1f, 1f, 1f, 1f); + for(int i2 = 0;i2 fli = fluidTank.getFluidList(); + for(int i=fli.size()-1;i>=0;i--) + { + FluidStack fluidStack = fli.get(i); + fluidListNames+=StatCollector.translateToLocal(fluidStack.getUnlocalizedName())+": "+fluidStack.amount+"mB /n "; + } + drawTooltip(par1,par2,x2-x1,y2-y1,x1,y1,fluidListNames); + } + + public boolean drawTooltip(int cursorPosX, int cursorPosY, int width, int height, int xPos, int yPos, String text) + { + updateScreenSize(); + long key = xPos+yPos*1024; + Integer frame=0; + if(frameTooltipMap.containsKey(key)) + { + frame=frameTooltipMap.get(key); + } + boolean showString=true; + if(cursorPosXxPos+width|| + cursorPosYyPos+height) + { + if(frame>0) + { + frame-=20; + frameTooltipMap.put(key, frame); + } + showString=false; + } + else + { + frame+=10; + frameTooltipMap.put(key, frame); + } + if(frame>0) + { + int strokeHeight=15; + int i,x1,x2,y1,y2,tooltipWidth,tooltipHeight; + tooltipWidth=tooltipHeight=0; + String[] splittedText = text.split(" /n "); + for(i=0;itooltipWidth) + { + tooltipWidth=Math.min(frame,Minecraft.getMinecraft().fontRenderer.getStringWidth(splittedText[i])+8); + } + } + tooltipHeight=Math.min(Math.max(frame-tooltipWidth,strokeHeight),strokeHeight*splittedText.length); + x1=cursorPosX-xPos; + x2=x1+tooltipWidth; + y1=cursorPosY-guiYPos+18; + y2=y1+tooltipHeight; + GL11.glPushAttrib(16704); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + if(showString) + { + drawRectangle(Tessellator.instance, x1,y1,x2,y2,128); + GL11.glEnable(GL11.GL_TEXTURE_2D); + for(i=0;i>> 24 & 255, color >>> 16 & 255, color >>> 8 & 255, color & 255); + tessellator.addVertex(x2, y1, 300.0D); + tessellator.addVertex(x1, y1, 300.0D); + tessellator.addVertex(x1, y2, 300.0D); + tessellator.addVertex(x2, y2, 300.0D); + tessellator.draw(); + } + + public void drawThermometerTemperature(long temperature, boolean show) + { + updateScreenSize(); + long key = 0; + int frame=0; + if(frameTooltipMap.containsKey(key)) + { + frame=frameTooltipMap.get(key); + } + if(frame<=0) + { + updatePlayerView(); + } + boolean showString=true; + if(show && frame<=122) + { + frame+=1; + frameTooltipMap.put(key, frame); + } + else + { + if(frame>0) + { + frame-=2; + frameTooltipMap.put(key, frame); + } + showString=false; + } + if(frame>0) + { + int width=Math.min(frame, 122); + int height=Math.min(frame, 48); + int xShift = Math.round(displayScaledWidth/100*(lastPlayerYaw - Minecraft.getMinecraft().renderViewEntity.prevRotationYaw)); + int yShift = Math.round(displayScaledHeight/64*(lastPlayerPitch - Minecraft.getMinecraft().renderViewEntity.prevRotationPitch)); + int xPos = displayScaledWidth/2+xShift; + int yPos = displayScaledHeight/2-48+yShift; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + drawTexturedModalRect(xPos,yPos,0,0,width,height); + GL11.glDisable(GL11.GL_DEPTH_TEST); + if(showString) + { + Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(temperature+"\u00B0K", xPos+35, yPos+3, 16768125); + } + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_BLEND); + } + } + + public void drawTexturedModalRect(int x1, int y1, int u, int v, int x2, int y2) { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(1f, 1f, 1f, 0.5f); + tessellator.addVertexWithUV(x1 + 0, y1 + y2, 300D, (u + 0) * f, (v + y2) * f1); + tessellator.addVertexWithUV(x1 + x2, y1 + y2, 300D, (u + x2) * f, (v + y2) * f1); + tessellator.addVertexWithUV(x1 + x2, y1 + 0, 300D, (u + x2) * f, (v + 0) * f1); + tessellator.addVertexWithUV(x1 + 0, y1 + 0, 300D, (u + 0) * f, (v + 0) * f1); + tessellator.draw(); + } + + + public void updateScreenSize() + { + if(prevDisplayHeight!=Minecraft.getMinecraft().displayHeight || prevDisplayWidth!=Minecraft.getMinecraft().displayWidth) + { + ScaledResolution var2 = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); + displayScaledWidth = var2.getScaledWidth(); + displayScaledHeight = var2.getScaledHeight(); + scaleFactor=var2.getScaleFactor(); + guiXPos = (displayScaledWidth - guiContainerWidth)/2; + guiYPos = (displayScaledHeight - guiContainerHeight)/2; + prevDisplayWidth=Minecraft.getMinecraft().displayWidth; + prevDisplayHeight=Minecraft.getMinecraft().displayHeight; + } + } + + public void updatePlayerView() + { + lastPlayerYaw = Minecraft.getMinecraft().renderViewEntity.prevRotationYaw; + lastPlayerPitch = Minecraft.getMinecraft().renderViewEntity.prevRotationPitch; + lastPlayerPosX = Minecraft.getMinecraft().renderViewEntity.prevPosX; + lastPlayerPosY = Minecraft.getMinecraft().renderViewEntity.prevPosY; + lastPlayerPosZ = Minecraft.getMinecraft().renderViewEntity.prevPosZ; + } + + public void drawKnee(double xPos, double yPos, double zPos, ForgeDirection direction12, ForgeDirection direction22, double radius1, double radius2, IIcon icon) + { + ForgeDirection direction1=direction12; + ForgeDirection direction2=direction22; + if(this.swapRenderBoundsX) + { + if(direction1.offsetX!=0) + { + direction1=direction1.getOpposite(); + } + if(direction2.offsetX!=0) + { + direction2=direction2.getOpposite(); + } + } + if(this.swapRenderBoundsY) + { + if(direction1.offsetY!=0) + { + direction1=direction1.getOpposite(); + } + if(direction2.offsetY!=0) + { + direction2=direction2.getOpposite(); + } + } + if(this.swapRenderBoundsZ) + { + if(direction1.offsetZ!=0) + { + direction1=direction1.getOpposite(); + } + if(direction2.offsetZ!=0) + { + direction2=direction2.getOpposite(); + } + } + double[][] outervertexes1 = new double[8][3]; + double[][] innervertexes1 = new double[8][3]; + double[][] outervertexes2 = new double[8][3]; + double[][] innervertexes2 = new double[8][3]; + int i=0; + for(i=0;i<8;i++) + { + if(direction1.equals(direction2)) + { + switch(direction1) + { + case UP: + outervertexes1[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + case DOWN: + outervertexes1[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i)}; + outervertexes2[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + case SOUTH: + outervertexes1[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + innervertexes1[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0d}; + innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0d}; + break; + case NORTH: + outervertexes1[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + innervertexes1[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + outervertexes2[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i), 0d}; + innervertexes2[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0d}; + break; + case EAST: + outervertexes1[i] = new double[] {0d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i)}; + outervertexes2[i] = new double[] {1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {1d, 0.5F+0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i)}; + break; + case WEST: + outervertexes1[i] = new double[] {0d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i)}; + outervertexes2[i] = new double[] {1d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {1d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i)}; + break; + default: + outervertexes1[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + } + + } + else + { + switch(direction1) + { + case UP: + outervertexes1[i] = new double[] {0.5F+0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i+Math.PI), 1d, 0.5F-0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i+Math.PI)}; + innervertexes1[i] = new double[] {0.5F+radius1*radius2*0.25F*(float)Math.cos(2D*Math.PI/8D*i+Math.PI), 1d, 0.5F-0.25F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i+Math.PI)}; + break; + case DOWN: + outervertexes1[i] = new double[] {0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + case SOUTH: + outervertexes1[i] = new double[] {0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + innervertexes1[i] = new double[] {0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + break; + case NORTH: + outervertexes1[i] = new double[] {0.5F+0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + innervertexes1[i] = new double[] {0.5F+radius1*radius2*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + break; + case EAST: + outervertexes1[i] = new double[] {0d, 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i)}; + break; + case WEST: + outervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.52F*radius2*(float)Math.cos(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i)}; + break; + default: + outervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.52F*radius2*(float)Math.cos(2D*Math.PI/8D*i)}; + innervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i)}; + break; + } + + switch(direction2) + { + case UP: + outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + case DOWN: + outervertexes2[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + case WEST: + outervertexes2[i] = new double[] {1d, 0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F-0.25F*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {1d, 0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F-0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + case EAST: + outervertexes2[i] = new double[] {0d, 0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {0d, 0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + case NORTH: + outervertexes2[i] = new double[] {0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 1d-0.5F-0.25F*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + innervertexes2[i] = new double[] {0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 1d-0.5F-0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 1d}; + break; + case SOUTH: + outervertexes2[i] = new double[] {0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i), 0d}; + innervertexes2[i] = new double[] {0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0d}; + break; + default: + outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)}; + innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i)}; + break; + } + + } + } + double[][][] quadList = new double[32][4][3]; + for(i=0;i<32;i++) + { + if(i<7) + { + quadList[i]=new double[][] {outervertexes1[i],outervertexes1[i+1],innervertexes1[i+1],innervertexes1[i]}; + } + else if(i==7) + { + quadList[i]=new double[][] {outervertexes1[i],outervertexes1[0],innervertexes1[0],innervertexes1[i]}; + } + else if(i<15) + { + quadList[i]=new double[][] {innervertexes2[i-8],innervertexes2[i+1-8],outervertexes2[i+1-8],outervertexes2[i-8]}; + } + else if(i==15) + { + quadList[i]=new double[][] {innervertexes2[i-8],innervertexes2[0],outervertexes2[0],outervertexes2[i-8]}; + } + else if(i<23) + { + quadList[i]=new double[][] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[i-16+1],outervertexes1[i-16+1]}; + } + else if(i==23) + { + quadList[i]=new double[][] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[0],outervertexes1[0]}; + } + else if(i<31) + { + quadList[i]=new double[][] {innervertexes1[i-24+1],innervertexes2[i-24+1], innervertexes2[i-24], innervertexes1[i-24]}; + } + else if(i==31) + { + quadList[i]=new double[][] {innervertexes1[0],innervertexes2[0],innervertexes2[i-24],innervertexes1[i-24]}; + } + } + for(i=0;i<32;i++) + { + this.drawSquare(xPos, yPos, zPos, quadList[i], icon); + } + + + } + public void drawPipe(double xPos, double yPos, double zPos, ForgeDirection direction1, double radius1, double radius2, IIcon icon) + { + this.drawKnee(xPos, yPos, zPos, direction1, direction1, radius1, radius2, icon); + } + + public void drawSquare(double xPos, double yPos, double zPos, double[][] vertexes, IIcon icon) + { + Tessellator var9 = Tessellator.instance; + double u1 = icon.getInterpolatedU(this.renderMinZ * 16.0D); + double u2 = icon.getInterpolatedU(this.renderMaxZ * 16.0D); + double v2 = icon.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double v1 = icon.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + if (this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) + { + u1 = icon.getMinU(); + u2 = icon.getMaxU(); + } + if (this.renderMinY < 0.0D || this.renderMaxY > 1.0D) + { + v2 = icon.getMinV(); + v1 = icon.getMaxV(); + } + double[] us = new double[]{u1,u1,u2,u2}; + double[] vs = new double[]{v1,v2,v2,v1}; + double xDelta=this.renderMaxX-this.renderMinX; + double yDelta=this.renderMaxY-this.renderMinY; + double zDelta=this.renderMaxZ-this.renderMinZ; + int startFrom=0; + int endTo=3; + if(this.renderFromInside) + { + startFrom=3; + endTo=0; + } + for(int i=startFrom;(i<=endTo&&!this.renderFromInside)||(i>=endTo&&this.renderFromInside);i+=(endTo-startFrom)/3) + { + double vX=vertexes[i][0]*xDelta+this.renderMinX; + double vY=vertexes[i][1]*yDelta+this.renderMinY; + double vZ=vertexes[i][2]*zDelta+this.renderMinZ; + double[] vYZ=null; + double[] vXZ=null; + double[] vXY=null; + if(this.rotationX!=0) + { + vYZ = this.rotateCoordinateByAngle(vY-(this.rotationPointY-8f)*scale, vZ-(this.rotationPointZ+8f)*scale, this.rotationX); + vY=vYZ[0]+(this.rotationPointY-8f)*scale; + vZ=vYZ[1]+(this.rotationPointZ+8f)*scale; + } + if(this.rotationY!=0) + { + vXZ = this.rotateCoordinateByAngle(vX-(this.rotationPointX+8f)*scale, vZ-(this.rotationPointZ+8f)*scale, this.rotationY); + vX=vXZ[0]+(this.rotationPointX+8f)*scale; + vZ=vXZ[1]-(this.rotationPointZ+8f)*scale; + } + if(this.rotationZ!=0) + { + vXY = this.rotateCoordinateByAngle(vX-(this.rotationPointX+8f)*scale, vY-(this.rotationPointY-8f)*scale, this.rotationZ); + vX=vXY[0]+(this.rotationPointX+8f)*scale; + vY=vXY[1]+(this.rotationPointY-8f)*scale; + if(swappingAxisOrBoundsAffectRotationOnAxisZ()) + { + vY-=(this.renderMaxZ-(this.rotationPointZ+8f))*scale*Math.sin(this.rotationZ); + } + } + if(this.swapXandY) + { + double var0 = vX; + vX=vY; + vY=var0; + } + if(this.swapXandZ) + { + double var0 = vX; + vX=vZ; + vZ=var0; + } + if(this.swapYandZ) + { + double var0 = vY; + vY=vZ; + vZ=var0; + } + var9.addVertexWithUV(xPos+vX, yPos+vY, zPos+vZ, us[i], vs[i]); + } + } + + public void setRenderBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) + { + if(this.swapRenderBoundsX) + { + this.renderMinX = 1-maxX; + this.renderMaxX = 1-minX; + } + else + { + this.renderMinX = minX; + this.renderMaxX = maxX; + } + if(this.swapRenderBoundsY) + { + this.renderMinY = 1-maxY; + this.renderMaxY = 1-minY; + } + else + { + this.renderMinY = minY; + this.renderMaxY = maxY; + } + if(this.swapRenderBoundsZ) + { + this.renderMinZ = 1-maxZ; + this.renderMaxZ = 1-minZ; + } + else + { + this.renderMinZ = minZ; + this.renderMaxZ = maxZ; + } + } + + public void setRotationPoint(float rX, float rY, float rZ) + { + this.rotationPointX=rX; + this.rotationPointY=rY; + this.rotationPointZ=rZ; + } + + public void setPosition(double xPos, double yPos, double zPos) + { + this.renderPositionX=xPos; + this.renderPositionY=yPos; + this.renderPositionZ=zPos; + } + + public void drawPipe(float fx,float fy,float fz, int xSize,int ySize,int zSize, float radius1, float radius2, ForgeDirection direction, IIcon icon) + { + this.setRenderBoundsFromModel(fx, fy, fz, xSize, ySize, zSize); + this.drawPipe(renderPositionX,renderPositionY, renderPositionZ, direction, radius1, radius2, icon); + } + + public void drawKnee(float fx,float fy,float fz, int xSize,int ySize,int zSize, float radius1, float radius2, ForgeDirection direction1, ForgeDirection direction2, IIcon icon) + { + this.setRenderBoundsFromModel(fx, fy, fz, xSize, ySize, zSize); + this.drawKnee(renderPositionX,renderPositionY, renderPositionZ, direction1, direction2, radius1, radius2, icon); + } + + public void drawBox(float fx,float fy,float fz, int xSize,int ySize,int zSize, Block block, int meta, RenderBlocks blockRenderer) + { + this.setRenderBoundsFromModel(fx, fy, fz, xSize, ySize, zSize); + blockRenderer.renderStandardBlock(block, (int)this.renderPositionX, (int)this.renderPositionY, (int)this.renderPositionZ); + } + + public void setRenderBoundsFromModel(float fx,float fy,float fz, int xSize,int ySize,int zSize) + { + float boundMinX=(-this.rotationPointX+8f-fx-xSize)*scale; + float boundMaxX=(-this.rotationPointX+8f-fx)*scale; + float boundMinZ=(-this.rotationPointZ+8f-fz-zSize)*scale; + float boundMaxZ=(-this.rotationPointZ+8f-fz)*scale; + float boundMinY=(this.rotationPointY-8f-fy-ySize)*scale; + float boundMaxY=(this.rotationPointY-8f-fy)*scale; + this.setRenderBounds(boundMinX, boundMinY, boundMinZ, boundMaxX, boundMaxY, boundMaxZ); + } + + public double[] rotateCoordinateByAngle(double coord1, double coord2, double angle) + { + double r = Math.sqrt(coord2*coord2+coord1*coord1); + double alpha0=Math.asin(coord2/r); + if(coord1<0d) + { + alpha0=Math.PI-Math.asin(coord2/r); + } + double alpha2=alpha0+angle; + double coord21=Math.sin(alpha2)*r; + double coord11=Math.cos(alpha2)*r; + return new double[]{coord11,coord21}; + } + + public void setRotation(float rotationX1, float rotationY1, float rotationZ1) + { + if(this.swapRenderBoundsX) + { + this.rotationX=-rotationX1; + } + else + { + this.rotationX=rotationX1; + } + if(this.swapRenderBoundsY) + { + this.rotationY=-rotationY1; + } + else + { + this.rotationY=rotationY1; + } + if(swappingAxisOrBoundsAffectRotationOnAxisZ()) + { + this.rotationZ=-rotationZ1; + } + else + { + this.rotationZ=rotationZ1; + } +// this.rotationX=rotationX1; + // this.rotationY=rotationY1; + //this.rotationZ=rotationZ1; + } + + public void reset() + { + this.renderFromInside=false; + this.swapXandZ=false; + this.swapXandY=false; + this.swapYandZ=false; + this.swapRenderBoundsX=false; + this.swapRenderBoundsY=false; + this.swapRenderBoundsZ=false; + this.setRotation(0f, 0f, 0f); + this.setRotationPoint(0f, 0f, 0f); + } + + private boolean swappingAxisOrBoundsAffectRotationOnAxisZ() + { + return (this.swapRenderBoundsZ && !this.swapXandZ && !this.swapYandZ)|| + (this.swapRenderBoundsX && this.swapXandZ) || + (this.swapRenderBoundsY && this.swapYandZ); + } + + public List splitStringByWidth(String string, int stringWidth) + { + List output = new ArrayList(); + StringBuffer sb = new StringBuffer(); + String[] splittedBySpaces = string.split(" "); + int arrayIndex=0; + for(String word:splittedBySpaces) + { + if(!word.contains("/n") && getStringWidth(sb)+getStringWidth(word) 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) + { + ItemStack ore = OreDictionary.getOres(name).get(0); + if(ore==null)return null; + ItemStack orecopy = ore.copy(); + orecopy.stackSize=1; + return orecopy; + } + + public static boolean hasOreDictionaryEntry(String name) + { + return !OreDictionary.getOres(name).isEmpty(); + } + + public static Item getOreDictItem(String name) + { + return OreDictionary.getOres(name).get(0).getItem(); + } + + public static Block getOreDictBlock(String name) + { + return Block.getBlockFromItem(OreDictionary.getOres(name).get(0).getItem()); + } + + public static ItemStack getOreDictItemStackWithSize(String name, int size) + { + ItemStack ore = OreDictionary.getOres(name).get(0); + if(ore==null)return null; + ItemStack orecopy = ore.copy(); + orecopy.stackSize=size; + return orecopy; + } + + public static String getFirstOreDictName(ItemStack stack) + { + int[] arrayIDs = OreDictionary.getOreIDs(stack); + if(arrayIDs.length>0) + { + return OreDictionary.getOreName(arrayIDs[0]); + } + return ""; + } + + public static ItemStack getThisModItemStack(String name) + { + if(ihlItemStackRegistry.get(name)!=null) + { + return ihlItemStackRegistry.get(name).copy(); + } + 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 + { + return new ItemStack(GameRegistry.findBlock("ihl", name)); + } + } + + public static ItemStack getThisModItemStackWithSize(String name, int i) { + if(ihlItemStackRegistry.get(name)!=null) + { + ItemStack stack = ihlItemStackRegistry.get(name).copy(); + 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); + } + } + + public static ItemStack getOtherModItemStackWithDamage(String modname, String name,int damage) { + if(GameRegistry.findItem(modname, name)!=null) + { + return new ItemStack(GameRegistry.findItem(modname, name),1,damage); + } + else if(GameRegistry.findBlock(modname, name)==null) + { + return null; + } + else + { + return new ItemStack(GameRegistry.findBlock(modname, name),1,damage); + } + } + + 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 + { + return Item.getItemFromBlock(GameRegistry.findBlock("ihl", name)); + } + } + + public static FluidStack getFluidStackWithSize(String name, int i) { + if(FluidRegistry.isFluidRegistered(name)) + { + return FluidRegistry.getFluidStack(name, i); + } + 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 + { + return GameRegistry.findBlock("ihl", name); + } + } + + 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) + { + int length = getWireLength(stack); + 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) + { + return true; + } + return false; + } + } + + 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) + { + ItemStack stack = getThisModItemStack(name); + 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); + return stack; + } + else + { + throw new IllegalArgumentException("ihl:"+name + " is not an instance of IWire."); + } + } + 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) + { + stack.stackTagCompound = new NBTTagCompound(); + stack.stackTagCompound.setInteger(((IWire)stack.getItem()).getTag(),i); + stack.stackTagCompound.setInteger(((IWire)stack.getItem()).getTagSecondary(),i); + return stack; + } + else + { + throw new IllegalArgumentException(stack1.getUnlocalizedName() + " is not an instance of IWire."); + } + } + + 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 getEntryListForOre(String name) + { + ArrayList outputList = new ArrayList(); + ArrayList oreList = OreDictionary.getOres(name); + Iterator oreListIterator = oreList.iterator(); + while(oreListIterator.hasNext()) + { + outputList.add(oreListIterator.next().copy()); + } + return outputList; + } + + public static ItemStack getItemStackIfExist(String name) + { + if(hasOreDictionaryEntry(name)) + { + return getOreDictItemStack(name); + } + else + { + if(ihlItemStackRegistry.get(name)!=null) + { + return ihlItemStackRegistry.get(name).copy(); + } + if(GameRegistry.findItem("ihl", name)!=null) + { + return new ItemStack(GameRegistry.findItem("ihl", name)); + } + else if(GameRegistry.findBlock("ihl", name)==null) + { + return null; + } + else + { + return new ItemStack(GameRegistry.findBlock("ihl", name)); + } + } + } + + 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; + return true; + } + } + return false; + } + + public static FluidStack getFluidStackWithSizeChemicallyPure(String name, int amount) + { + FluidStack fstack = getFluidStackWithSize(name, amount); + fstack.tag=new NBTTagCompound(); + fstack.tag.setBoolean("chemicallyPure", true); + return fstack; + } + + public static void removeItemStackFromOreDictionaryEntry(String orename, ItemStack itemStack) + { + ArrayList orelist = OreDictionary.getOres(orename); + Iterator oreListIterator = orelist.iterator(); + ItemStack odstack = null; + while(oreListIterator.hasNext()) + { + odstack = oreListIterator.next(); + if(odstack.getItem()==itemStack.getItem()) + { + break; + } + else + { + odstack = null; + } + } + if(odstack != null) + { + orelist.remove(odstack); + 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, 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) + { + 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."); + } + } + + 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."); + } + } + + 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."); + } + } + + 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."); + } + } + + public static void damageItemViaNBTTag(ItemStack stack, int amount) + { + NBTTagCompound gtTagCompound; + if(stack.stackTagCompound.hasKey("GT.ToolStats")) + { + gtTagCompound = stack.stackTagCompound.getCompoundTag("GT.ToolStats"); + } + else + { + stack.stackSize--; + return; + } + int damage = 0; + int maxDamage = 0; + if(gtTagCompound.hasKey("MaxDamage")) + { + maxDamage = gtTagCompound.getInteger("MaxDamage"); + } + else + { + stack.stackSize--; + return; + } + + if(gtTagCompound.hasKey("Damage")) + { + damage = gtTagCompound.getInteger("Damage"); + } + if(damage=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 String getFirstOreDictNameExcludingTagAny(ItemStack stack) { + int[] arrayIDs = OreDictionary.getOreIDs(stack); + for(int i=0;i0 && (output.getValue() == null || emptyFluidItemsSlot.canAdd((ItemStack)output.getValue()))) + { + fluidTank.fill(drainInputSlot.drain(null, fluidTank.getCapacity()-fluidTank.getFluidAmount(), output, false),true); + if(output.getValue()!=null) + { + emptyFluidItemsSlot.add((ItemStack)output.getValue()); + } + } + } + if (fillInputSlot!=null && !fillInputSlot.isEmpty()) + { + output = new MutableObject(); + if (fillInputSlot.transferFromTank(fluidTank, output, true) && (output.getValue() == null || emptyFluidItemsSlot.canAdd((ItemStack)output.getValue()))) + { + fillInputSlot.transferFromTank(fluidTank, output, false); + if(output.getValue()!=null) + { + emptyFluidItemsSlot.add((ItemStack)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) + { + 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; + 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 3; + } + + 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(); + List output = new ArrayList(); + while(irii.hasNext()) + { + IRecipeInput iri = irii.next(); + ItemStack stack = iri.getInputs().get(0); + stack.stackSize=iri.getAmount(); + output.add(stack); + } + return output; + } + + public static List convertRecipeInputToFluidStackList(List input) { + Iterator irii=input.iterator(); + List output = new ArrayList(); + while(irii.hasNext()) + { + IRecipeInputFluid iri = irii.next(); + FluidStack stack = iri.getInputs().get(0); + 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; + } + else if(variable<0) + { + return variable+1; + } + else + { + return variable-1; + } + } + + public static long getXYZHash(int x,int y,int z) + { + return ((x&0x1FFFFF)<<42)|((y&0x1FFFFF)<<21)|(z&0x1FFFFF); + } + + 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 getWireLength(is); + } + else + { + return is.stackSize; + } + } + + public static ItemStack getWireItemStackCopyWithLengthMultiplied(ItemStack stack, int multiplier) + { + ItemStack out = stack.copy(); + 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.setBoolean("firstConnection", false); + 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) { + ItemStack is = getUninsulatedWire(material, length, transverseSection); + 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) + { + String material = cable.getString("material"); + int transverseSection = cable.getInteger("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 ItemStack getItemStackWithTag(String unLocalizedName, String tag, int tagValue) { + ItemStack stack = IHLUtils.getThisModItemStack(unLocalizedName); + 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)) + { + 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 !(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 cableList = te.getCableList(); + Iterator cli = cableList.iterator(); + while(cli.hasNext()) + { + NBTTagCompound c = cli.next(); + cli.remove(); + IHLMod.enet.removeCableEntities(c); + ItemStack is = IHLUtils.getThisModItemStack("copperWire"); + 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); + } + 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 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)) + { + 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); + } + + public static float parseFloatSafe(String string, float useSafeValue) + { + if (Pattern.matches(fpRegex, string)) + return Float.valueOf(string); + else { + return useSafeValue; + } + + } +} diff --git a/ihl/utils/IHLXMLParser.java b/ihl/utils/IHLXMLParser.java new file mode 100644 index 0000000..67d246b --- /dev/null +++ b/ihl/utils/IHLXMLParser.java @@ -0,0 +1,141 @@ +package ihl.utils; + +import ihl.IHLMod; +import ihl.guidebook.IHLGuidebookGui; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.io.OutputStreamWriter; +import java.net.URL; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.*; +import org.xml.sax.SAXException; + +import com.google.common.io.Files; + + +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")))); + } + 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); + } + + private File getGuidebookFile() throws IOException + { + File folder = new File(IHLMod.proxy.getMinecraftDir(), "config"); + folder.mkdirs(); + File file = new File(folder, "ihl-guidebook.xml"); + if(!file.exists()) + { + InputStream in = IHLMod.class.getResourceAsStream("/assets/ihl/config/ihl-guidebook.xml"); + InputStreamReader isReader = new InputStreamReader(in, "UTF-8"); + LineNumberReader reader = new LineNumberReader(isReader); + OutputStreamWriter osWriter = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); + BufferedWriter writer = new BufferedWriter(osWriter); + String line; + while ((line = reader.readLine()) != null) + { + writer.append(line); + writer.newLine(); + } + writer.close(); + osWriter.close(); + in = IHLMod.class.getResourceAsStream("/assets/ihl/config/adress.xsd"); + isReader = new InputStreamReader(in, "UTF-8"); + reader = new LineNumberReader(isReader); + file = new File(folder, "adress.xsd"); + osWriter = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); + writer = new BufferedWriter(osWriter); + while ((line = reader.readLine()) != null) + { + writer.append(line); + writer.newLine(); + } + writer.close(); + osWriter.close(); + } + return file; + } + +} diff --git a/ihl/utils/PlayerWakeUpEventHandler.java b/ihl/utils/PlayerWakeUpEventHandler.java new file mode 100644 index 0000000..5b6751f --- /dev/null +++ b/ihl/utils/PlayerWakeUpEventHandler.java @@ -0,0 +1,17 @@ +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/utils/WorldSavedDataBlastWave.java b/ihl/utils/WorldSavedDataBlastWave.java new file mode 100644 index 0000000..06e1b41 --- /dev/null +++ b/ihl/utils/WorldSavedDataBlastWave.java @@ -0,0 +1,92 @@ +package ihl.utils; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.WorldSavedData; + +public class WorldSavedDataBlastWave extends WorldSavedData { + Map data = new HashMap(256); + public static long memoryUsage=0L; + + public WorldSavedDataBlastWave(String name) + { + super(name); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + if(nbt.hasKey("entryList")) + { + NBTTagList entryList=nbt.getTagList("entryList", 10); + for(int i=0;i> dataESI = data.entrySet().iterator(); + while(dataESI.hasNext()) + { + Entry dataEntry = dataESI.next(); + Long[][] bwArray = dataEntry.getValue(); + NBTTagCompound chunk = new NBTTagCompound(); + NBTTagList blastWaveList = new NBTTagList(); + for(int i1=0;i1<16;i1++) + { + NBTTagCompound blastWave = new NBTTagCompound(); + blastWave.setLong("longNumber", bwArray[i1][0]); + blastWave.setInteger("sourceX", bwArray[i1][1].intValue()); + blastWave.setInteger("sourceY", bwArray[i1][2].intValue()); + blastWave.setInteger("sourceZ", bwArray[i1][3].intValue()); + blastWave.setInteger("power", bwArray[i1][4].intValue()); + blastWaveList.appendTag(blastWave); + } + chunk.setTag("blastWaveList", blastWaveList); + chunk.setLong("chunkHash", dataEntry.getKey()); + entryList.appendTag(chunk); + } + nbt.setTag("entryList", entryList); + } + + public void scheduleExplosionEffectsOnChunkLoad(long chunkXZKey, long longNumber, int sourceX, int sourceY, int sourceZ, int power1, int absEBSY) + { + Long[][] waves; + if(data.containsKey(chunkXZKey)) + { + waves=data.get(chunkXZKey); + } + else + { + waves=new Long[16][5]; + data.put(chunkXZKey, waves); + } + waves[absEBSY][0]=longNumber; + waves[absEBSY][1]=(long)sourceX; + waves[absEBSY][2]=(long)sourceY; + waves[absEBSY][3]=(long)sourceZ; + waves[absEBSY][4]=(long)power1; + } +} diff --git a/ihl/worldgen/IHLWorldGenerator.java b/ihl/worldgen/IHLWorldGenerator.java new file mode 100644 index 0000000..71478b3 --- /dev/null +++ b/ihl/worldgen/IHLWorldGenerator.java @@ -0,0 +1,255 @@ +package ihl.worldgen; + +import ihl.IHLMod; +import ihl.utils.IHLUtils; +import ihl.worldgen.ores.IHLFluid; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.IChunkProvider; +import cpw.mods.fml.common.IWorldGenerator; + +public class IHLWorldGenerator implements IWorldGenerator { + + private WorldGenMinableMeta + apatiteGenerator, + saltpeterGenerator, + limestoneGenerator, + gypsumGenerator, + potassiumFeldsparGenerator, + tronaGenerator, + gyubneraGenerator, + rocksaltGenerator, + cinnabarGenerator, + bauxiteGenerator, + chromiteGenerator, + muscoviteGenerator, + oilGenerator, + datoliteGenerator, + saltwaterGenerator, + bischofiteGenerator; + private WorldGenMinableMeta currentGenerator; + protected final Map> oreCoordinatesToChunkCoordinates = new HashMap(); + protected final Map blockToOreCoordinates = new HashMap(); + public final Set precalculatedChunkChache = new HashSet(); + public static IHLWorldGenerator instance; + + + public IHLWorldGenerator() + { + super(); + apatiteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates, IHLUtils.getOreDictBlock("oreApatite"), 0, 360, new Block[] {Blocks.stone,Blocks.gravel}); + saltpeterGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreSaltpeter"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); + limestoneGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreLimestone"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); + gypsumGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreGypsum"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); + potassiumFeldsparGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("orePotassiumFeldspar"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); + tronaGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreTrona"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); + gyubneraGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreGyubnera"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); + rocksaltGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreRockSalt"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); + cinnabarGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreCinnabar"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); + bauxiteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreBauxite"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); + chromiteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreChromite"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); + muscoviteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreMica"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); + oilGenerator = new WorldGenLiquidOre(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLFluid.getBlock("oil"),Blocks.clay, 0, 32, 0, 8, new Block[] {Blocks.lava,Blocks.clay}); + datoliteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreDatolite"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); + saltwaterGenerator = new WorldGenLiquidOre(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLFluid.getBlock("saltwater"),Blocks.sandstone, 0, 32, 62, 62, new Block[] {Blocks.sand,Blocks.sandstone}); + bischofiteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreBischofite"), 0, 1400, new Block[] {Blocks.stone,Blocks.gravel}); + instance=this; + } + + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + { + int x1 = 0,y1 = 0,z1 = 0; + for(int ix=-16+chunkX;ix<=16+chunkX;ix++) + { + for(int iz=-16+chunkZ;iz<=16+chunkZ;iz++) + { + long chunkKey = (ix<<16)+iz; + if(!this.precalculatedChunkChache.contains(chunkKey)) + { + if(!world.getChunkProvider().chunkExists(ix, iz) || (ix==chunkX && iz==chunkZ)) + { + currentGenerator = switchCurrentOreGenerator(world, random, ix, iz); + if(currentGenerator!=null) + { + if(currentGenerator.generateNewVein(random, ix, iz)) + { + + } + } + } + this.precalculatedChunkChache.add(chunkKey); + } + } + } + long chunkKey = (chunkX<<16)+chunkZ; + if(this.precalculatedChunkChache.contains(chunkKey)) + { + Set oreCoordinatesSet = this.oreCoordinatesToChunkCoordinates.get(chunkKey); + if(oreCoordinatesSet!=null) + { + Object[] oreCoordinatesSetA = oreCoordinatesSet.toArray(); + for(int i=0;i 1.9f && biome.rainfall==0f) + { + return saltwaterGenerator; + } + } + break; + case 14: + if (IHLMod.config.generateDatolite) + { + if (random.nextFloat() < 0.25F) + { + return datoliteGenerator; + } + } + break; + case 15: + if (IHLMod.config.generateBischofite) + { + if (random.nextFloat() < 0.25F) + { + return bischofiteGenerator; + } + } + } + return null; + } +} diff --git a/ihl/worldgen/WorldGenLiquidOre.java b/ihl/worldgen/WorldGenLiquidOre.java new file mode 100644 index 0000000..f59fb2e --- /dev/null +++ b/ihl/worldgen/WorldGenLiquidOre.java @@ -0,0 +1,86 @@ +package ihl.worldgen; + +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenLiquidOre extends WorldGenMinableMeta { + + public WorldGenLiquidOre(Set precalculatedChunkChache1,Map blockToOreCoordinates, Map> oreCoordinatesToChunkCoordinates, Block block, Block liquidBedBlock1, int meta, int numberOfBlocks1, int veinMinHeightLimit1, int veinMaxHeightLimit1, Block... replacedBlock1) + { + super(precalculatedChunkChache1,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,block, liquidBedBlock1, meta, numberOfBlocks1, veinMinHeightLimit1, veinMaxHeightLimit1, replacedBlock1); + } + + @Override + public boolean generate(World world, Random random, int x, int y, int z) + { + if(replaceableBlocks.contains(world.getBlock(x, y, z))) + { + if(y<44 || world.getBlock(x, y+1, z).isAir(world, x, y+1, z) || world.getBlock(x, y+1, z).equals(Blocks.air)) + { + world.setBlock(x, y, z, mineableBlock, mineableBlockMeta, 2); + int x1,y1,z1; + int xyz[] = {0,0,1,0,0,-1,0,0}; + Block block; + for(int i=0;i<=5;i++) + { + x1=x+xyz[i]; + y1=y+xyz[i+1]; + z1=z+xyz[i+2]; + block = world.getBlock(x1,y1,z1); + if(block!=mineableBlock) + { + if(block.getMaterial()==Material.lava) + { + world.setBlock(x1, y1, z1, Blocks.obsidian, 0, 2); + } + else if(!block.isAir(world, x1, y1, z1) || xyz[i+1]<=0) + { + world.setBlock(x1, y1, z1, liquidBedBlock, 0, 2); + } + } + } + return true; + } + } + return false; + } + + @Override + public boolean generateNewVein(Random random, int chunkX1, int chunkZ1) + { + int chunkX = chunkX1; + int chunkZ = chunkZ1; + int x0=chunkX << 4; + int z0=chunkZ << 4; + long chunkKey = (chunkX<<16)+chunkZ; + for(int ix=x0-this.numberOfBlocks/2;ix>4; + chunkZ=z0>>4; + chunkKey = (chunkX<<16)+chunkZ; + updateOreCoordinatesToChunkCoordinates(chunkKey, oreCoordinatesArray); + this.blockToOreCoordinates.put(oreCoordinatesKey, this); + this.precalculatedChunkChache.add(chunkKey); + } + } + } + } + } + return true; + } +} diff --git a/ihl/worldgen/WorldGenMinableMeta.java b/ihl/worldgen/WorldGenMinableMeta.java new file mode 100644 index 0000000..3c5f094 --- /dev/null +++ b/ihl/worldgen/WorldGenMinableMeta.java @@ -0,0 +1,128 @@ +package ihl.worldgen; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenMinableMeta extends WorldGenerator { + + protected final Block mineableBlock; + protected final Set replaceableBlocks=new HashSet(); + protected final Block liquidBedBlock; + protected final int mineableBlockMeta; + protected final int numberOfBlocks; + protected int blockCounter; + protected final int veinMaxHeightLimit; + protected final int veinMinHeightLimit; + + public boolean maxBlockReached=false; + public int lastX=-1; + public int lastY=64; + public int lastZ=-1; + protected ForgeDirection veinDirection = ForgeDirection.SOUTH;//EAST + protected final Map> oreCoordinatesToChunkCoordinates; + protected final Map blockToOreCoordinates; + protected final Set precalculatedChunkChache; + + public WorldGenMinableMeta(Set precalculatedChunkChache1, Map blockToOreCoordinates1, Map> oreCoordinatesToChunkCoordinates2, Block block, int meta, int numberOfBlocks1, Block... blocks) { + this(precalculatedChunkChache1 ,blockToOreCoordinates1, oreCoordinatesToChunkCoordinates2, block, Blocks.clay, meta, numberOfBlocks1, 0, 128, blocks); + } + + public WorldGenMinableMeta(Set precalculatedChunkChache1, Map blockToOreCoordinates1, Map> oreCoordinatesToChunkCoordinates1, Block block, Block liquidBedBlock1, int meta, int numberOfBlocks1, int veinMinHeightLimit1, int veinMaxHeightLimit1, Block... replacedBlock1) + { + precalculatedChunkChache=precalculatedChunkChache1; + blockToOreCoordinates=blockToOreCoordinates1; + oreCoordinatesToChunkCoordinates=oreCoordinatesToChunkCoordinates1; + mineableBlock = block; + replaceableBlocks.addAll(Arrays.asList(replacedBlock1)); + mineableBlockMeta = meta; + liquidBedBlock=liquidBedBlock1; + numberOfBlocks = numberOfBlocks1; + veinMaxHeightLimit=veinMaxHeightLimit1; + veinMinHeightLimit=veinMinHeightLimit1; + } + + @Override + public boolean generate(World world, Random random, int x, int y, int z) + { + boolean success=false; + int chunkX = x>>4; + int chunkZ = z>>4; + int xyz[] = {0,0,1,0,0,-1,0,0}; + for(int i=0;i<=5;i++) + { + int x0 = x+xyz[i]; + int y0 = y+xyz[i+1]; + int z0 = z+xyz[i+2]; + if(x0>>4==chunkX && z0>>4==chunkZ) + { + if(replaceableBlocks.contains(world.getBlock(x0, y0, z0))) + { + world.setBlock(x0, y0, z0, mineableBlock, mineableBlockMeta, 2); + success=true; + } + } + } + return false; + } + + public boolean generateNewVein(Random random, int chunkX1, int chunkZ1) + { + Vec3 veinVector = Vec3.createVectorHelper(random.nextFloat()*2-1f, random.nextFloat()-0.5f, random.nextFloat()*2-1f); + veinVector.normalize(); + int chunkX = chunkX1; + int chunkZ = chunkZ1; + int x0=chunkX << 4; + int z0=chunkZ << 4; + int y0=random.nextInt(veinMaxHeightLimit); + //System.out.println("generated new vein with height="+y0); + float fx=x0; + float fy=y0; + float fz=z0; + long chunkKey = (chunkX<<16)+chunkZ; + for(int i=0;i>4; + chunkZ=z0>>4; + chunkKey = (chunkX<<16)+chunkZ; + updateOreCoordinatesToChunkCoordinates(chunkKey, oreCoordinatesArray); + this.blockToOreCoordinates.put(oreCoordinatesKey, this); + this.precalculatedChunkChache.add(chunkKey); + } + fx+=veinVector.xCoord+random.nextFloat()*0.25f; + fy+=veinVector.yCoord+random.nextFloat()*0.25f; + fz+=veinVector.zCoord+random.nextFloat()*0.25f; + x0=Math.round(fx); + y0=Math.round(fy); + z0=Math.round(fz); + } + return true; + } + + protected void updateOreCoordinatesToChunkCoordinates(long chunkKey, int[] oreCoordinates) + { + if(this.oreCoordinatesToChunkCoordinates.containsKey(chunkKey)) + { + this.oreCoordinatesToChunkCoordinates.get(chunkKey).add(oreCoordinates); + } + else + { + Set oreCoordinatesS = new HashSet(); + oreCoordinatesS.add(oreCoordinates); + this.oreCoordinatesToChunkCoordinates.put(chunkKey, oreCoordinatesS); + } + } + +} diff --git a/ihl/worldgen/ores/BlockOre.java b/ihl/worldgen/ores/BlockOre.java new file mode 100644 index 0000000..a88f3b7 --- /dev/null +++ b/ihl/worldgen/ores/BlockOre.java @@ -0,0 +1,137 @@ +package ihl.worldgen.ores; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import cpw.mods.fml.common.registry.GameRegistry; +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.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; + +public class BlockOre extends Block +{ + private Type type; + private static List instances = new ArrayList(); + private static Map iconMap = new HashMap(); + + public BlockOre(Type type1) + { + super(Material.rock); + this.type=type1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName(type.unLocalizedName); + instances.add(this); + this.setHardness(2.0F).setResistance(4.0F); + } + + public static void init() + { + Type[] var1 = Type.values(); + for(int i=0;i ii = instances.iterator(); + while(ii.hasNext()) + { + BlockOre instance = ii.next(); + GameRegistry.registerBlock(instance,instance.type.unLocalizedName); + OreDictionary.registerOre(instance.type.unLocalizedName, instance); + } + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag); + if(this.type.fortuneAffectsDrops) + { + this.dropXpOnBlockBreak(world, x, y, z, MathHelper.getRandomIntegerInRange(world.rand, 1, 4)); + } + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + ArrayList drops = new ArrayList(); + int fortmod = world.rand.nextInt(fortune + 2) - 1; + if (fortmod < 0 || !type.fortuneAffectsDrops)fortmod = 0; + ItemStack drop = null; + int amount = 1; + amount = (type.amountFrom + (type.amountTo>0?world.rand.nextInt(type.amountTo):0)) * (fortmod + 1); + drop = OreDictionary.getOres(type.oreDrop).get(0); + if (drop != null && amount > 0) + { + drop.stackSize=amount; + drops.add(drop); + } + return drops; + } + + + public enum Type + { + Bischofite("oreBischofite", "dustBischofite",1,2), + Datolite("oreDatolite", "dustDatolite",1,2), + Stibnite("oreStibnite"), + Chromite("oreChromite"), + Muscovite("oreMica"), + Bauxite("oreBauxite"), + Cinnabar("oreCinnabar"), + RockSalt("oreRockSalt", "dustRockSalt",1,2), + Limestone("oreLimestone", "dustCalcite",1,2), + Gypsum("oreGypsum"), + Gyubnera("oreGyubnera"),//(Mn,Fe)WO4 Mn:Fe 5/1 + OreTrona("oreTrona", "dustTrona",1,2), + PotassiumFeldspar("orePotassiumFeldspar"), + Apatite("oreApatite", "gemApatite",2,5), + Saltpeter("oreSaltpeter", "dustSaltpeter",1,2); + Type(String unlocalizedName1, String oreDrop1, int amountFrom1, int amountTo1 ) + { + unLocalizedName=unlocalizedName1; + oreDrop=oreDrop1; + amountFrom=amountFrom1; + amountTo=amountTo1; + } + Type(String unlocalizedName1) + { + unLocalizedName=unlocalizedName1; + oreDrop=unlocalizedName1; + amountFrom=1; + amountTo=0; + fortuneAffectsDrops=false; + } + String unLocalizedName; + String oreDrop; + int amountFrom; + int amountTo; + boolean fortuneAffectsDrops=true; + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) + { + iconMap.put(this.type, register.registerIcon(IHLModInfo.MODID + ":"+this.type.unLocalizedName)); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int i, int j) + { + return iconMap.get(type); + } +} diff --git a/ihl/worldgen/ores/DebugScannerBlock.java b/ihl/worldgen/ores/DebugScannerBlock.java new file mode 100644 index 0000000..a934f60 --- /dev/null +++ b/ihl/worldgen/ores/DebugScannerBlock.java @@ -0,0 +1,46 @@ +package ihl.worldgen.ores; + +import ihl.IHLCreativeTab; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class DebugScannerBlock extends Block implements ITileEntityProvider{ + + public DebugScannerBlock(Material material) + { + super(material); + this.setCreativeTab(IHLCreativeTab.tab); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new DebugScannerTileEntity(); + } + + @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 DebugScannerTileEntity) + { + DebugScannerTileEntity bte = (DebugScannerTileEntity)te; + if (bte == null || entityPlayer.isSneaking()) { + return false; + } + else + { + return bte.getGui(entityPlayer); + } + } + return false; + } +} diff --git a/ihl/worldgen/ores/DebugScannerContainer.java b/ihl/worldgen/ores/DebugScannerContainer.java new file mode 100644 index 0000000..52d4990 --- /dev/null +++ b/ihl/worldgen/ores/DebugScannerContainer.java @@ -0,0 +1,49 @@ +package ihl.worldgen.ores; + +import ic2.core.ContainerBase; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; + +public class DebugScannerContainer extends ContainerBase { + + protected DebugScannerTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastFuel = -1; + public short lastProgress = -1; + public final static int height=256; + public final static int width=248; + + public DebugScannerContainer(EntityPlayer entityPlayer, DebugScannerTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + int col,row; + + for (row = 0; row < 3; ++row) + { + for (col = 0; col < 13; ++col) + { + int slotnum = col + row * 13 + 9; + if(slotnum < entityPlayer.inventory.getSizeInventory()-4) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, slotnum, 8 + col * 18, 196 + row * 18)); + } + else + { + break; + } + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 80 + col * 18, 232)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.itemsSlot, 0, 8, 8)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.itemsSlot, 1, 8+18, 8)); + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/worldgen/ores/DebugScannerGui.java b/ihl/worldgen/ores/DebugScannerGui.java new file mode 100644 index 0000000..9d379fe --- /dev/null +++ b/ihl/worldgen/ores/DebugScannerGui.java @@ -0,0 +1,71 @@ +package ihl.worldgen.ores; + +import java.util.List; + +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 DebugScannerGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDebugScanner.png"); + private DebugScannerContainer container; + + public DebugScannerGui (DebugScannerContainer container1) + { + super(container1); + this.container=container1; + this.ySize=DebugScannerContainer.height; + this.xSize=DebugScannerContainer.width; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + List ode = container.tileEntity.oreDictionaryEntries; + int verticalOffset = 31; + for(int i=0;i38) + { + String string1=string.substring(0,38); + String string2=string.substring(38); + fontRendererObj.drawStringWithShadow(string1, 9, i*10+verticalOffset, colorIndex); + verticalOffset+=10; + fontRendererObj.drawStringWithShadow(string2, 9, i*10+verticalOffset, colorIndex); + } + else + { + fontRendererObj.drawStringWithShadow(string, 9, i*10+verticalOffset, colorIndex); + } + } + } + + @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); + } +} \ No newline at end of file diff --git a/ihl/worldgen/ores/DebugScannerTileEntity.java b/ihl/worldgen/ores/DebugScannerTileEntity.java new file mode 100644 index 0000000..2102cf0 --- /dev/null +++ b/ihl/worldgen/ores/DebugScannerTileEntity.java @@ -0,0 +1,161 @@ +package ihl.worldgen.ores; + +import java.util.ArrayList; +import java.util.Iterator; +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.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.oredict.OreDictionary; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlot; + +public class DebugScannerTileEntity extends TileEntityInventory implements IHasGui +{ + public final InvSlot itemsSlot; + private ItemStack lastItem; + public List oreDictionaryEntries = new ArrayList(); + + public DebugScannerTileEntity() + { + this.itemsSlot = new InvSlot(this, "drainInput", 0, InvSlot.Access.I, 2); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing()!=(short)side && side!=0 && side!=1; + } + + @Override + public void updateEntityClient() + { + if(IC2.platform.isRendering()) + { + if(this.itemsSlot.get(0)!=null && this.itemsSlot.get(0)!=lastItem) + { + this.oreDictionaryEntries.clear(); + int[] ids = OreDictionary.getOreIDs(this.itemsSlot.get()); + String itemNameFromIR = Item.itemRegistry.getNameForObject(this.itemsSlot.get().getItem()); + this.oreDictionaryEntries.add("ItemRegistry entry:"); + this.oreDictionaryEntries.add(" "+itemNameFromIR); + this.oreDictionaryEntries.add("Item damage: " + this.itemsSlot.get().getItemDamage()); + this.oreDictionaryEntries.add("Item class:"); + this.oreDictionaryEntries.add(" "+this.itemsSlot.get().getItem().getClass().getCanonicalName()); + if(this.itemsSlot.get().stackTagCompound!=null) + { + this.oreDictionaryEntries.add("NBT keys:"); + Iterator iterator = this.itemsSlot.get().stackTagCompound.func_150296_c().iterator(); + while(iterator.hasNext()) + { + String entry = (String) iterator.next(); + if(this.itemsSlot.get().stackTagCompound.getTag(entry) instanceof NBTTagCompound) + { + this.oreDictionaryEntries.add(" "+entry); + NBTTagCompound ct = this.itemsSlot.get().stackTagCompound.getCompoundTag(entry); + if(ct!=null && ct.func_150296_c()!=null && !ct.func_150296_c().isEmpty()) + { + this.oreDictionaryEntries.add(" -NBT compound tag subkeys:"); + Iterator stIterator = ct.func_150296_c().iterator(); + while(stIterator.hasNext()) + { + String entry2 = (String) stIterator.next(); + this.oreDictionaryEntries.add(" "+entry2+"="+ct.getString(entry2)); + } + } + } + else + { + this.oreDictionaryEntries.add(" "+entry+"="+this.itemsSlot.get().stackTagCompound.getString(entry)); + } + } + } + if(ids.length>0) + { + this.oreDictionaryEntries.add("Ore dict. entries:"); + for(int i=0;i "); + } + this.oreDictionaryEntries.add("Fluid flowing icon:"); + if(fluid.getFluid().getFlowingIcon()!=null) + { + this.oreDictionaryEntries.add(" "+fluid.getFluid().getFlowingIcon().getIconName()); + } + else + { + this.oreDictionaryEntries.add(" "); + } + } + } + lastItem=this.itemsSlot.get(1); + } + } + } + + /** + * Returns the name of the inventory + */ + @Override + public String getInventoryName() + { + return "debugScanner"; + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer entityPlayer) + { + return new DebugScannerContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new DebugScannerGui(new DebugScannerContainer(entityPlayer, this)); + } + + @Override + public void onGuiClosed(EntityPlayer entityPlayer) {} + + + public boolean getGui(EntityPlayer player) + { + return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false; + } + } \ No newline at end of file diff --git a/ihl/worldgen/ores/IHLFluid.java b/ihl/worldgen/ores/IHLFluid.java new file mode 100644 index 0000000..804a52c --- /dev/null +++ b/ihl/worldgen/ores/IHLFluid.java @@ -0,0 +1,363 @@ +package ihl.worldgen.ores; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import ic2.core.Ic2Items; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.items_blocks.IHLFluidBlock; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.material.MaterialLiquid; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBucket; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class IHLFluid extends Fluid +{ + private IHLFluidType type; + private static List fluidInstances = new ArrayList(); + private static Map localFluidRegistry = new HashMap(); + private static Map realDensityMap = new HashMap(); + private static Map condensationMap = new HashMap(); + private static Map> solutionMap = new HashMap(); + public static final int maxGaseousStateVapoursDensity = 40; + + public IHLFluid(IHLFluidType type1) { + super(type1.fluidRegistryName); + type=type1; + this.setTemperature(type.temperature); + this.setDensity(Math.round(type.density)); + realDensityMap.put(type1.fluidRegistryName, type.density); + this.setGaseous(type.isGaseous); + this.setUnlocalizedName(type.fluidRegistryName.replaceFirst("fluid", "")); + Fluid instance = this; + if (!FluidRegistry.registerFluid(instance)) + { + instance = FluidRegistry.getFluid(type.fluidRegistryName); + } + if(instance.getBlock()==null && !type.noBlock) + { + instance.setBlock(new IHLFluidBlock(instance, type.blockMaterial, type.textureName, "fluid"+type.fluidName.replaceFirst("fluid", "")).setFlammable(type.flammable).setBlockName("block"+type.fluidName).setCreativeTab(IHLCreativeTab.tab)); + } + if(type.haveBucket) + { + Item bucket = new ItemBucket(block).setTextureName(IHLModInfo.MODID+":bucket_"+type.fluidName).setUnlocalizedName("bucket_"+type.fluidName).setCreativeTab(IHLCreativeTab.tab); + GameRegistry.registerItem(bucket, "bucket_"+type.fluidName); + FluidContainerRegistry.registerFluidContainer(instance, new ItemStack(bucket), FluidContainerRegistry.EMPTY_BUCKET); + } + type.fluid=instance; + localFluidRegistry.put(type1.fluidRegistryName, type); + fluidInstances.add(this); + } + + public static void init() + { + IHLFluidType[] var1 = IHLFluidType.values(); + for(int i=0;i ii = fluidInstances.iterator(); + while(ii.hasNext()) + { + Fluid instance = ii.next(); + IHLFluidType instanceType = localFluidRegistry.get(instance.getName()); + instance.setIcons( + iconRegistry.registerIcon(IHLModInfo.MODID + ":" + instanceType.textureName + "Still") + ,iconRegistry.registerIcon(IHLModInfo.MODID + ":" + instanceType.textureName + "Flowing") + ); + } + } + + public static ItemStack getCell(String fluidname1) + { + ItemStack filledCell = FluidContainerRegistry.fillFluidContainer(new FluidStack(FluidRegistry.getFluid(fluidname1), FluidContainerRegistry.BUCKET_VOLUME),Ic2Items.cell.copy()); + return filledCell; + } + + public static Block getBlock(String fluidname) + { + return localFluidRegistry.get(fluidname).fluid.getBlock(); + } + + public static int getMeltingPoint(Fluid fluid) + { + if(localFluidRegistry.get(fluid.getName())!=null) + { + IHLFluidType type = localFluidRegistry.get(fluid.getName()); + return type.meltingPoint; + } + else + { + if(fluid.isGaseous()) + { + return fluid.getTemperature()>100?fluid.getTemperature()-100:0; + } + else + { + return fluid.getTemperature(); + } + } + } + + public static int getBoilingPoint(Fluid fluid) + { + if(localFluidRegistry.containsKey(fluid.getName())) + { + IHLFluidType type = localFluidRegistry.get(fluid.getName()); + return type.boilingPoint; + } + else + { + if(fluid.getName()=="steam" || fluid.getName()=="ic2steam" || fluid.getName()=="ic2superheatedsteam") + { + return 373; + } + else if(fluid.isGaseous()) + { + return fluid.getTemperature(); + } + else + { + return fluid.getTemperature()+100; + } + } + } + + public enum IHLFluidType + { + //Methane("Methane","fluidAcetylene",10047, 293, 249, 373, 1150, "methane", Material.water, false, false, false, false), + LithiumChloride("LithiumChlorideDissolvedInWater",10046, 293, 249, 373, 1530, "solution.lithiumchloride", Material.water, false, false, false), + CalciumChloride("CalciumChlorideDissolvedInWater",10045, 293, 249, 373, 1630, "solution.calciumchloride", Material.water, false, false, false), + ZeolitePulp("ZeolitePulp","fluidPulpZeolite",10044, 293, 249, 373, 1150, "pulp.sodiumzeolite", Material.water, false, false, false), + MoltenTarPitch("MoltenTarPitch","fluidOil",10043, 373, 373, 800, 1250, "molten.tarpitch", Material.lava, false, false, false), + CrackingGas("CrackingGas","fluidAcetylene",10042, 293, 135, 273, 2.27f, "crackinggas",new MaterialLiquid(MapColor.blackColor), false, false, false), + Trichlorosilane("Trichlorosilane","fluidHydrogenChloride", 10041, 293, 147, 305, 1342, "trichlorosilane", new MaterialLiquid(MapColor.greenColor), true, false, false), + SiliconTetrachloride("SiliconTetrachloride","fluidChlorine", 10040, 293, 204, 330, 584, "silicontetrachloride", new MaterialLiquid(MapColor.cyanColor), true, false, false), + Chlorine("Chlorine", 10039, 293, 172, 238, 3.21F), + BoricAcid("BoricAcid",10038, 373, 249, 373, 1275, "boricacid", Material.water, false, false, false), + MicaPulp("PulpMica",10037, 293, 249, 373, 1150, "pulp.mica", Material.water, false, false, false), + CellulosePulp("PulpCellulose",10036, 293, 249, 373, 1075, "pulp.cellulose", Material.water, false, false, false), + Fuel("Fuel", 10035, 293, 268, 633, 840, "fuel", Material.water, true, false, true), + MineralOil("MineralOil", 10034, 293, 238, 704, 845, "mineraloil", Material.water, true, false, true), + FuelOil("FuelOil", 10033, 293, 293, 693, 991, "fueloil", Material.water, true, false, true), + Oil("Oil", 10032, 293, 284, 773, 850, "oil", Material.water, true, false, true), + Mercury("Mercury", 10031, 293, 234, 630, 13546), + VapourMercury("VapourMercury",10030, 630, 234, 630, 9.229F, "vapour.mercury", new MaterialLiquid(MapColor.cyanColor), false, false, false), + Hydrogen("Hydrogen", 10029, 293, 14, 20, 0.046F, "hydrogen", new MaterialLiquid(MapColor.blueColor), true, false, true), + SaltWater("SaltWater", 10028, 293, 253, 373, 1360), + HydrogenChloride("HydrogenChloride", 10027, 293, 159, 188, 1.477F, "hydrogenchloride", new MaterialLiquid(MapColor.yellowColor), true, false, true), + NatriumTungstate("NatriumTungstateDissolvedInWater",10026, 293, 249, 373, 1730, "solution.natriumtungstate", Material.water, true, false, false), + Turpentine("Turpentine",10025, 293, 217, 453, 1470, "turpentine", Material.water, true, false, true), + Air("Air", 293, 55, 93, 1.292F, Ic2Items.airCell), + Nitrogen("Nitrogen", 10024, 92, 56, 92, 1.251F, "nitrogen", new MaterialLiquid(MapColor.airColor), true, false, true), + Acetylene("Acetylene", 10023, 293, 17, 190, 1.173F, "acetylene", Material.water, true, false, true), + Oxygen("Oxygen", 10022, 93, 55, 93, 1.429F, "oxygen", new MaterialLiquid(MapColor.airColor), true, false, true), + NatriumHydroxide("NatriumHydroxideDissolvedInWater",10021, 293, 249, 373, 1525, "solution.natriumhydroxide", Material.water, true, false, false), + LiquidGlass("LiquidGlass",10020, 293, 253, 373, 2400), + fluidRubberTreeSap("fluidRubberTreeSap",10019, 293, 273, 393, 1200, "fluidrubbertreesap", Material.water, true, true, false), + SpruceResin("SpruceResin",10018, 293, 273, 533, 1080, "spruceresin", Material.water, true, true, true), + 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), + AquaRegia("AquaRegia",10014, 293, 231, 356, 1060), + SodiumPeroxide("SodiumPeroxide",10013, 950, 950, 2223, 1800), + OsmiumTetroxide("OsmiumTetroxide",10012, 313, 313, 403, 9), + OleicAcid("OleicAcid",10011, 293, 288, 633, 895, "oleicacid", Material.water, true, false, true), + Limemilk("Limemilk",10010, 293, 250, 373, 1020), + NickelSulfateDissolvedInWater("NickelSulfateDissolvedInWater",10009, 293, 253, 373, 1220, "solution.nickelsulfate", Material.water, true, false, false), + BlueVitriolDissolvedInWater("BlueVitriolDissolvedInWater",10008, 293, 253, 373, 1180, "solution.bluevitriol", Material.water, true, false, false), + MoltenRubberWithSulfur("MoltenRubberWithSulfur",10007, 600, 600, 1000, 1200, "molten.rubber", Material.lava, false, false, true), + MoltenLithium("MoltenLithium","fluidMolten",10042, 454, 454, 1613, 512, "molten.lithium", Material.lava, false, false, false), + MoltenSodiumChloride("MoltenSodiumChloride","fluidMolten",10006, 1273, 1273, 1740, 1556, "molten.sodiumchloride", Material.lava, false, false, false), + MoltenGlass("MoltenGlass","fluidMolten",10048, 600, 600, 1950, 2270, "molten.glass", Material.lava, false, false, false, true), + MoltenMagnesium("MoltenMagnesium","fluidMolten",10006, 923, 923, 1623, 1584, "molten.magnesium", Material.lava, false, false, false), + MoltenSteel("MoltenSteel","fluidMolten",10006, 1800, 1800, 3134, 6980, "molten.steel", Material.lava, false, false, false), + MoltenCopper("MoltenCopper","fluidMolten",10048, 1356, 1356, 2840, 8920, "molten.copper", Material.lava, false, false, false), + MoltenBronze("MoltenBronze",10005, 940, 940, 2840, 8000, "molten.bronze", Material.lava, false, false, false), + MoltenGold("MoltenGold",10005, 1337, 1337, 3129, 17310, "molten.gold", Material.lava, false, false, false), + VapourSulfuricAcid("VapourSulfuricAcid",10004, 610, 283, 610, 4.522F, "vapour.sulfuricacid", new MaterialLiquid(MapColor.redColor), false, false, false), + SulfuricAnhydride("SulfuricAnhydride",10003, 45, 17, 45, 2, "sulfuricanhydride", new MaterialLiquid(MapColor.redColor), true, false, false), + SulfuricAcid("SulfuricAcid",10002, 293, 283, 610, 1836), + NitricAcid("NitricAcid",10001, 293, 231, 356, 1100); + IHLFluidType(String fluidName1, int celldamage, int temperature1, int meltingPoint1, int boilingPoint1, float density1) + { + fluidName=fluidName1; + fluidRegistryName=fluidName.toLowerCase(); + textureName="fluid"+fluidName.replaceFirst("fluid", ""); + temperature=temperature1; + density=density1; + cellName="itemCell"+fluidName; + haveBucket=false; + isGaseous=density10) + { + return new FluidStack(fluid.getID(),quantity); + } + } + return null; + } + public static float getCondensationConversionRate(Fluid gas) + { + String fluidname = condensationMap.get(gas.getName()); + Fluid fluid = FluidRegistry.getFluid(fluidname); + if(fluid!=null) + { + float rate = (float)gas.getDensity()/(float)fluid.getDensity(); + if(gas.getDensity()<0) + { + //IC2 steam density -800, 100 mb steam from 1 mb water + rate=(-8000F/gas.getDensity())/fluid.getDensity(); + } + return rate; + } + return 0F; + } + + public static boolean canBeDissolvedIn(FluidStack solvent, String impurity) + { + return solutionMap.get(solvent.getFluid().getName()).contains(impurity); + } + + public static float getRealDensity(Fluid gas) + { + if(realDensityMap.containsKey(gas.getName())) + { + return realDensityMap.get(gas.getName()); + } + else + { + float density = gas.getDensity(); + if(gas.getDensity()<0) + { + //IC2 steam density -800, 100 mb steam from 1 mb water + density=-8000F/gas.getDensity(); + } + return density; + } + } + +} -- cgit v1.2.3