From e5a6eadc45b004d6730ff4ffd827e6e0b2916e9b Mon Sep 17 00:00:00 2001 From: Victor Robertson Date: Fri, 7 Mar 2014 19:00:25 -0600 Subject: [PATCH] Fix indentation and remove trailing whitespace This patch provides common/mekanism/*.java with standardized indentation (tabs) and also removes trailing whitespace. --- common/mekanism/api/AdvancedInput.java | 8 +- common/mekanism/api/ChanceOutput.java | 18 +- common/mekanism/api/ChemicalPair.java | 22 +- common/mekanism/api/Coord4D.java | 88 +- common/mekanism/api/EnumColor.java | 22 +- common/mekanism/api/IClientTicker.java | 2 +- common/mekanism/api/ItemInfo.java | 16 +- common/mekanism/api/ItemRetriever.java | 32 +- common/mekanism/api/ListUtils.java | 52 +- common/mekanism/api/MekanismAPI.java | 12 +- common/mekanism/api/Pos3D.java | 54 +- common/mekanism/api/RecipeHelper.java | 28 +- common/mekanism/api/TabProxy.java | 8 +- .../api/energy/EnergizedItemManager.java | 14 +- .../mekanism/api/energy/ICableOutputter.java | 2 +- .../mekanism/api/energy/IEnergizedItem.java | 14 +- .../api/energy/IStrictEnergyAcceptor.java | 2 +- .../api/energy/IStrictEnergyStorage.java | 6 +- common/mekanism/api/gas/Gas.java | 54 +- common/mekanism/api/gas/GasNetwork.java | 200 +- common/mekanism/api/gas/GasRegistry.java | 26 +- common/mekanism/api/gas/GasStack.java | 30 +- common/mekanism/api/gas/GasTank.java | 66 +- common/mekanism/api/gas/GasTransmission.java | 188 +- common/mekanism/api/gas/IGasHandler.java | 8 +- common/mekanism/api/gas/IGasItem.java | 14 +- common/mekanism/api/gas/IGasTransmitter.java | 2 +- common/mekanism/api/gas/ITubeConnection.java | 2 +- common/mekanism/api/gas/OreGas.java | 14 +- common/mekanism/api/infuse/InfuseObject.java | 6 +- .../mekanism/api/infuse/InfuseRegistry.java | 26 +- common/mekanism/api/infuse/InfuseType.java | 18 +- common/mekanism/api/infuse/InfusionInput.java | 8 +- .../mekanism/api/infuse/InfusionOutput.java | 12 +- .../api/transmitters/DynamicNetwork.java | 166 +- .../api/transmitters/IGridTransmitter.java | 26 +- .../api/transmitters/ITransmitter.java | 2 +- .../api/transmitters/ITransmitterNetwork.java | 32 +- .../api/transmitters/TransmissionType.java | 62 +- .../TransmitterNetworkRegistry.java | 38 +- .../mekanism/client/CapeBufferDownload.java | 16 +- .../client/ClientConnectionHandler.java | 6 +- common/mekanism/client/ClientProxy.java | 136 +- common/mekanism/client/ClientTickHandler.java | 254 +-- common/mekanism/client/HolidayManager.java | 90 +- common/mekanism/client/MekanismClient.java | 22 +- .../mekanism/client/MekanismKeyHandler.java | 6 +- .../mekanism/client/ThreadClientUpdate.java | 86 +- common/mekanism/client/ThreadTankSparkle.java | 30 +- .../gui/GuiAdvancedElectricMachine.java | 118 +- common/mekanism/client/gui/GuiBucket.java | 14 +- .../mekanism/client/gui/GuiChanceMachine.java | 86 +- .../client/gui/GuiChemicalCrystalizer.java | 378 ++-- .../gui/GuiChemicalDissolutionChamber.java | 140 +- .../client/gui/GuiChemicalInfuser.java | 178 +- .../client/gui/GuiChemicalOxidizer.java | 130 +- .../client/gui/GuiChemicalWasher.java | 174 +- .../mekanism/client/gui/GuiConfiguration.java | 422 ++--- .../client/gui/GuiConfigurationTab.java | 20 +- common/mekanism/client/gui/GuiCredits.java | 76 +- common/mekanism/client/gui/GuiDictionary.java | 158 +- .../mekanism/client/gui/GuiDigitalMiner.java | 238 +-- .../client/gui/GuiDigitalMinerConfig.java | 330 ++-- .../mekanism/client/gui/GuiDynamicTank.java | 86 +- .../mekanism/client/gui/GuiElectricChest.java | 114 +- .../client/gui/GuiElectricMachine.java | 86 +- .../mekanism/client/gui/GuiElectricPump.java | 70 +- .../client/gui/GuiElectrolyticSeparator.java | 152 +- common/mekanism/client/gui/GuiElement.java | 26 +- common/mekanism/client/gui/GuiEnergyCube.java | 40 +- common/mekanism/client/gui/GuiEnergyInfo.java | 8 +- common/mekanism/client/gui/GuiFactory.java | 196 +- common/mekanism/client/gui/GuiGasTank.java | 58 +- .../client/gui/GuiLogisticalSorter.java | 296 +-- .../client/gui/GuiMItemStackFilter.java | 122 +- .../client/gui/GuiMOreDictFilter.java | 292 +-- common/mekanism/client/gui/GuiMekanism.java | 96 +- .../client/gui/GuiMetallurgicInfuser.java | 116 +- .../mekanism/client/gui/GuiPasswordEnter.java | 94 +- .../client/gui/GuiPasswordModify.java | 98 +- .../client/gui/GuiPortableTeleporter.java | 160 +- .../client/gui/GuiPrecisionSawmill.java | 8 +- common/mekanism/client/gui/GuiRecipeType.java | 18 +- .../client/gui/GuiRedstoneControl.java | 26 +- .../mekanism/client/gui/GuiRobitCrafting.java | 70 +- .../client/gui/GuiRobitInventory.java | 60 +- common/mekanism/client/gui/GuiRobitMain.java | 192 +- .../mekanism/client/gui/GuiRobitRepair.java | 290 +-- .../mekanism/client/gui/GuiRobitSmelting.java | 104 +- .../client/gui/GuiRotaryCondensentrator.java | 118 +- .../client/gui/GuiSalinationController.java | 228 +-- common/mekanism/client/gui/GuiSortingTab.java | 20 +- .../client/gui/GuiTItemStackFilter.java | 200 +- .../client/gui/GuiTOreDictFilter.java | 342 ++-- common/mekanism/client/gui/GuiTeleporter.java | 142 +- .../client/gui/GuiUpgradeManagement.java | 34 +- .../client/model/ModelArmoredJetpack.java | 370 ++-- .../client/model/ModelAtomicDisassembler.java | 6 +- .../mekanism/client/model/ModelBalloon.java | 8 +- .../client/model/ModelBoxSelectiveFace.java | 172 +- .../mekanism/client/model/ModelChargepad.java | 4 +- .../model/ModelChemicalCrystalizer.java | 18 +- .../ModelChemicalDissolutionChamber.java | 12 +- .../client/model/ModelChemicalInfuser.java | 16 +- .../client/model/ModelChemicalOxidizer.java | 14 +- .../client/model/ModelChemicalWasher.java | 12 +- .../client/model/ModelDigitalMiner.java | 12 +- .../client/model/ModelElectricPump.java | 8 +- .../model/ModelElectrolyticSeparator.java | 388 ++-- .../client/model/ModelEnergyCube.java | 12 +- .../client/model/ModelFreeRunners.java | 4 +- .../mekanism/client/model/ModelGasMask.java | 124 +- .../mekanism/client/model/ModelGasTank.java | 4 +- .../mekanism/client/model/ModelJetpack.java | 20 +- .../client/model/ModelLogisticalSorter.java | 14 +- .../client/model/ModelMetallurgicInfuser.java | 6 +- .../client/model/ModelObsidianTNT.java | 2 +- .../model/ModelRendererSelectiveFace.java | 264 +-- common/mekanism/client/model/ModelRobit.java | 116 +- .../client/model/ModelTransporterBox.java | 10 +- .../nei/AdvancedMachineRecipeHandler.java | 44 +- .../client/nei/BaseRecipeHandler.java | 42 +- .../nei/ChanceMachineRecipeHandler.java | 12 +- .../nei/ChemicalCrystalizerRecipeHandler.java | 50 +- ...emicalDissolutionChamberRecipeHandler.java | 52 +- .../nei/ChemicalInfuserRecipeHandler.java | 60 +- ...ChemicalInjectionChamberRecipeHandler.java | 8 +- .../nei/ChemicalOxidizerRecipeHandler.java | 46 +- .../nei/ChemicalWasherRecipeHandler.java | 60 +- .../client/nei/CombinerRecipeHandler.java | 6 +- .../client/nei/CrusherRecipeHandler.java | 4 +- .../ElectrolyticSeparatorRecipeHandler.java | 60 +- .../nei/EnrichmentChamberRecipeHandler.java | 4 +- .../client/nei/MachineRecipeHandler.java | 2 +- .../client/nei/MekanismRecipeHandler.java | 148 +- .../nei/MetallurgicInfuserRecipeHandler.java | 38 +- .../client/nei/NEIMekanismConfig.java | 36 +- .../nei/OsmiumCompressorRecipeHandler.java | 6 +- .../nei/PrecisionSawmillRecipeHandler.java | 4 +- .../nei/PurificationChamberRecipeHandler.java | 8 +- .../RotaryCondensentratorRecipeHandler.java | 68 +- .../SalinationControllerRecipeHandler.java | 62 +- .../client/render/MekanismRenderer.java | 570 +++--- .../client/render/ModelCustomArmor.java | 64 +- .../client/render/RenderPartTransmitter.java | 256 +-- .../client/render/RenderTickHandler.java | 72 +- .../render/block/BasicRenderingHandler.java | 28 +- .../render/block/MachineRenderingHandler.java | 72 +- .../client/render/entity/RenderBalloon.java | 22 +- .../entity/RenderObsidianTNTPrimed.java | 100 +- .../client/render/entity/RenderRobit.java | 8 +- .../render/item/ItemRenderingHandler.java | 320 ++-- .../client/render/tileentity/RenderBin.java | 270 +-- .../render/tileentity/RenderChargepad.java | 14 +- .../tileentity/RenderChemicalCrystalizer.java | 20 +- .../RenderChemicalDissolutionChamber.java | 14 +- .../tileentity/RenderChemicalInfuser.java | 74 +- .../tileentity/RenderChemicalOxidizer.java | 66 +- .../tileentity/RenderChemicalWasher.java | 14 +- .../tileentity/RenderConfigurableMachine.java | 58 +- .../render/tileentity/RenderDigitalMiner.java | 18 +- .../render/tileentity/RenderDynamicTank.java | 130 +- .../tileentity/RenderElectricChest.java | 44 +- .../render/tileentity/RenderElectricPump.java | 18 +- .../RenderElectrolyticSeparator.java | 20 +- .../render/tileentity/RenderEnergyCube.java | 72 +- .../render/tileentity/RenderGasTank.java | 14 +- .../tileentity/RenderLogisticalSorter.java | 42 +- .../tileentity/RenderMetallurgicInfuser.java | 22 +- .../render/tileentity/RenderObsidianTNT.java | 8 +- .../RenderRotaryCondensentrator.java | 18 +- .../RenderSalinationController.java | 74 +- .../render/tileentity/RenderTeleporter.java | 36 +- .../mekanism/client/sound/GasMaskSound.java | 8 +- common/mekanism/client/sound/IHasSound.java | 4 +- .../mekanism/client/sound/JetpackSound.java | 8 +- common/mekanism/client/sound/PlayerSound.java | 12 +- common/mekanism/client/sound/Sound.java | 90 +- .../mekanism/client/sound/SoundHandler.java | 98 +- common/mekanism/client/sound/TileSound.java | 14 +- common/mekanism/client/voice/VoiceClient.java | 40 +- common/mekanism/client/voice/VoiceInput.java | 30 +- common/mekanism/client/voice/VoiceOutput.java | 16 +- .../mekanism/common/BoxBlacklistParser.java | 34 +- common/mekanism/common/CommandMekanism.java | 138 +- .../common/CommonPlayerTickHandler.java | 138 +- .../mekanism/common/CommonPlayerTracker.java | 6 +- common/mekanism/common/CommonProxy.java | 136 +- .../common/CommonWorldTickHandler.java | 22 +- .../common/ConnectedTextureRenderer.java | 122 +- common/mekanism/common/CoreGuiHandler.java | 6 +- .../mekanism/common/CreativeTabMekanism.java | 2 +- common/mekanism/common/EnergyDisplay.java | 38 +- common/mekanism/common/EnergyNetwork.java | 192 +- common/mekanism/common/FluidNetwork.java | 208 +-- common/mekanism/common/FluidSlot.java | 10 +- common/mekanism/common/HashList.java | 38 +- common/mekanism/common/IActiveState.java | 8 +- .../common/IAdvancedBoundingBlock.java | 6 +- common/mekanism/common/IBoundingBlock.java | 4 +- common/mekanism/common/IConfigurable.java | 2 +- common/mekanism/common/IEjector.java | 18 +- common/mekanism/common/IElectricChest.java | 22 +- common/mekanism/common/IElectricMachine.java | 20 +- common/mekanism/common/IEnergyCube.java | 4 +- common/mekanism/common/IFactory.java | 92 +- common/mekanism/common/IInvConfiguration.java | 8 +- .../common/ILogisticalTransporter.java | 16 +- common/mekanism/common/IModule.java | 6 +- common/mekanism/common/IRedstoneControl.java | 14 +- common/mekanism/common/ISpecialBounds.java | 4 +- .../mekanism/common/ISustainedInventory.java | 4 +- common/mekanism/common/ISustainedTank.java | 6 +- common/mekanism/common/ITileComponent.java | 10 +- common/mekanism/common/ITileNetwork.java | 4 +- .../mekanism/common/IUpgradeManagement.java | 10 +- common/mekanism/common/ItemAttacher.java | 14 +- common/mekanism/common/KeySync.java | 22 +- common/mekanism/common/Mekanism.java | 444 ++--- common/mekanism/common/ObfuscatedNames.java | 2 +- common/mekanism/common/OreDictCache.java | 58 +- common/mekanism/common/OreHandler.java | 8 +- common/mekanism/common/PacketHandler.java | 208 +-- common/mekanism/common/Resource.java | 10 +- common/mekanism/common/RobitAIFollow.java | 238 +-- common/mekanism/common/RobitAIPickup.java | 12 +- common/mekanism/common/SideData.java | 6 +- common/mekanism/common/Teleporter.java | 6 +- common/mekanism/common/ThreadGetData.java | 4 +- common/mekanism/common/Tier.java | 24 +- common/mekanism/common/Version.java | 28 +- common/mekanism/common/asm/LoadingHook.java | 4 +- common/mekanism/common/block/BlockBasic.java | 576 +++--- .../mekanism/common/block/BlockBounding.java | 26 +- .../common/block/BlockCardboardBox.java | 216 +-- .../common/block/BlockEnergyCube.java | 368 ++-- .../mekanism/common/block/BlockGasTank.java | 280 +-- .../mekanism/common/block/BlockMachine.java | 1526 ++++++++-------- .../common/block/BlockObsidianTNT.java | 168 +- common/mekanism/common/block/BlockOre.java | 12 +- .../common/classloading/ClassEnumerator.java | 30 +- .../mekanism/common/entity/EntityBalloon.java | 542 +++--- .../common/entity/EntityObsidianTNT.java | 222 +-- .../mekanism/common/entity/EntityRobit.java | 642 +++---- .../common/integration/IC2ItemManager.java | 26 +- .../common/integration/MekanismHooks.java | 58 +- .../common/integration/OreDictManager.java | 222 +-- .../common/inventory/InventoryBin.java | 66 +- .../inventory/InventoryElectricChest.java | 126 +- .../ContainerAdvancedElectricMachine.java | 338 ++-- .../container/ContainerChanceMachine.java | 280 +-- .../ContainerChemicalCrystalizer.java | 246 +-- .../ContainerChemicalDissolutionChamber.java | 272 +-- .../container/ContainerChemicalInfuser.java | 230 +-- .../container/ContainerChemicalOxidizer.java | 246 +-- .../container/ContainerChemicalWasher.java | 280 +-- .../container/ContainerDictionary.java | 134 +- .../container/ContainerDigitalMiner.java | 226 +-- .../container/ContainerDynamicTank.java | 196 +- .../container/ContainerElectricChest.java | 282 +-- .../container/ContainerElectricMachine.java | 278 +-- .../container/ContainerElectricPump.java | 246 +-- .../ContainerElectrolyticSeparator.java | 282 +-- .../container/ContainerEnergyCube.java | 292 +-- .../inventory/container/ContainerFactory.java | 526 +++--- .../inventory/container/ContainerFilter.java | 146 +- .../inventory/container/ContainerGasTank.java | 210 +-- .../ContainerMetallurgicInfuser.java | 288 +-- .../inventory/container/ContainerNull.java | 20 +- .../container/ContainerRobitCrafting.java | 10 +- .../container/ContainerRobitInventory.java | 150 +- .../container/ContainerRobitMain.java | 72 +- .../container/ContainerRobitRepair.java | 10 +- .../container/ContainerRobitSmelting.java | 304 ++-- .../ContainerRotaryCondensentrator.java | 284 +-- .../ContainerSalinationController.java | 254 +-- .../container/ContainerTeleporter.java | 188 +- .../inventory/slot/SlotElectricChest.java | 14 +- .../common/inventory/slot/SlotEnergy.java | 6 +- .../inventory/slot/SlotMachineUpgrade.java | 2 +- .../common/inventory/slot/SlotOutput.java | 2 +- .../inventory/slot/SlotStorageTank.java | 10 +- .../common/item/ItemAtomicDisassembler.java | 532 +++--- common/mekanism/common/item/ItemBalloon.java | 64 +- .../mekanism/common/item/ItemBlockBasic.java | 84 +- .../common/item/ItemBlockCardboardBox.java | 148 +- .../common/item/ItemBlockEnergyCube.java | 126 +- .../common/item/ItemBlockGasTank.java | 112 +- .../common/item/ItemBlockMachine.java | 618 +++---- common/mekanism/common/item/ItemBlockOre.java | 14 +- common/mekanism/common/item/ItemClump.java | 4 +- .../common/item/ItemConfigurator.java | 416 ++--- common/mekanism/common/item/ItemCrystal.java | 4 +- .../mekanism/common/item/ItemDictionary.java | 28 +- .../mekanism/common/item/ItemDirtyDust.java | 4 +- common/mekanism/common/item/ItemDust.java | 8 +- .../mekanism/common/item/ItemElectricBow.java | 202 +-- .../mekanism/common/item/ItemEnergized.java | 48 +- .../mekanism/common/item/ItemFreeRunners.java | 82 +- common/mekanism/common/item/ItemGasMask.java | 36 +- common/mekanism/common/item/ItemIngot.java | 6 +- common/mekanism/common/item/ItemJetpack.java | 110 +- common/mekanism/common/item/ItemMekanism.java | 4 +- .../common/item/ItemNetworkReader.java | 104 +- .../common/item/ItemPortableTeleporter.java | 40 +- common/mekanism/common/item/ItemProxy.java | 20 +- common/mekanism/common/item/ItemRobit.java | 64 +- .../mekanism/common/item/ItemScubaTank.java | 92 +- common/mekanism/common/item/ItemShard.java | 4 +- .../common/item/ItemWalkieTalkie.java | 46 +- .../common/miner/MItemStackFilter.java | 36 +- .../mekanism/common/miner/MOreDictFilter.java | 24 +- common/mekanism/common/miner/MinerFilter.java | 32 +- .../common/miner/ThreadMinerSearch.java | 56 +- .../common/multipart/ItemPartTransmitter.java | 62 +- .../common/multipart/MultipartMekanism.java | 6 +- .../multipart/PartDiversionTransporter.java | 62 +- .../multipart/PartLogisticalTransporter.java | 314 ++-- .../common/multipart/PartMechanicalPipe.java | 302 +-- .../common/multipart/PartPressurizedTube.java | 288 +-- .../multipart/PartRestrictiveTransporter.java | 6 +- .../common/multipart/PartSidedPipe.java | 140 +- .../common/multipart/PartTransmitter.java | 54 +- .../common/multipart/PartUniversalCable.java | 278 +-- .../common/multipart/TransmitterIcons.java | 58 +- .../common/multipart/TransmitterType.java | 28 +- .../common/network/IMekanismPacket.java | 6 +- .../common/network/PacketBoxBlacklist.java | 14 +- .../common/network/PacketConfigSync.java | 122 +- .../network/PacketConfigurationUpdate.java | 60 +- .../network/PacketConfiguratorState.java | 14 +- .../common/network/PacketDataRequest.java | 24 +- .../common/network/PacketDigitUpdate.java | 14 +- .../common/network/PacketDigitalMinerGui.java | 108 +- .../common/network/PacketEditFilter.java | 74 +- .../network/PacketElectricBowState.java | 16 +- .../common/network/PacketElectricChest.java | 306 ++-- .../common/network/PacketJetpackData.java | 32 +- common/mekanism/common/network/PacketKey.java | 30 +- .../network/PacketLogisticalSorterGui.java | 90 +- .../common/network/PacketNewFilter.java | 38 +- .../network/PacketPortableTeleport.java | 20 +- .../common/network/PacketPortalFX.java | 12 +- .../common/network/PacketRedstoneControl.java | 14 +- .../common/network/PacketRemoveUpgrade.java | 20 +- .../mekanism/common/network/PacketRobit.java | 130 +- .../common/network/PacketScubaTankData.java | 32 +- .../common/network/PacketSimpleGui.java | 44 +- .../common/network/PacketStatusUpdate.java | 14 +- .../common/network/PacketTileEntity.java | 16 +- .../network/PacketTransmitterUpdate.java | 146 +- .../network/PacketWalkieTalkieState.java | 16 +- common/mekanism/common/recipe/BinRecipe.java | 56 +- .../common/recipe/MekanismRecipe.java | 586 +++--- .../mekanism/common/recipe/RecipeHandler.java | 106 +- .../common/tank/DynamicFluidTank.java | 312 ++-- .../common/tank/DynamicTankCache.java | 4 +- .../common/tank/SynchronizedTankData.java | 42 +- .../common/tank/TankUpdateProtocol.java | 314 ++-- .../tile/TileEntityAdvancedBoundingBlock.java | 144 +- .../TileEntityAdvancedElectricMachine.java | 258 +-- .../tile/TileEntityAdvancedFactory.java | 4 +- .../common/tile/TileEntityBasicBlock.java | 120 +- .../common/tile/TileEntityBasicMachine.java | 206 +-- .../mekanism/common/tile/TileEntityBin.java | 242 +-- .../common/tile/TileEntityBoundingBlock.java | 68 +- .../common/tile/TileEntityCardboardBox.java | 10 +- .../common/tile/TileEntityChanceMachine.java | 184 +- .../common/tile/TileEntityChargepad.java | 116 +- .../tile/TileEntityChemicalCrystalizer.java | 300 +-- .../TileEntityChemicalDissolutionChamber.java | 230 +-- .../tile/TileEntityChemicalInfuser.java | 238 +-- .../TileEntityChemicalInjectionChamber.java | 20 +- .../tile/TileEntityChemicalOxidizer.java | 208 +-- .../common/tile/TileEntityChemicalWasher.java | 262 +-- .../common/tile/TileEntityCombiner.java | 8 +- .../common/tile/TileEntityContainerBlock.java | 260 +-- .../common/tile/TileEntityCrusher.java | 12 +- .../common/tile/TileEntityDigitalMiner.java | 612 +++---- .../common/tile/TileEntityDynamicTank.java | 272 +-- .../common/tile/TileEntityDynamicValve.java | 14 +- .../common/tile/TileEntityElectricBlock.java | 146 +- .../common/tile/TileEntityElectricChest.java | 136 +- .../tile/TileEntityElectricMachine.java | 118 +- .../common/tile/TileEntityElectricPump.java | 280 +-- .../tile/TileEntityElectrolyticSeparator.java | 150 +- .../common/tile/TileEntityEliteFactory.java | 2 +- .../tile/TileEntityEnergizedSmelter.java | 4 +- .../common/tile/TileEntityEnergyCube.java | 154 +- .../tile/TileEntityEnrichmentChamber.java | 4 +- .../common/tile/TileEntityFactory.java | 474 ++--- .../common/tile/TileEntityGasTank.java | 110 +- .../tile/TileEntityLogisticalSorter.java | 372 ++-- .../tile/TileEntityMetallurgicInfuser.java | 406 ++--- .../common/tile/TileEntityObsidianTNT.java | 2 +- .../tile/TileEntityOsmiumCompressor.java | 10 +- .../tile/TileEntityPrecisionSawmill.java | 4 +- .../tile/TileEntityPurificationChamber.java | 18 +- .../tile/TileEntityRotaryCondensentrator.java | 266 +-- .../tile/TileEntitySalinationController.java | 292 +-- .../common/tile/TileEntitySalinationTank.java | 12 +- .../tile/TileEntitySalinationValve.java | 2 +- .../common/tile/TileEntityTeleporter.java | 264 +-- .../tile/component/TileComponentEjector.java | 108 +- .../tile/component/TileComponentUpgrade.java | 44 +- .../mekanism/common/transporter/Finder.java | 20 +- .../mekanism/common/transporter/InvStack.java | 26 +- .../common/transporter/TItemStackFilter.java | 46 +- .../common/transporter/TOreDictFilter.java | 34 +- .../common/transporter/TransporterFilter.java | 44 +- .../transporter/TransporterManager.java | 238 +-- .../transporter/TransporterPathfinder.java | 232 +-- .../common/transporter/TransporterStack.java | 122 +- common/mekanism/common/util/CableUtils.java | 358 ++-- common/mekanism/common/util/ChargeUtils.java | 30 +- .../mekanism/common/util/InventoryUtils.java | 252 +-- .../mekanism/common/util/MekanismUtils.java | 1614 ++++++++--------- common/mekanism/common/util/MinerUtils.java | 54 +- common/mekanism/common/util/PipeUtils.java | 104 +- common/mekanism/common/util/StackUtils.java | 56 +- .../common/util/TransporterUtils.java | 216 +-- .../common/voice/VoiceConnection.java | 54 +- .../common/voice/VoiceServerManager.java | 38 +- .../client/BlockRenderingHandler.java | 128 +- .../client/GeneratorsClientProxy.java | 14 +- .../client/gui/GuiBioGenerator.java | 68 +- .../client/gui/GuiHeatGenerator.java | 70 +- .../client/gui/GuiHydrogenGenerator.java | 70 +- .../client/gui/GuiSolarGenerator.java | 68 +- .../generators/client/gui/GuiWindTurbine.java | 86 +- .../model/ModelAdvancedSolarGenerator.java | 2 +- .../client/model/ModelBioGenerator.java | 6 +- .../client/model/ModelHeatGenerator.java | 276 +-- .../client/model/ModelHydrogenGenerator.java | 340 ++-- .../client/model/ModelSolarGenerator.java | 8 +- .../client/model/ModelWindTurbine.java | 10 +- .../render/RenderAdvancedSolarGenerator.java | 30 +- .../client/render/RenderBioGenerator.java | 54 +- .../client/render/RenderHeatGenerator.java | 16 +- .../render/RenderHydrogenGenerator.java | 16 +- .../client/render/RenderSolarGenerator.java | 8 +- .../client/render/RenderWindTurbine.java | 42 +- .../common/GeneratorsCommonProxy.java | 30 +- .../common/GeneratorsGuiHandler.java | 6 +- .../generators/common/MekanismGenerators.java | 66 +- .../common/block/BlockGenerator.java | 698 +++---- .../container/ContainerBioGenerator.java | 262 +-- .../container/ContainerHeatGenerator.java | 230 +-- .../container/ContainerHydrogenGenerator.java | 228 +-- .../container/ContainerSolarGenerator.java | 196 +- .../container/ContainerWindTurbine.java | 196 +- .../common/item/ItemBlockGenerator.java | 154 +- .../TileEntityAdvancedSolarGenerator.java | 12 +- .../common/tile/TileEntityBioGenerator.java | 60 +- .../common/tile/TileEntityGenerator.java | 138 +- .../common/tile/TileEntityHeatGenerator.java | 124 +- .../tile/TileEntityHydrogenGenerator.java | 74 +- .../common/tile/TileEntitySolarGenerator.java | 56 +- .../common/tile/TileEntityWindTurbine.java | 30 +- .../mekanism/tools/common/MekanismTools.java | 88 +- .../tools/item/ItemMekanismArmor.java | 34 +- .../mekanism/tools/item/ItemMekanismAxe.java | 46 +- .../mekanism/tools/item/ItemMekanismHoe.java | 128 +- .../tools/item/ItemMekanismPaxel.java | 122 +- .../tools/item/ItemMekanismPickaxe.java | 116 +- .../tools/item/ItemMekanismShovel.java | 42 +- .../tools/item/ItemMekanismSword.java | 18 +- .../mekanism/tools/item/ItemMekanismTool.java | 18 +- 468 files changed, 25218 insertions(+), 25218 deletions(-) diff --git a/common/mekanism/api/AdvancedInput.java b/common/mekanism/api/AdvancedInput.java index 189398ebe..8d2859af9 100644 --- a/common/mekanism/api/AdvancedInput.java +++ b/common/mekanism/api/AdvancedInput.java @@ -7,20 +7,20 @@ import net.minecraft.item.ItemStack; public class AdvancedInput { public ItemStack itemStack; - + public Gas gasType; - + public AdvancedInput(ItemStack item, Gas gas) { itemStack = item; gasType = gas; } - + public boolean isValid() { return itemStack != null && gasType != null; } - + public boolean matches(AdvancedInput input) { return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.stackSize >= itemStack.stackSize; diff --git a/common/mekanism/api/ChanceOutput.java b/common/mekanism/api/ChanceOutput.java index 21fceded7..97ff0b7de 100644 --- a/common/mekanism/api/ChanceOutput.java +++ b/common/mekanism/api/ChanceOutput.java @@ -8,40 +8,40 @@ import net.minecraft.item.ItemStack; public class ChanceOutput { private static Random rand = new Random(); - + public ItemStack primaryOutput; - + public ItemStack secondaryOutput; - + public double secondaryChance; - + public ChanceOutput(ItemStack primary, ItemStack secondary, double chance) { primaryOutput = primary; secondaryOutput = secondary; secondaryChance = chance; } - + public ChanceOutput(ItemStack primary) { primaryOutput = primary; } - + public boolean checkSecondary() { return rand.nextDouble() <= secondaryChance; } - + public boolean hasPrimary() { return primaryOutput != null; } - + public boolean hasSecondary() { return secondaryOutput != null; } - + public ChanceOutput copy() { return new ChanceOutput(StackUtils.copy(primaryOutput), StackUtils.copy(secondaryOutput), secondaryChance); diff --git a/common/mekanism/api/ChemicalPair.java b/common/mekanism/api/ChemicalPair.java index cd79ed24e..6ebb82e33 100644 --- a/common/mekanism/api/ChemicalPair.java +++ b/common/mekanism/api/ChemicalPair.java @@ -12,10 +12,10 @@ public class ChemicalPair { /** The left gas of this chemical input */ public GasStack leftGas; - + /** The right gas of this chemical input */ public GasStack rightGas; - + /** * Creates a chemical input with two defined gasses. * @param left - left gas @@ -26,7 +26,7 @@ public class ChemicalPair leftGas = left; rightGas = right; } - + /** * If this is a valid * @return @@ -35,7 +35,7 @@ public class ChemicalPair { return leftGas != null && rightGas != null; } - + /** * Whether or not the defined input contains the same gasses and at least the required amount of the defined gasses as this input. * @param input - input to check @@ -45,7 +45,7 @@ public class ChemicalPair { return meets(input) || meets(input.swap()); } - + /** * Swaps the right gas and left gas of this input. * @return a swapped ChemicalInput @@ -54,7 +54,7 @@ public class ChemicalPair { return new ChemicalPair(rightGas, leftGas); } - + /** * Draws the needed amount of gas from each tank. * @param leftTank - left tank to draw from @@ -73,7 +73,7 @@ public class ChemicalPair rightTank.draw(leftGas.amount, true); } } - + /** * Whether or not one of this ChemicalInput's GasStack entry's gas type is equal to the gas type of the given gas. * @param stack - stack to check @@ -85,10 +85,10 @@ public class ChemicalPair { return false; } - + return stack.isGasEqual(leftGas) || stack.isGasEqual(rightGas); } - + /** * Actual implementation of meetsInput(), performs the checks. * @param input - input to check @@ -100,12 +100,12 @@ public class ChemicalPair { return false; } - + if(input.leftGas.getGas() != leftGas.getGas() || input.rightGas.getGas() != rightGas.getGas()) { return false; } - + return input.leftGas.amount >= leftGas.amount && input.rightGas.amount >= rightGas.amount; } diff --git a/common/mekanism/api/Coord4D.java b/common/mekanism/api/Coord4D.java index 9725361ba..d219dfe51 100644 --- a/common/mekanism/api/Coord4D.java +++ b/common/mekanism/api/Coord4D.java @@ -19,14 +19,14 @@ import com.google.common.io.ByteArrayDataInput; * @author aidancbrady * */ -public class Coord4D +public class Coord4D { public int xCoord; public int yCoord; public int zCoord; - + public int dimensionId; - + /** * Creates a Coord4D WITHOUT a dimensionId. Don't use unless absolutely necessary. * @param x - x coordinate @@ -38,10 +38,10 @@ public class Coord4D xCoord = x; yCoord = y; zCoord = z; - + dimensionId = 0; } - + /** * Creates a Coord4D from the defined x, y, z, and dimension values. * @param x - x coordinate @@ -54,10 +54,10 @@ public class Coord4D xCoord = x; yCoord = y; zCoord = z; - + dimensionId = dimension; } - + /** * Gets the metadata of the block representing this Coord4D. * @param world - world this Coord4D is in @@ -67,7 +67,7 @@ public class Coord4D { return world.getBlockMetadata(xCoord, yCoord, zCoord); } - + /** * Gets the block ID of the block representing this Coord4D. * @param world - world this Coord4D is in @@ -77,7 +77,7 @@ public class Coord4D { return world.getBlockId(xCoord, yCoord, zCoord); } - + /** * Gets the TileEntity of the block representing this Coord4D. * @param world - world this Coord4D is in @@ -89,10 +89,10 @@ public class Coord4D { return null; } - + return world.getBlockTileEntity(xCoord, yCoord, zCoord); } - + /** * Gets the Block value of the block representing this Coord4D. * @param world - world this Coord4D is in @@ -104,10 +104,10 @@ public class Coord4D { return null; } - + return Block.blocksList[getBlockId(world)]; } - + /** * Writes this Coord4D's data to an NBTTagCompound. * @param nbtTags - tag compound to write to @@ -119,10 +119,10 @@ public class Coord4D nbtTags.setInteger("y", yCoord); nbtTags.setInteger("z", zCoord); nbtTags.setInteger("dimensionId", dimensionId); - + return nbtTags; } - + /** * Writes this Coord4D's data to an ArrayList for packet transfer. * @param data - the ArrayList to add the data to @@ -147,10 +147,10 @@ public class Coord4D xCoord += x; yCoord += y; zCoord += z; - + return this; } - + /** * Creates and returns a new Coord4D translated to the defined offsets of the side. * @param side - side to translate this Coord4D to @@ -160,12 +160,12 @@ public class Coord4D { return getFromSide(side, 1); } - + public Coord4D getFromSide(ForgeDirection side, int amount) { return new Coord4D(xCoord+(side.offsetX*amount), yCoord+(side.offsetY*amount), zCoord+(side.offsetZ*amount), dimensionId); } - + /** * Returns a new Coord4D from a defined TileEntity's xCoord, yCoord and zCoord values. * @param tileEntity - TileEntity at the location that will represent this Coord4D @@ -175,7 +175,7 @@ public class Coord4D { return new Coord4D(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.worldObj.provider.dimensionId); } - + /** * Returns a new Coord4D from a tag compound. * @param nbtTags - tag compound to read from @@ -185,7 +185,7 @@ public class Coord4D { return new Coord4D(nbtTags.getInteger("x"), nbtTags.getInteger("y"), nbtTags.getInteger("z"), nbtTags.getInteger("dimensionId")); } - + /** * Returns a new Coord4D from a ByteArrayDataInput. * @param dataStream - data input to read from @@ -195,7 +195,7 @@ public class Coord4D { return new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); } - + /** * Creates and returns a new Coord4D with values representing the difference between the defined Coord4D * @param other - the Coord4D to subtract from this @@ -205,7 +205,7 @@ public class Coord4D { return new Coord4D(xCoord-other.xCoord, yCoord-other.yCoord, zCoord-other.zCoord, dimensionId); } - + /** * A method used to find the ForgeDirection represented by the distance of the defined Coord4D. Most likely won't have many * applicable uses. @@ -215,7 +215,7 @@ public class Coord4D public ForgeDirection sideDifference(Coord4D other) { Coord4D diff = difference(other); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if(side.offsetX == diff.xCoord && side.offsetY == diff.yCoord && side.offsetZ == diff.zCoord) @@ -223,10 +223,10 @@ public class Coord4D return side; } } - + return ForgeDirection.UNKNOWN; } - + /** * Gets the distance to a defined Coord4D. * @param obj - the Coord4D to find the distance to @@ -234,12 +234,12 @@ public class Coord4D */ public int distanceTo(Coord4D obj) { - int subX = xCoord - obj.xCoord; - int subY = yCoord - obj.yCoord; - int subZ = zCoord - obj.zCoord; - return (int)MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); + int subX = xCoord - obj.xCoord; + int subY = yCoord - obj.yCoord; + int subZ = zCoord - obj.zCoord; + return (int)MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); } - + /** * Whether or not the defined side of this Coord4D is visible. * @param side - side to check @@ -250,7 +250,7 @@ public class Coord4D { return world.isAirBlock(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ); } - + /** * Steps this Coord4D in the defined side's offset without creating a new value. * @param side - side to step towards @@ -260,7 +260,7 @@ public class Coord4D { return translate(side.offsetX, side.offsetY, side.offsetZ); } - + /** * Whether or not the chunk this Coord4D is in exists and is loaded. * @param world - world this Coord4D is in @@ -270,7 +270,7 @@ public class Coord4D { return world.getChunkProvider().chunkExists(xCoord >> 4, zCoord >> 4); } - + /** * Gets the chunk this Coord4D is in. * @param world - world this Coord4D is in @@ -280,7 +280,7 @@ public class Coord4D { return world.getChunkFromBlockCoords(xCoord >> 4, zCoord >> 4); } - + /** * Whether or not the block this Coord4D represents is an air block. * @param world - world this Coord4D is in @@ -290,31 +290,31 @@ public class Coord4D { return world.isAirBlock(xCoord, yCoord, zCoord); } - + @Override public Coord4D clone() { return new Coord4D(xCoord, yCoord, zCoord, dimensionId); } - + @Override public String toString() { return "[Object3D: " + xCoord + ", " + yCoord + ", " + zCoord + "]"; } - + @Override public boolean equals(Object obj) { - return obj instanceof Coord4D && - ((Coord4D)obj).xCoord == xCoord && - ((Coord4D)obj).yCoord == yCoord && - ((Coord4D)obj).zCoord == zCoord && + return obj instanceof Coord4D && + ((Coord4D)obj).xCoord == xCoord && + ((Coord4D)obj).yCoord == yCoord && + ((Coord4D)obj).zCoord == zCoord && ((Coord4D)obj).dimensionId == dimensionId; } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + xCoord; diff --git a/common/mekanism/api/EnumColor.java b/common/mekanism/api/EnumColor.java index c0e9a84af..d0e4f4bd5 100644 --- a/common/mekanism/api/EnumColor.java +++ b/common/mekanism/api/EnumColor.java @@ -25,19 +25,19 @@ public enum EnumColor PINK("\u00a7d", "pink", new int[] {255, 85, 255}, 9), YELLOW("\u00a7e", "yellow", new int[] {255, 255, 85}, 11), WHITE("\u00a7f", "white", new int[] {255, 255, 255}, 15); - + public static EnumColor[] DYES = new EnumColor[] {BLACK, DARK_RED, DARK_GREEN, null, DARK_BLUE, PURPLE, DARK_AQUA, GREY, DARK_GREY, PINK, BRIGHT_GREEN, YELLOW, INDIGO, RED, ORANGE, WHITE}; - + /** The color code that will be displayed */ public final String code; - + public final int[] rgbCode; - + public final int mcMeta; - + /** A friendly name of the color. */ public String unlocalizedName; - + private EnumColor(String s, String n, int[] rgb, int meta) { code = s; @@ -45,7 +45,7 @@ public enum EnumColor rgbCode = rgb; mcMeta = meta; } - + /** * Gets the localized name of this color by translating the unlocalized name. * @return localized name @@ -54,7 +54,7 @@ public enum EnumColor { return StatCollector.translateToLocal("color." + unlocalizedName); } - + /** * Gets the name of this color with it's color prefix code. * @return the color's name and color prefix @@ -63,7 +63,7 @@ public enum EnumColor { return code + getLocalizedName(); } - + /** * Gets the 0-1 of this color's RGB value by dividing by 255 (used for OpenGL coloring). * @param index - R:0, G:1, B:2 @@ -73,7 +73,7 @@ public enum EnumColor { return (float)rgbCode[index]/255F; } - + /** * Gets the value of this color mapped to MC in-game item colors present in dyes and wool. * @return mc meta value @@ -82,7 +82,7 @@ public enum EnumColor { return mcMeta; } - + @Override public String toString() { diff --git a/common/mekanism/api/IClientTicker.java b/common/mekanism/api/IClientTicker.java index 3e306b8bd..228897370 100644 --- a/common/mekanism/api/IClientTicker.java +++ b/common/mekanism/api/IClientTicker.java @@ -3,6 +3,6 @@ package mekanism.api; public interface IClientTicker { public void clientTick(); - + public boolean needsTicks(); } diff --git a/common/mekanism/api/ItemInfo.java b/common/mekanism/api/ItemInfo.java index 819c5390f..27cb2c431 100644 --- a/common/mekanism/api/ItemInfo.java +++ b/common/mekanism/api/ItemInfo.java @@ -3,31 +3,31 @@ package mekanism.api; import net.minecraft.item.ItemStack; public class ItemInfo -{ +{ public int id; public int meta; - + public ItemInfo(int i, int j) { id = i; meta = j; } - + public static ItemInfo get(ItemStack stack) { return new ItemInfo(stack.itemID, stack.getItemDamage()); } - + @Override public boolean equals(Object obj) { - return obj instanceof ItemInfo && - ((ItemInfo)obj).id == id && + return obj instanceof ItemInfo && + ((ItemInfo)obj).id == id && ((ItemInfo)obj).meta == meta; } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + id; diff --git a/common/mekanism/api/ItemRetriever.java b/common/mekanism/api/ItemRetriever.java index 277bdd7f7..e18f62a30 100644 --- a/common/mekanism/api/ItemRetriever.java +++ b/common/mekanism/api/ItemRetriever.java @@ -10,35 +10,35 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public final class ItemRetriever +public final class ItemRetriever { /** The 'Mekanism' class that items and blocks are retrieved from. */ private static Class Mekanism; - + /** * Attempts to retrieve an ItemStack of an item or block with the declared identifier. - * + * * Mekanism identifiers follow an easy-to-remember pattern. All identifiers - * are identical to the String returned by 'getItemName().' None include spaces, - * and all start with a capital letter. The name that shows up in-game can be - * stripped down to identifier form by removing spaces and all non-alphabetic + * are identical to the String returned by 'getItemName().' None include spaces, + * and all start with a capital letter. The name that shows up in-game can be + * stripped down to identifier form by removing spaces and all non-alphabetic * characters (,./'=-_). Below is an example: - * + * * ItemStack enrichedAlloy = ItemRetriever.getItem("EnrichedAlloy"); - * + * * The same also works for blocks. - * + * * ItemStack refinedObsidian = ItemRetriever.getItem("RefinedObsidian"); - * - * Note that for items or blocks that have specific metadata you will need to create + * + * Note that for items or blocks that have specific metadata you will need to create * a new ItemStack with that specified value, as this will only return an ItemStack * with the meta value '0.' - * + * * Make sure you run this in or after FMLPostInitializationEvent runs, because most - * items are registered when FMLInitializationEvent runs. However, some items ARE + * items are registered when FMLInitializationEvent runs. However, some items ARE * registered later in order to hook into other mods. In a rare circumstance you may * have to add "after:Mekanism" in the @Mod 'dependencies' annotation. - * + * * @param identifier - a String to be searched in the 'Mekanism' class * @return an ItemStack of the declared identifier, otherwise null. */ @@ -49,9 +49,9 @@ public final class ItemRetriever { Mekanism = Class.forName("mekanism.common.Mekanism"); } - + Object ret = Mekanism.getField(identifier).get(null); - + if(ret instanceof Item) { return new ItemStack((Item)ret, 1); diff --git a/common/mekanism/api/ListUtils.java b/common/mekanism/api/ListUtils.java index be7118b67..fb319cee8 100644 --- a/common/mekanism/api/ListUtils.java +++ b/common/mekanism/api/ListUtils.java @@ -164,69 +164,69 @@ public class ListUtils { return (List)Arrays.asList(set.toArray()); } - + public static List asList(V... values) { return (List)Arrays.asList(values); } - + public static double[] splitDouble(int size, double num) { double[] split = new double[size]; - + for(int i = 0; i < size; i++) { double remain = num%size; double ret = (num-remain)/size; ret += remain; - + split[i] = ret; num -= remain; } - + return split; } - + public static double[] percent(double[] values) { double[] ret = new double[values.length]; double total = 0; - + for(double d : values) total += d; - + for(int i = 0; i < values.length; i++) { ret[i] = values[i]/total; } - + return ret; } - + public static int[] calcPercentInt(double[] percent, int val) { int[] ret = new int[percent.length]; - + for(int i = 0; i < percent.length; i++) { ret[i] = (int)Math.round(val*percent[i]); } - + int newTotal = 0; for(int i : ret) newTotal += i; - + int diff = val-newTotal; - + if(diff != val) { for(int i = 0; i < ret.length; i++) { int num = ret[i]; - + if(diff < 0 && num == 0) { continue; } - + if(diff > 0) { ret[i]++; @@ -237,46 +237,46 @@ public class ListUtils ret[i]--; diff++; } - + if(diff == 0) { return ret; } } } - + return ret; } - + public static int[] splitInt(int size, int num) { int[] split = new int[size]; - + for(int i = 0; i < size; i++) { int remain = num%size; int ret = (num-remain)/size; ret += remain; - + split[i] = ret; num -= remain; } - + return split; } - + public static double[] percent(int[] values) { double[] ret = new double[values.length]; double total = 0; - + for(double d : values) total += d; - + for(int i = 0; i < values.length; i++) { ret[i] = values[i]/total; } - + return ret; } } diff --git a/common/mekanism/api/MekanismAPI.java b/common/mekanism/api/MekanismAPI.java index a53466ec9..6818071a6 100644 --- a/common/mekanism/api/MekanismAPI.java +++ b/common/mekanism/api/MekanismAPI.java @@ -10,7 +10,7 @@ public class MekanismAPI { //Add a BlockInfo value here if you don't want a certain block to be picked up by cardboard boxes private static Set cardboardBoxIgnore = new HashSet(); - + public static boolean isBlockCompatible(int id, int meta) { for(ItemInfo i : cardboardBoxIgnore) @@ -20,24 +20,24 @@ public class MekanismAPI return false; } } - + return true; } - + public static void addBoxBlacklist(int id, int meta) { cardboardBoxIgnore.add(new ItemInfo(id, meta)); } - + public static void removeBoxBlacklist(int id, int meta) { cardboardBoxIgnore.remove(new ItemInfo(id, meta)); } - + public static Set getBoxIgnore() { return cardboardBoxIgnore; } - + public static class BoxBlacklistEvent extends Event {} } diff --git a/common/mekanism/api/Pos3D.java b/common/mekanism/api/Pos3D.java index 0b9281a0d..28b4499d6 100644 --- a/common/mekanism/api/Pos3D.java +++ b/common/mekanism/api/Pos3D.java @@ -14,19 +14,19 @@ public class Pos3D public double xPos; public double yPos; public double zPos; - + public Pos3D() { this(0, 0, 0); } - + public Pos3D(double x, double y, double z) { xPos = x; yPos = y; zPos = z; } - + /** * Creates a Pos3D with an entity's posX, posY, and posZ values. * @param entity - entity to create the Pos3D from @@ -35,7 +35,7 @@ public class Pos3D { this(entity.posX, entity.posY, entity.posZ); } - + /** * Creates a Pos3D with a TileEntity's xCoord, yCoord and zCoord values. * @param tileEntity - TileEntity to create the Pos3D from @@ -44,7 +44,7 @@ public class Pos3D { this(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); } - + /** * Creates and returns a Pos3D with values representing the difference between this and the Pos3D in the parameters. * @param pos - Pos3D to subtract @@ -54,7 +54,7 @@ public class Pos3D { return new Pos3D(xPos-pos.xPos, yPos-pos.yPos, zPos-pos.zPos); } - + /** * Creates a new Pos3D from the motion of an entity. * @param entity @@ -64,7 +64,7 @@ public class Pos3D { return new Pos3D(entity.motionX, entity.motionY, entity.motionZ); } - + /** * Translates this Pos3D by the defined values. * @param x - amount to translate on the x axis @@ -77,10 +77,10 @@ public class Pos3D xPos += x; yPos += y; zPos += z; - + return this; } - + /** * Performs the same operation as translate(x, y, z), but with a Pos3D value instead. * @param pos - Pos3D value to translate by @@ -90,7 +90,7 @@ public class Pos3D { return translate(pos.xPos, pos.yPos, pos.zPos); } - + /** * Returns the distance between this and the defined Pos3D. * @param pos - the Pos3D to find the distance to @@ -98,12 +98,12 @@ public class Pos3D */ public double distance(Pos3D pos) { - double subX = xPos - pos.xPos; - double subY = yPos - pos.yPos; - double subZ = zPos - pos.zPos; - return MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); + double subX = xPos - pos.xPos; + double subY = yPos - pos.yPos; + double subZ = zPos - pos.zPos; + return MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); } - + /** * Rotates this Pos3D by the defined yaw value. * @param yaw - yaw to rotate by @@ -121,10 +121,10 @@ public class Pos3D xPos = x * Math.cos(yawRadians) - z * Math.sin(yawRadians); zPos = x * Math.sin(yawRadians) + z * Math.cos(yawRadians); } - + return this; } - + /** * Scales this Pos3D by the defined x, y, an z values. * @param x - x value to scale by @@ -137,10 +137,10 @@ public class Pos3D xPos *= x; yPos *= y; zPos *= z; - + return this; } - + /** * Performs the same operation as scale(x, y, z), but with a value representing all three dimensions. * @param scale - value to scale by @@ -150,30 +150,30 @@ public class Pos3D { return scale(scale, scale, scale); } - + @Override public Pos3D clone() { return new Pos3D(xPos, yPos, zPos); } - + @Override public String toString() { return "[Pos3D: " + xPos + ", " + yPos + ", " + zPos + "]"; } - + @Override public boolean equals(Object obj) { - return obj instanceof Pos3D && - ((Pos3D)obj).xPos == xPos && - ((Pos3D)obj).yPos == yPos && + return obj instanceof Pos3D && + ((Pos3D)obj).xPos == xPos && + ((Pos3D)obj).yPos == yPos && ((Pos3D)obj).zPos == zPos; } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + new Double(xPos).hashCode(); diff --git a/common/mekanism/api/RecipeHelper.java b/common/mekanism/api/RecipeHelper.java index 075c9b75d..e0087f316 100644 --- a/common/mekanism/api/RecipeHelper.java +++ b/common/mekanism/api/RecipeHelper.java @@ -12,7 +12,7 @@ import net.minecraftforge.fluids.FluidStack; * @author AidanBrady * */ -public final class RecipeHelper +public final class RecipeHelper { /** * Add an Enrichment Chamber recipe. @@ -29,7 +29,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add an Osmium Compressor recipe. * @param input - input ItemStack @@ -45,7 +45,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Combiner recipe. * @param input - input ItemStack @@ -61,7 +61,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Crusher recipe. * @param input - input ItemStack @@ -77,7 +77,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Purification Chamber recipe. * @param input - input ItemStack @@ -93,7 +93,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Chemical Oxidizer recipe. * @param input - input ItemStack @@ -109,7 +109,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Chemical Infuser recipe. * @param input - input ChemicalInput @@ -125,7 +125,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Precision Sawmill recipe. * @param input - input ItemStack @@ -141,7 +141,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Chemical Injection Chamber recipe. * @param input - input AdvancedInput @@ -157,7 +157,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add an Electrolytic Separator recipe. * @param input - input FluidStack @@ -173,7 +173,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Chemical Dissolution Chamber recipe. * @param input - input ItemStack @@ -189,7 +189,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Chemical Washer recipe. * @param input - input GasStack @@ -205,7 +205,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Electrolytic Separator recipe. * @param input - input GasStack @@ -221,7 +221,7 @@ public final class RecipeHelper System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); } } - + /** * Add a Metallurgic Infuser recipe. * @param input - input Infusion diff --git a/common/mekanism/api/TabProxy.java b/common/mekanism/api/TabProxy.java index 0aa14c969..94238a221 100644 --- a/common/mekanism/api/TabProxy.java +++ b/common/mekanism/api/TabProxy.java @@ -11,7 +11,7 @@ public final class TabProxy { /** The 'Mekanism' class where the tab instance is stored. */ public static Class Mekanism; - + /** * Attempts to get the Mekanism creative tab instance from the 'Mekanism' class. Will return * the tab if the mod is loaded, but otherwise will return the defined 'preferred' creative tab. This way @@ -25,14 +25,14 @@ public final class TabProxy { Mekanism = Class.forName("mekanism.common.Mekanism"); } - + Object ret = Mekanism.getField("tabMekanism").get(null); - + if(ret instanceof CreativeTabs) { return (CreativeTabs)ret; } - + return preferred; } catch(Exception e) { System.err.println("[Mekanism] Error retrieving Mekanism creative tab."); diff --git a/common/mekanism/api/energy/EnergizedItemManager.java b/common/mekanism/api/energy/EnergizedItemManager.java index 254760923..165bdf608 100644 --- a/common/mekanism/api/energy/EnergizedItemManager.java +++ b/common/mekanism/api/energy/EnergizedItemManager.java @@ -17,20 +17,20 @@ public class EnergizedItemManager if(itemStack.getItem() instanceof IEnergizedItem) { IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); - + if(energizedItem.canSend(itemStack)) { double energyToUse = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getEnergy(itemStack), amount)); energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) - energyToUse); - + return energyToUse; } } } - + return 0; } - + /** * Charges an IEnergizedItem with the defined amount of energy. * @param itemStack - ItemStack to charge @@ -44,17 +44,17 @@ public class EnergizedItemManager if(itemStack.getItem() instanceof IEnergizedItem) { IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); - + if(energizedItem.canReceive(itemStack)) { double energyToSend = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getMaxEnergy(itemStack) - energizedItem.getEnergy(itemStack), amount)); energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) + energyToSend); - + return energyToSend; } } } - + return 0; } } diff --git a/common/mekanism/api/energy/ICableOutputter.java b/common/mekanism/api/energy/ICableOutputter.java index fedda2b9f..8228040ca 100644 --- a/common/mekanism/api/energy/ICableOutputter.java +++ b/common/mekanism/api/energy/ICableOutputter.java @@ -7,7 +7,7 @@ import net.minecraftforge.common.ForgeDirection; * @author AidanBrady * */ -public interface ICableOutputter +public interface ICableOutputter { /** * Whether or not this block can output to a cable on a specific side. diff --git a/common/mekanism/api/energy/IEnergizedItem.java b/common/mekanism/api/energy/IEnergizedItem.java index 2e90ed9be..5b784de70 100644 --- a/common/mekanism/api/energy/IEnergizedItem.java +++ b/common/mekanism/api/energy/IEnergizedItem.java @@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack; * @author aidancbrady * */ -public interface IEnergizedItem +public interface IEnergizedItem { /** * Gets and returns the amount of energy stored in this item. @@ -15,42 +15,42 @@ public interface IEnergizedItem * @return energy stored */ public double getEnergy(ItemStack itemStack); - + /** * Sets this item's stored energy value to a new amount. * @param itemStack - the ItemStack who's energy value is to be change * @param amount - new amount of energy */ public void setEnergy(ItemStack itemStack, double amount); - + /** * Gets and returns this item's maximum amount of energy that can be stored. * @param itemStack - the ItemStack to check * @return maximum energy */ public double getMaxEnergy(ItemStack itemStack); - + /** * Gets and returns how much energy this item can transfer to and from charging slots. * @param itemStack - the ItemStack to check * @return transfer amount */ public double getMaxTransfer(ItemStack itemStack); - + /** * Gets and returns whether or not this item can receive energy from a charging slot. * @param itemStack - the ItemStack to check * @return if the item can receive energy */ public boolean canReceive(ItemStack itemStack); - + /** * Gets and returns whether or not this item can send energy to a charging slot. * @param itemStack - the ItemStack to check * @return if the item can send energy */ public boolean canSend(ItemStack itemStack); - + /** * Returns whether or not this item contains metadata-specific subtypes instead of using metadata for damage display. * @return if the item contains metadata-specific subtypes diff --git a/common/mekanism/api/energy/IStrictEnergyAcceptor.java b/common/mekanism/api/energy/IStrictEnergyAcceptor.java index 6d5224bde..deb550df2 100644 --- a/common/mekanism/api/energy/IStrictEnergyAcceptor.java +++ b/common/mekanism/api/energy/IStrictEnergyAcceptor.java @@ -15,7 +15,7 @@ public interface IStrictEnergyAcceptor extends IStrictEnergyStorage * @return energy used */ public double transferEnergyToAcceptor(ForgeDirection side, double amount); - + /** * Whether or not this tile entity accepts energy from a certain side. * @param side - side to check diff --git a/common/mekanism/api/energy/IStrictEnergyStorage.java b/common/mekanism/api/energy/IStrictEnergyStorage.java index 5b538aa3f..fd560fa18 100644 --- a/common/mekanism/api/energy/IStrictEnergyStorage.java +++ b/common/mekanism/api/energy/IStrictEnergyStorage.java @@ -5,20 +5,20 @@ package mekanism.api.energy; * @author aidancbrady * */ -public interface IStrictEnergyStorage +public interface IStrictEnergyStorage { /** * Gets the amount of energy this TileEntity is currently storing. * @return stored energy */ public double getEnergy(); - + /** * Sets the amount of stored energy of this TileEntity to a new amount. * @param energy - new energy value */ public void setEnergy(double energy); - + /** * Gets the maximum amount of energy this TileEntity can store. * @return maximum energy diff --git a/common/mekanism/api/gas/Gas.java b/common/mekanism/api/gas/Gas.java index e1aafbfeb..bf7e4b0b2 100644 --- a/common/mekanism/api/gas/Gas.java +++ b/common/mekanism/api/gas/Gas.java @@ -14,15 +14,15 @@ import net.minecraftforge.fluids.FluidRegistry; public class Gas { private String name; - + private String unlocalizedName; - + private Fluid fluid; - + private Icon icon; - + private boolean visible = true; - + /** * Creates a new Gas object with a defined name or key value. * @param s - name or key to associate this Gas with @@ -31,7 +31,7 @@ public class Gas { unlocalizedName = name = s; } - + /** * Gets the name (key) of this Gas. This is NOT a translated or localized display name. * @return this Gas's name or key @@ -40,7 +40,7 @@ public class Gas { return name; } - + /** * Whether or not this is a visible gas. * @return if this gas is visible @@ -49,7 +49,7 @@ public class Gas { return visible; } - + /** * Sets this gas's "visible" state to a new value. Setting it to 'false' will treat this gas as an internal gas, and it will not be displayed or accessed by other mods. * @param v - new visible state @@ -58,10 +58,10 @@ public class Gas public Gas setVisible(boolean v) { visible = v; - + return this; } - + /** * Gets the unlocalized name of this Gas. * @return this Gas's unlocalized name @@ -70,7 +70,7 @@ public class Gas { return "gas." + unlocalizedName; } - + /** * Translates this Gas's unlocalized name and returns it as localized. * @return this Gas's localized name @@ -79,7 +79,7 @@ public class Gas { return StatCollector.translateToLocal(getUnlocalizedName()); } - + /** * Sets the unlocalized name of this Gas. * @param s - unlocalized name to set @@ -88,10 +88,10 @@ public class Gas public Gas setUnlocalizedName(String s) { unlocalizedName = s; - + return this; } - + /** * Gets the Icon associated with this Gas. * @return associated Icon @@ -100,7 +100,7 @@ public class Gas { return icon; } - + /** * Sets this gas's icon. * @param i - Icon to associate with this Gas @@ -109,15 +109,15 @@ public class Gas public Gas setIcon(Icon i) { icon = i; - + if(hasFluid()) { fluid.setIcons(getIcon()); } - + return this; } - + /** * Gets the ID associated with this gas. * @return the associated gas ID @@ -126,7 +126,7 @@ public class Gas { return GasRegistry.getGasID(this); } - + /** * Writes this Gas to a defined tag compound. * @param nbtTags - tag compound to write this Gas to @@ -135,10 +135,10 @@ public class Gas public NBTTagCompound write(NBTTagCompound nbtTags) { nbtTags.setString("gasName", getName()); - + return nbtTags; } - + /** * Returns the Gas stored in the defined tag compound. * @param nbtTags - tag compound to get the Gas from @@ -150,10 +150,10 @@ public class Gas { return null; } - + return GasRegistry.getGas(nbtTags.getString("gasName")); } - + /** * Whether or not this Gas has an associated fluid. * @return if this gas has a fluid @@ -162,7 +162,7 @@ public class Gas { return fluid != null; } - + /** * Gets the fluid associated with this Gas. * @return fluid associated with this gas @@ -171,7 +171,7 @@ public class Gas { return fluid; } - + /** * Registers a new fluid out of this Gas or gets one from the FluidRegistry. * @return this Gas object @@ -190,10 +190,10 @@ public class Gas fluid = FluidRegistry.getFluid(getName()); } } - + return this; } - + @Override public String toString() { diff --git a/common/mekanism/api/gas/GasNetwork.java b/common/mekanism/api/gas/GasNetwork.java index 7747ce568..b8ab96d85 100644 --- a/common/mekanism/api/gas/GasNetwork.java +++ b/common/mekanism/api/gas/GasNetwork.java @@ -28,31 +28,31 @@ import cpw.mods.fml.common.FMLCommonHandler; public class GasNetwork extends DynamicNetwork { public int transferDelay = 0; - + public boolean didTransfer; public boolean prevTransfer; - + public float gasScale; - + public Gas refGas; - + public GasStack gasStored; public int prevStored; public int prevTransferAmount = 0; - + public GasNetwork(IGridTransmitter... varPipes) { transmitters.addAll(Arrays.asList(varPipes)); register(); } - + public GasNetwork(Collection> collection) { transmitters.addAll(collection); register(); } - + public GasNetwork(Set networks) { for(GasNetwork net : networks) @@ -66,7 +66,7 @@ public class GasNetwork extends DynamicNetwork gasScale = net.gasScale; refGas = net.refGas; gasStored = net.gasStored; - + net.gasScale = 0; net.refGas = null; net.gasStored = null; @@ -82,116 +82,116 @@ public class GasNetwork extends DynamicNetwork else { gasStored.amount += net.gasStored.amount; } - + net.gasStored = null; } } - + addAllTransmitters(net.transmitters); net.deregister(); } } - + gasScale = getScale(); - + refresh(); register(); } - - @Override - public void onNetworksCreated(List networks) - { + + @Override + public void onNetworksCreated(List networks) + { if(gasStored != null && FMLCommonHandler.instance().getEffectiveSide().isServer()) { - int[] caps = new int[networks.size()]; - int cap = 0; - - for(GasNetwork network : networks) - { - caps[networks.indexOf(network)] = network.getCapacity(); - cap += network.getCapacity(); - } - - gasStored.amount = Math.min(cap, gasStored.amount); - - int[] values = ListUtils.calcPercentInt(ListUtils.percent(caps), gasStored.amount); - - for(GasNetwork network : networks) - { - int index = networks.indexOf(network); - - if(values[index] > 0) - { - network.gasStored = new GasStack(gasStored.getGas(), values[index]); - network.refGas = gasStored.getGas(); - } - } + int[] caps = new int[networks.size()]; + int cap = 0; + + for(GasNetwork network : networks) + { + caps[networks.indexOf(network)] = network.getCapacity(); + cap += network.getCapacity(); + } + + gasStored.amount = Math.min(cap, gasStored.amount); + + int[] values = ListUtils.calcPercentInt(ListUtils.percent(caps), gasStored.amount); + + for(GasNetwork network : networks) + { + int index = networks.indexOf(network); + + if(values[index] > 0) + { + network.gasStored = new GasStack(gasStored.getGas(), values[index]); + network.refGas = gasStored.getGas(); + } + } } - + gasScale = 0; refGas = null; gasStored = null; - } - + } + public synchronized int getGasNeeded() { return getCapacity()-(gasStored != null ? gasStored.amount : 0); } - + public synchronized int tickEmit(GasStack stack) { List availableAcceptors = Arrays.asList(getAcceptors(stack.getGas()).toArray()); - + Collections.shuffle(availableAcceptors); - + int toSend = stack.amount; int prevSending = toSend; - + if(!availableAcceptors.isEmpty()) { int divider = availableAcceptors.size(); int remaining = toSend % divider; int sending = (toSend-remaining)/divider; - + for(Object obj : availableAcceptors) { if(obj instanceof IGasHandler) { IGasHandler acceptor = (IGasHandler)obj; - + int currentSending = sending; - + if(remaining > 0) { currentSending++; remaining--; } - + toSend -= acceptor.receiveGas(acceptorDirections.get(acceptor).getOpposite(), new GasStack(stack.getGas(), currentSending)); } } } - + int sent = prevSending-toSend; - + if(sent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer()) { didTransfer = true; transferDelay = 2; } - + return sent; } - + public synchronized int emit(GasStack stack) { if(gasStored != null && gasStored.getGas() != stack.getGas()) { return 0; } - + int toUse = Math.min(getGasNeeded(), stack.amount); - + if(gasStored == null) { gasStored = stack.copy(); @@ -200,15 +200,15 @@ public class GasNetwork extends DynamicNetwork else { gasStored.amount += toUse; } - + return toUse; } - + @Override public void onUpdate() { super.onUpdate(); - + if(FMLCommonHandler.instance().getEffectiveSide().isServer()) { prevTransferAmount = 0; @@ -220,29 +220,29 @@ public class GasNetwork extends DynamicNetwork else { transferDelay--; } - + int stored = gasStored != null ? gasStored.amount : 0; - + if(stored != prevStored) { needsUpdate = true; } - + prevStored = stored; - + if(didTransfer != prevTransfer || needsUpdate) { MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, gasStored, didTransfer)); needsUpdate = false; } - + prevTransfer = didTransfer; - + if(gasStored != null) { prevTransferAmount = tickEmit(gasStored); gasStored.amount -= prevTransferAmount; - + if(gasStored.amount <= 0) { gasStored = null; @@ -250,14 +250,14 @@ public class GasNetwork extends DynamicNetwork } } } - + @Override public void clientTick() { super.clientTick(); - + gasScale = Math.max(gasScale, getScale()); - + if(didTransfer && gasScale < 1) { gasScale = Math.max(getScale(), Math.min(1, gasScale+0.02F)); @@ -265,33 +265,33 @@ public class GasNetwork extends DynamicNetwork else if(!didTransfer && gasScale > 0) { gasScale = Math.max(getScale(), Math.max(0, gasScale-0.02F)); - + if(gasScale == 0) { gasStored = null; } } } - + @Override public synchronized Set getAcceptors(Object... data) { Gas type = (Gas)data[0]; Set toReturn = new HashSet(); - + for(IGasHandler acceptor : possibleAcceptors) { if(acceptorDirections.get(acceptor) == null) { continue; } - + if(acceptor.canReceiveGas(acceptorDirections.get(acceptor).getOpposite(), type)) { toReturn.add(acceptor); } } - + return toReturn; } @@ -300,7 +300,7 @@ public class GasNetwork extends DynamicNetwork { Set> iterTubes = (Set>)transmitters.clone(); Iterator> it = iterTubes.iterator(); - + possibleAcceptors.clear(); acceptorDirections.clear(); @@ -317,15 +317,15 @@ public class GasNetwork extends DynamicNetwork conductor.setTransmitterNetwork(this); } } - + for(IGridTransmitter transmitter : transmitters) { IGasHandler[] acceptors = GasTransmission.getConnectedAcceptors((TileEntity)transmitter); - + for(IGasHandler acceptor : acceptors) { ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor)); - + if(side != null && acceptor != null && !(acceptor instanceof IGridTransmitter) && transmitter.canConnectToAcceptor(side, true)) { possibleAcceptors.add(acceptor); @@ -351,10 +351,10 @@ public class GasNetwork extends DynamicNetwork public static class GasTransferEvent extends Event { public final GasNetwork gasNetwork; - + public final GasStack transferType; public final boolean didTransfer; - + public GasTransferEvent(GasNetwork network, GasStack type, boolean did) { gasNetwork = network; @@ -362,50 +362,50 @@ public class GasNetwork extends DynamicNetwork didTransfer = did; } } - + public float getScale() { return Math.min(1, (gasStored == null || getCapacity() == 0 ? 0 : (float)gasStored.amount/getCapacity())); } - + @Override public String toString() { return "[GasNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors."; } - + @Override public boolean canMerge(List> networks) { Gas found = null; - + for(ITransmitterNetwork network : networks) { if(network instanceof GasNetwork) { GasNetwork net = (GasNetwork)network; - + if(net.gasStored != null) { if(found != null && found != net.gasStored.getGas()) { return false; } - + found = net.gasStored.getGas(); } } } - + return true; } - + @Override - protected GasNetwork create(IGridTransmitter... varTransmitters) + protected GasNetwork create(IGridTransmitter... varTransmitters) { GasNetwork network = new GasNetwork(varTransmitters); network.refGas = refGas; - + if(gasStored != null) { if(network.gasStored == null) @@ -416,21 +416,21 @@ public class GasNetwork extends DynamicNetwork network.gasStored.amount += gasStored.amount; } } - + network.gasScale = network.getScale(); gasScale = 0; refGas = null; gasStored = null; - + return network; } @Override - protected GasNetwork create(Collection> collection) + protected GasNetwork create(Collection> collection) { GasNetwork network = new GasNetwork(collection); network.refGas = refGas; - + if(gasStored != null) { if(network.gasStored == null) @@ -441,24 +441,24 @@ public class GasNetwork extends DynamicNetwork network.gasStored.amount += gasStored.amount; } } - + network.gasScale = network.getScale(); - + return network; } @Override - protected GasNetwork create(Set networks) + protected GasNetwork create(Set networks) { return new GasNetwork(networks); } - + @Override public TransmissionType getTransmissionType() { return TransmissionType.GAS; } - + @Override public String getNeeded() { @@ -470,7 +470,7 @@ public class GasNetwork extends DynamicNetwork { return gasStored != null ? gasStored.getGas().getLocalizedName() + " (" + gasStored.amount + ")" : "None"; } - + @Override public String getFlow() { diff --git a/common/mekanism/api/gas/GasRegistry.java b/common/mekanism/api/gas/GasRegistry.java index 2075b000d..25db9667e 100644 --- a/common/mekanism/api/gas/GasRegistry.java +++ b/common/mekanism/api/gas/GasRegistry.java @@ -8,7 +8,7 @@ import net.minecraftforge.fluids.Fluid; public class GasRegistry { private static ArrayList registeredGasses = new ArrayList(); - + /** * Register a new gas into GasRegistry. * @param gas - Gas to register @@ -20,12 +20,12 @@ public class GasRegistry { return null; } - + registeredGasses.add(gas); - + return getGas(gas.getName()); } - + /** * Gets the gas associated with the defined ID. * @param id - ID to check @@ -37,10 +37,10 @@ public class GasRegistry { return null; } - + return registeredGasses.get(id); } - + /** * Gets the gas associated with the defined fluid. * @param f - fluid to check @@ -55,10 +55,10 @@ public class GasRegistry return gas; } } - + return null; } - + /** * Whether or not GasRegistry contains a gas with the specified name * @param name - name to check @@ -68,7 +68,7 @@ public class GasRegistry { return getGas(name) != null; } - + /** * Gets the list of all gasses registered in GasRegistry. * @return a cloned list of all registered gasses @@ -77,7 +77,7 @@ public class GasRegistry { return (List)registeredGasses.clone(); } - + /** * Gets the gas associated with the specified name. * @param name - name of the gas to get @@ -92,10 +92,10 @@ public class GasRegistry return gas; } } - + return null; } - + /** * Gets the gas ID of a specified gas. * @param gas - gas to get the ID from @@ -107,7 +107,7 @@ public class GasRegistry { return -1; } - + return registeredGasses.indexOf(gas); } } diff --git a/common/mekanism/api/gas/GasStack.java b/common/mekanism/api/gas/GasStack.java index 5314c12a1..0f3f40bfb 100644 --- a/common/mekanism/api/gas/GasStack.java +++ b/common/mekanism/api/gas/GasStack.java @@ -10,9 +10,9 @@ import net.minecraft.nbt.NBTTagCompound; public class GasStack { private Gas type; - + public int amount; - + /** * Creates a new GasStack with a defined gas ID and quantity. * @param id - gas ID to associate this GasStack to, will perform a GasRegistry lookup in the constructor @@ -23,7 +23,7 @@ public class GasStack type = GasRegistry.getGas(id); amount = quantity; } - + /** * Creates a new GasStack with a defined Gas type and quantity. * @param gas - gas type of the stack @@ -34,9 +34,9 @@ public class GasStack type = gas; amount = quantity; } - + private GasStack() {} - + /** * Gets the Gas type of this GasStack. * @return this GasStack's Gas type @@ -45,7 +45,7 @@ public class GasStack { return type; } - + /** * Writes this GasStack to a defined tag compound. * @param nbtTags - tag compound to write to @@ -55,10 +55,10 @@ public class GasStack { type.write(nbtTags); nbtTags.setInteger("amount", amount); - + return nbtTags; } - + /** * Reads this GasStack's data from a defined tag compound. * @param nbtTags - tag compound to read from @@ -68,7 +68,7 @@ public class GasStack type = Gas.readFromNBT(nbtTags); amount = nbtTags.getInteger("amount"); } - + /** * Returns the GasStack stored in the defined tag compound, or null if it doesn't exist. * @param nbtTags - tag compound to read from @@ -80,18 +80,18 @@ public class GasStack { return null; } - + GasStack stack = new GasStack(); stack.read(nbtTags); - + if(stack.getGas() == null) { return null; } - + return stack; } - + /** * Returns a copied form of this GasStack. * @return copied GasStack @@ -100,7 +100,7 @@ public class GasStack { return new GasStack(type, amount); } - + /** * Whether or not this GasStack's gas type is equal to the other defined GasStack. * @param stack - GasStack to check @@ -110,7 +110,7 @@ public class GasStack { return stack != null && getGas() == stack.getGas(); } - + @Override public String toString() { diff --git a/common/mekanism/api/gas/GasTank.java b/common/mekanism/api/gas/GasTank.java index 10614ef69..7c0ba3ba7 100644 --- a/common/mekanism/api/gas/GasTank.java +++ b/common/mekanism/api/gas/GasTank.java @@ -10,11 +10,11 @@ import net.minecraft.nbt.NBTTagCompound; public class GasTank { public GasStack stored; - + private int maxGas; - + private GasTank() {} - + /** * Creates a tank with a defined capacity. * @param max - the maximum amount of gas this GasTank can hold @@ -23,7 +23,7 @@ public class GasTank { maxGas = max; } - + /** * Sets this tank's GasStack value to a new value. Will cap the amount to this GasTank's capacity. * @param stack - value to set this tank's GasStack value to @@ -31,13 +31,13 @@ public class GasTank public void setGas(GasStack stack) { stored = stack; - + if(stored != null) { stored.amount = Math.min(getMaxGas(), stored.amount); } } - + /** * Draws a specified amount of gas out of this tank. * @param amount - amount to draw @@ -50,27 +50,27 @@ public class GasTank { return null; } - + GasStack ret = new GasStack(getGas().getGas(), Math.min(getStored(), amount)); - + if(ret.amount > 0) { if(doDraw) { stored.amount -= ret.amount; - + if(stored.amount <= 0) { stored = null; } } - + return ret; } - + return null; } - + /** * Adds a specified amount of gas to this tank. * @param amount - the GasStack for this tank to receive @@ -83,9 +83,9 @@ public class GasTank { return 0; } - + int toFill = Math.min(getMaxGas()-getStored(), amount.amount); - + if(doReceive) { if(stored == null) @@ -96,10 +96,10 @@ public class GasTank stored.amount = Math.min(getMaxGas(), getStored()+amount.amount); } } - + return toFill; } - + /** * If this GasTank can receive the specified type of gas. Will return false if this tank does not need anymore gas. * @param gas - gas to check @@ -111,10 +111,10 @@ public class GasTank { return false; } - + return true; } - + /** * If this GasTank can receive the specified type of gas. Will return TRUE if this tank does not need anymore gas. * @param gas - gas to check @@ -126,10 +126,10 @@ public class GasTank { return false; } - + return true; } - + /** * If this GasTank can be drawn of the specified type of gas. Will return false if this tank does not contain any gas. * @param gas - gas to check @@ -141,10 +141,10 @@ public class GasTank { return false; } - + return true; } - + /** * Gets the amount of gas needed by this GasTank. * @return @@ -153,7 +153,7 @@ public class GasTank { return getMaxGas()-getStored(); } - + /** * Gets the maximum amount of gas this tank can hold. * @return - max gas @@ -162,7 +162,7 @@ public class GasTank { return maxGas; } - + /** * Gets the GasStack held by this GasTank. * @return - GasStakc held by this tank @@ -171,7 +171,7 @@ public class GasTank { return stored; } - + /** * Gets the amount of gas stored by this GasTank. * @return amount of gas stored @@ -180,7 +180,7 @@ public class GasTank { return stored != null ? stored.amount : 0; } - + /** * Writes this tank to a defined tag compound. * @param nbtTags - tag compound to write to @@ -192,12 +192,12 @@ public class GasTank { nbtTags.setCompoundTag("stored", stored.write(new NBTTagCompound())); } - + nbtTags.setInteger("maxGas", maxGas); - + return nbtTags; } - + /** * Reads this tank's data from a defined tag compound. * @param nbtTags - tag compound to read from @@ -208,10 +208,10 @@ public class GasTank { stored = GasStack.readFromNBT(nbtTags.getCompoundTag("stored")); } - + maxGas = nbtTags.getInteger("maxGas"); } - + /** * Returns the tank stored in the defined tag compound, or null if it doesn't exist. * @param nbtTags - tag compound to read from @@ -223,10 +223,10 @@ public class GasTank { return null; } - + GasTank tank = new GasTank(); tank.read(nbtTags); - + return tank; } } diff --git a/common/mekanism/api/gas/GasTransmission.java b/common/mekanism/api/gas/GasTransmission.java index 681d07961..34f7818bd 100644 --- a/common/mekanism/api/gas/GasTransmission.java +++ b/common/mekanism/api/gas/GasTransmission.java @@ -12,82 +12,82 @@ import net.minecraftforge.common.ForgeDirection; * @author AidanBrady * */ -public final class GasTransmission +public final class GasTransmission { - /** - * Gets all the tubes around a tile entity. - * @param tileEntity - center tile entity - * @return array of TileEntities - */ - public static TileEntity[] getConnectedTubes(TileEntity tileEntity) - { - TileEntity[] tubes = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + /** + * Gets all the tubes around a tile entity. + * @param tileEntity - center tile entity + * @return array of TileEntities + */ + public static TileEntity[] getConnectedTubes(TileEntity tileEntity) + { + TileEntity[] tubes = new TileEntity[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity tube = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); - + if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, tileEntity)) { - tubes[orientation.ordinal()] = tube; + tubes[orientation.ordinal()] = tube; } - } - - return tubes; - } - - /** - * Gets all the acceptors around a tile entity. - * @param tileEntity - center tile entity - * @return array of IGasAcceptors - */ - public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity) - { - IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + } + + return tubes; + } + + /** + * Gets all the acceptors around a tile entity. + * @param tileEntity - center tile entity + * @return array of IGasAcceptors + */ + public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity) + { + IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); - + if(acceptor instanceof IGasHandler) { acceptors[orientation.ordinal()] = (IGasHandler)acceptor; } - } - - return acceptors; - } - - /** - * Gets all the tube connections around a tile entity. - * @param tileEntity - center tile entity - * @return array of ITubeConnections - */ - public static ITubeConnection[] getConnections(TileEntity tileEntity) - { - ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null}; - + } + + return acceptors; + } + + /** + * Gets all the tube connections around a tile entity. + * @param tileEntity - center tile entity + * @return array of ITubeConnections + */ + public static ITubeConnection[] getConnections(TileEntity tileEntity) + { + ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null}; + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + { TileEntity connection = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); - + if(canConnect(connection, orientation)) { connections[orientation.ordinal()] = (ITubeConnection)connection; } - } - - return connections; - } - - /** - * Whether or not a TileEntity can connect to a specified tile on a specified side. - * @param tileEntity - TileEntity to attempt connection to - * @param side - side to attempt connection on - * @return if this tile and side are connectable - */ - public static boolean canConnect(TileEntity tileEntity, ForgeDirection side) - { + } + + return connections; + } + + /** + * Whether or not a TileEntity can connect to a specified tile on a specified side. + * @param tileEntity - TileEntity to attempt connection to + * @param side - side to attempt connection on + * @return if this tile and side are connectable + */ + public static boolean canConnect(TileEntity tileEntity, ForgeDirection side) + { if(tileEntity instanceof ITubeConnection && (!(tileEntity instanceof IGasTransmitter) || TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, tileEntity))) { if(((ITubeConnection)tileEntity).canTubeConnect(side.getOpposite())) @@ -95,51 +95,51 @@ public final class GasTransmission return true; } } - - return false; - } - - /** - * Emits a defined gas to the network. - * @param type - gas type to send - * @param amount - amount of gas to send - * @param sender - the sender of the gas - * @param facing - side the sender is outputting from - * @return gas sent - */ - public static int emitGasToNetwork(GasStack stack, TileEntity sender, ForgeDirection facing) - { - TileEntity pointer = Coord4D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj); - - if(TransmissionType.checkTransmissionType(pointer, TransmissionType.GAS, sender)) - { - return ((IGridTransmitter)pointer).getTransmitterNetwork().emit(stack); - } - - return 0; - } - /** - * Removes a specified amount of gas from an IGasItem. - * @param itemStack - ItemStack of the IGasItem - * @param type - type of gas to remove from the IGasItem, null if it doesn't matter - * @param amount - amount of gas to remove from the ItemStack - * @return the GasStack removed by the IGasItem - */ + return false; + } + + /** + * Emits a defined gas to the network. + * @param type - gas type to send + * @param amount - amount of gas to send + * @param sender - the sender of the gas + * @param facing - side the sender is outputting from + * @return gas sent + */ + public static int emitGasToNetwork(GasStack stack, TileEntity sender, ForgeDirection facing) + { + TileEntity pointer = Coord4D.get(sender).getFromSide(facing).getTileEntity(sender.worldObj); + + if(TransmissionType.checkTransmissionType(pointer, TransmissionType.GAS, sender)) + { + return ((IGridTransmitter)pointer).getTransmitterNetwork().emit(stack); + } + + return 0; + } + + /** + * Removes a specified amount of gas from an IGasItem. + * @param itemStack - ItemStack of the IGasItem + * @param type - type of gas to remove from the IGasItem, null if it doesn't matter + * @param amount - amount of gas to remove from the ItemStack + * @return the GasStack removed by the IGasItem + */ public static GasStack removeGas(ItemStack itemStack, Gas type, int amount) { if(itemStack != null && itemStack.getItem() instanceof IGasItem) { IGasItem item = (IGasItem)itemStack.getItem(); - + if(type != null && item.getGas(itemStack) != null && item.getGas(itemStack).getGas() != type || !item.canProvideGas(itemStack, type)) { return null; } - + return item.removeGas(itemStack, amount); } - + return null; } @@ -155,7 +155,7 @@ public final class GasTransmission { return ((IGasItem)itemStack.getItem()).addGas(itemStack, stack.copy()); } - + return 0; } } diff --git a/common/mekanism/api/gas/IGasHandler.java b/common/mekanism/api/gas/IGasHandler.java index 6abc06168..312f0c266 100644 --- a/common/mekanism/api/gas/IGasHandler.java +++ b/common/mekanism/api/gas/IGasHandler.java @@ -7,7 +7,7 @@ import net.minecraftforge.common.ForgeDirection; * @author AidanBrady * */ -public interface IGasHandler +public interface IGasHandler { /** * Transfer a certain amount of gas to this block. @@ -15,14 +15,14 @@ public interface IGasHandler * @return gas added */ public int receiveGas(ForgeDirection side, GasStack stack); - + /** * Draws a certain amount of gas from this block. * @param amount - amount to draw * @return gas drawn */ public GasStack drawGas(ForgeDirection side, int amount); - + /** * Whether or not this block can accept gas from a certain side. * @param side - side to check @@ -30,7 +30,7 @@ public interface IGasHandler * @return if block accepts gas */ public boolean canReceiveGas(ForgeDirection side, Gas type); - + /** * Whether or not this block can be drawn of gas from a certain side. * @param side - side to check diff --git a/common/mekanism/api/gas/IGasItem.java b/common/mekanism/api/gas/IGasItem.java index b9567d5bd..04231cd81 100644 --- a/common/mekanism/api/gas/IGasItem.java +++ b/common/mekanism/api/gas/IGasItem.java @@ -14,7 +14,7 @@ public interface IGasItem * @return */ public int getRate(ItemStack itemstack); - + /** * Adds a defined amount of a certain gas to an item. * @param itemstack - the itemstack to add gas to @@ -23,7 +23,7 @@ public interface IGasItem * @return the gas that was accepted by the item */ public int addGas(ItemStack itemstack, GasStack stack); - + /** * Removes the defined amount of a certain gas from the item. * @param itemstack - the itemstack to remove gas from @@ -32,7 +32,7 @@ public interface IGasItem * @return the gas that was removed by the item */ public GasStack removeGas(ItemStack itemstack, int amount); - + /** * Whether or not this storage tank be given a specific gas. * @param itemstack - the itemstack to check @@ -40,7 +40,7 @@ public interface IGasItem * @return if the item be charged */ public boolean canReceiveGas(ItemStack itemstack, Gas type); - + /** * Whether or not this item can give a gas receiver a certain type of gas. * @param itemstack - the itemstack to check @@ -48,7 +48,7 @@ public interface IGasItem * @return if the item can provide gas */ public boolean canProvideGas(ItemStack itemstack, Gas type); - + /** * Get the gas of a declared type. * @param type - type of gas @@ -56,7 +56,7 @@ public interface IGasItem * @return gas stored */ public GasStack getGas(ItemStack itemstack); - + /** * Set the gas of a declared type to a new amount; * @param type - type of gas @@ -64,7 +64,7 @@ public interface IGasItem * @param amount - amount to store */ public void setGas(ItemStack itemstack, GasStack stack); - + /** * Gets the maximum amount of gas this tile entity can store. * @param type - type of gas diff --git a/common/mekanism/api/gas/IGasTransmitter.java b/common/mekanism/api/gas/IGasTransmitter.java index 820dfb929..63eb02fd1 100644 --- a/common/mekanism/api/gas/IGasTransmitter.java +++ b/common/mekanism/api/gas/IGasTransmitter.java @@ -5,5 +5,5 @@ import net.minecraft.tileentity.TileEntity; public interface IGasTransmitter extends IGridTransmitter { - public boolean canTransferGasToTube(TileEntity tile); + public boolean canTransferGasToTube(TileEntity tile); } diff --git a/common/mekanism/api/gas/ITubeConnection.java b/common/mekanism/api/gas/ITubeConnection.java index 044a6dc8f..c80bdca50 100644 --- a/common/mekanism/api/gas/ITubeConnection.java +++ b/common/mekanism/api/gas/ITubeConnection.java @@ -7,7 +7,7 @@ import net.minecraftforge.common.ForgeDirection; * @author AidanBrady * */ -public interface ITubeConnection +public interface ITubeConnection { /** * Whether or not a tube can connect to a certain orientation. diff --git a/common/mekanism/api/gas/OreGas.java b/common/mekanism/api/gas/OreGas.java index b8e02b6e2..316169c2a 100644 --- a/common/mekanism/api/gas/OreGas.java +++ b/common/mekanism/api/gas/OreGas.java @@ -6,31 +6,31 @@ public class OreGas extends Gas { private String oreName; private OreGas cleanGas; - + public OreGas(String s, String name) { super(s); - + oreName = name; } - + public boolean isClean() { return getCleanGas() == null; } - + public OreGas getCleanGas() { return cleanGas; } - + public OreGas setCleanGas(OreGas gas) { cleanGas = gas; - + return this; } - + public String getOreName() { return StatCollector.translateToLocal(oreName); diff --git a/common/mekanism/api/infuse/InfuseObject.java b/common/mekanism/api/infuse/InfuseObject.java index bfd114744..a86c02f1a 100644 --- a/common/mekanism/api/infuse/InfuseObject.java +++ b/common/mekanism/api/infuse/InfuseObject.java @@ -5,14 +5,14 @@ package mekanism.api.infuse; * @author AidanBrady * */ -public class InfuseObject +public class InfuseObject { /** The type of infuse this item stores */ public InfuseType type; - + /** How much infuse this item stores */ public int stored; - + public InfuseObject(InfuseType infusion, int i) { type = infusion; diff --git a/common/mekanism/api/infuse/InfuseRegistry.java b/common/mekanism/api/infuse/InfuseRegistry.java index 8a82ca0f1..308b9c5be 100644 --- a/common/mekanism/api/infuse/InfuseRegistry.java +++ b/common/mekanism/api/infuse/InfuseRegistry.java @@ -10,14 +10,14 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public class InfuseRegistry +public class InfuseRegistry { /** The (private) map of ItemStacks and their related InfuseObjects. */ private static Map infuseObjects = new HashMap(); - + /** The (private) map of infuse names and their corresponding InfuseTypes. */ private static Map infuseTypes = new HashMap(); - + /** * Registers an InfuseType into the registry. Call this in PreInit! * @param infuse @@ -28,10 +28,10 @@ public class InfuseRegistry { return; } - + infuseTypes.put(infuse.name, infuse); } - + /** * Gets an InfuseType from it's name, or null if it doesn't exist. * @param name - the name of the InfuseType to get @@ -43,10 +43,10 @@ public class InfuseRegistry { return null; } - + return infuseTypes.get(name); } - + /** * Whether or not the registry contains a correspondent InfuseType to a name. * @param name - the name to check @@ -56,7 +56,7 @@ public class InfuseRegistry { return get(name) != null; } - + /** * Registers a block or item that serves as an infuse object. An infuse object will store a certain type and amount of infuse, * and will deliver this amount to the Metallurgic Infuser's buffer of infuse. The item's stack size will be decremented when @@ -71,10 +71,10 @@ public class InfuseRegistry { return; } - + infuseObjects.put(itemStack, infuseObject); } - + /** * Gets the InfuseObject data from an ItemStack. * @param itemStack - the ItemStack to check @@ -89,10 +89,10 @@ public class InfuseRegistry return obj.getValue(); } } - + return null; } - + /** * Gets the private map for InfuseObjects. * @return private InfuseObject map @@ -101,7 +101,7 @@ public class InfuseRegistry { return infuseObjects; } - + /** * Gets the private map for InfuseTypes. * @return private InfuseType map diff --git a/common/mekanism/api/infuse/InfuseType.java b/common/mekanism/api/infuse/InfuseType.java index 52d5b6d89..1f5215cb7 100644 --- a/common/mekanism/api/infuse/InfuseType.java +++ b/common/mekanism/api/infuse/InfuseType.java @@ -8,23 +8,23 @@ import net.minecraft.util.StatCollector; * @author AidanBrady * */ -public final class InfuseType +public final class InfuseType { /** The name of this infusion */ public String name; - + /** The location of this infuse's GUI texture */ public ResourceLocation texture; - + /** The infuse's GUI texture X offset. */ public int texX; - + /** The infuse's GUI texture Y offset. */ public int texY; - + /** The unlocalized name of this type. */ public String unlocalizedName; - + public InfuseType(String s, ResourceLocation location, int x, int y) { name = s; @@ -32,14 +32,14 @@ public final class InfuseType texX = x; texY = y; } - + public InfuseType setUnlocalizedName(String name) { unlocalizedName = name; - + return this; } - + public String getLocalizedName() { return StatCollector.translateToLocal(unlocalizedName); diff --git a/common/mekanism/api/infuse/InfusionInput.java b/common/mekanism/api/infuse/InfusionInput.java index e8324c022..edbad48cd 100644 --- a/common/mekanism/api/infuse/InfusionInput.java +++ b/common/mekanism/api/infuse/InfusionInput.java @@ -11,20 +11,20 @@ public class InfusionInput { /** The type of this infusion */ public InfuseType infusionType; - + /** How much infuse it takes to perform this operation */ public int infuseAmount; - + /** The input ItemStack */ public ItemStack inputStack; - + public InfusionInput(InfuseType infusiontype, int required, ItemStack itemstack) { infusionType = infusiontype; infuseAmount = required; inputStack = itemstack; } - + public static InfusionInput getInfusion(InfuseType type, int stored, ItemStack itemstack) { return new InfusionInput(type, stored, itemstack); diff --git a/common/mekanism/api/infuse/InfusionOutput.java b/common/mekanism/api/infuse/InfusionOutput.java index 6d8722345..ad6d79a62 100644 --- a/common/mekanism/api/infuse/InfusionOutput.java +++ b/common/mekanism/api/infuse/InfusionOutput.java @@ -7,30 +7,30 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public class InfusionOutput +public class InfusionOutput { /** The input infusion */ public InfusionInput infusionInput; - + /** The output resource of this infusion */ public ItemStack resource; - + public InfusionOutput(InfusionInput input, ItemStack itemstack) { infusionInput = input; resource = itemstack; } - + public static InfusionOutput getInfusion(InfusionInput input, ItemStack itemstack) { return new InfusionOutput(input, itemstack); } - + public int getInfuseRequired() { return infusionInput.infuseAmount; } - + public InfusionOutput copy() { return new InfusionOutput(infusionInput, resource); diff --git a/common/mekanism/api/transmitters/DynamicNetwork.java b/common/mekanism/api/transmitters/DynamicNetwork.java index d575cd21b..a9b00d972 100644 --- a/common/mekanism/api/transmitters/DynamicNetwork.java +++ b/common/mekanism/api/transmitters/DynamicNetwork.java @@ -23,56 +23,56 @@ import cpw.mods.fml.common.FMLCommonHandler; public abstract class DynamicNetwork> implements ITransmitterNetwork, IClientTicker { public LinkedHashSet> transmitters = new LinkedHashSet>(); - + public HashSet possibleAcceptors = new HashSet(); public HashMap acceptorDirections = new HashMap(); - + private List updateQueue = new ArrayList(); - + protected int ticksSinceCreate = 0; - + protected boolean fixed = false; - + protected boolean needsUpdate = false; - + protected abstract ITransmitterNetwork create(IGridTransmitter... varTransmitters); - + protected abstract ITransmitterNetwork create(Collection> collection); - + protected abstract ITransmitterNetwork create(Set networks); - + public void addAllTransmitters(Set> newTransmitters) { transmitters.addAll(newTransmitters); } - + public boolean isFirst(IGridTransmitter transmitter) { return transmitters.iterator().next().equals(transmitter); } - + @Override public void removeTransmitter(IGridTransmitter transmitter) { transmitters.remove(transmitter); - + if(transmitters.size() == 0) { deregister(); } } - + @Override public void register() { try { IGridTransmitter aTransmitter = transmitters.iterator().next(); - + if(aTransmitter instanceof TileEntity) { if(!((TileEntity)aTransmitter).worldObj.isRemote) { - TransmitterNetworkRegistry.getInstance().registerNetwork(this); + TransmitterNetworkRegistry.getInstance().registerNetwork(this); } else { MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte)1)); @@ -80,12 +80,12 @@ public abstract class DynamicNetwork> implemen } } catch(NoSuchElementException e) {} } - + @Override public void deregister() { transmitters.clear(); - + if(FMLCommonHandler.instance().getEffectiveSide().isServer()) { TransmitterNetworkRegistry.getInstance().removeNetwork(this); @@ -94,48 +94,48 @@ public abstract class DynamicNetwork> implemen MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte)0)); } } - + @Override public int getSize() { return transmitters.size(); } - + @Override public int getAcceptorSize() { return possibleAcceptors.size(); } - public int getCapacity() - { - return (int)getMeanCapacity() * transmitters.size(); - } + public int getCapacity() + { + return (int)getMeanCapacity() * transmitters.size(); + } - /** - * Override this if things can have variable capacity along the network. - * @return An 'average' value of capacity. Calculate it how you will. - */ - public double getMeanCapacity() - { + /** + * Override this if things can have variable capacity along the network. + * @return An 'average' value of capacity. Calculate it how you will. + */ + public double getMeanCapacity() + { return transmitters.size() > 0 ? transmitters.iterator().next().getCapacity() : 0; - } - + } + @Override public void tick() { boolean didFix = false; - + if(!fixed) { ticksSinceCreate++; - + if(transmitters.size() == 0) { deregister(); return; } - + if(ticksSinceCreate > 1200) { ticksSinceCreate = 0; @@ -143,24 +143,24 @@ public abstract class DynamicNetwork> implemen didFix = true; } } - + if(!didFix) { onUpdate(); } } - + public void onUpdate() { if(FMLCommonHandler.instance().getEffectiveSide().isServer()) { Iterator i = updateQueue.iterator(); - + try { while(i.hasNext()) { DelayQueue q = i.next(); - + if(q.delay > 0) { q.delay--; @@ -173,7 +173,7 @@ public abstract class DynamicNetwork> implemen } catch(Exception e) {} } } - + @Override public synchronized void fixMessedUpNetwork(IGridTransmitter transmitter) { @@ -182,7 +182,7 @@ public abstract class DynamicNetwork> implemen NetworkFinder finder = new NetworkFinder(((TileEntity)transmitter).getWorldObj(), getTransmissionType(), Coord4D.get((TileEntity)transmitter)); List partNetwork = finder.exploreNetwork(); Set> newTransporters = new HashSet>(); - + for(Coord4D node : partNetwork) { TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).worldObj); @@ -193,29 +193,29 @@ public abstract class DynamicNetwork> implemen newTransporters.add((IGridTransmitter)nodeTile); } } - + ITransmitterNetwork newNetwork = create(newTransporters); newNetwork.refresh(); newNetwork.setFixed(true); deregister(); } } - + @Override public synchronized void split(IGridTransmitter splitPoint) { if(splitPoint instanceof TileEntity) { removeTransmitter(splitPoint); - + TileEntity[] connectedBlocks = new TileEntity[6]; boolean[] dealtWith = {false, false, false, false, false, false}; List> newNetworks = new ArrayList>(); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity sideTile = Coord4D.get((TileEntity)splitPoint).getFromSide(side).getTileEntity(((TileEntity)splitPoint).worldObj); - + if(sideTile != null) { connectedBlocks[side.ordinal()] = sideTile; @@ -230,16 +230,16 @@ public abstract class DynamicNetwork> implemen { NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).worldObj, getTransmissionType(), Coord4D.get(connectedBlockA), Coord4D.get((TileEntity)splitPoint)); List partNetwork = finder.exploreNetwork(); - + for(int check = count; check < connectedBlocks.length; check++) { if(check == count) { continue; } - + TileEntity connectedBlockB = connectedBlocks[check]; - + if(TransmissionType.checkTransmissionType(connectedBlockB, getTransmissionType()) && !dealtWith[check]) { if(partNetwork.contains(Coord4D.get(connectedBlockB))) @@ -248,13 +248,13 @@ public abstract class DynamicNetwork> implemen } } } - + Set> newNetCables = new HashSet>(); - + for(Coord4D node : finder.iterated) { TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).worldObj); - + if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType())) { if(nodeTile != splitPoint) @@ -263,108 +263,108 @@ public abstract class DynamicNetwork> implemen } } } - + newNetworks.add(create(newNetCables)); } } - + if(newNetworks.size() > 0) { onNetworksCreated((List)newNetworks); - + for(ITransmitterNetwork network : newNetworks) { network.refresh(); } } - + deregister(); } } - + @Override public void onNetworksCreated(List networks) {} - + @Override public void setFixed(boolean value) { fixed = value; } - + @Override public boolean needsTicks() { return getSize() > 0; } - + @Override - public void clientTick() + public void clientTick() { ticksSinceCreate++; - + if(ticksSinceCreate == 5 && getSize() > 0) { TileEntity tile = (TileEntity)transmitters.iterator().next(); MinecraftForge.EVENT_BUS.post(new NetworkClientRequest(tile)); } } - + @Override public boolean canMerge(List> networks) { return true; } - + public static class ClientTickUpdate extends Event { public DynamicNetwork network; public byte operation; /*0 remove, 1 add*/ - + public ClientTickUpdate(DynamicNetwork net, byte b) { network = net; operation = b; } } - + public static class NetworkClientRequest extends Event { public TileEntity tileEntity; - + public NetworkClientRequest(TileEntity tile) { tileEntity = tile; } } - + public void addUpdate(EntityPlayer player) { updateQueue.add(new DelayQueue(player)); } - + public static class NetworkFinder { public TransmissionType transmissionType; - + public World worldObj; public Coord4D start; - + public List iterated = new ArrayList(); public List toIgnore = new ArrayList(); - + public NetworkFinder(World world, TransmissionType type, Coord4D location, Coord4D... ignore) { worldObj = world; start = location; - + transmissionType = type; - + if(ignore != null) { - for(int i = 0; i < ignore.length; i++) - { - toIgnore.add(ignore[i]); - } + for(int i = 0; i < ignore.length; i++) + { + toIgnore.add(ignore[i]); + } } } @@ -375,13 +375,13 @@ public abstract class DynamicNetwork> implemen iterated.add(location); } else { - toIgnore.add(location); + toIgnore.add(location); } - + for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { Coord4D obj = location.getFromSide(direction); - + if(!iterated.contains(obj) && !toIgnore.contains(obj)) { TileEntity tileEntity = obj.getTileEntity(worldObj); @@ -400,16 +400,16 @@ public abstract class DynamicNetwork> implemen public List exploreNetwork() { loopAll(start); - + return iterated; } } - + public static class DelayQueue { public EntityPlayer player; public int delay; - + public DelayQueue(EntityPlayer p) { player = p; diff --git a/common/mekanism/api/transmitters/IGridTransmitter.java b/common/mekanism/api/transmitters/IGridTransmitter.java index 8d0b272a9..13edf3f4d 100644 --- a/common/mekanism/api/transmitters/IGridTransmitter.java +++ b/common/mekanism/api/transmitters/IGridTransmitter.java @@ -4,13 +4,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; public interface IGridTransmitter> extends ITransmitter -{ +{ /** * Gets the network currently in use by this transmitter segment. * @return network this transmitter is using */ public N getTransmitterNetwork(); - + /** * Gets the network currently in use by this transmitter segment. * @param createIfNull - If true, the transmitter will try and connect to an @@ -19,28 +19,28 @@ public interface IGridTransmitter> extends ITrans * @return network this transmitter is using */ public N getTransmitterNetwork(boolean createIfNull); - + /** * Sets this transmitter segment's network to a new value. * @param network - network to set to */ public void setTransmitterNetwork(N network); - + /** * Refreshes the transmitter's network. */ public void refreshTransmitterNetwork(); - + /** * Called when the chunk this transmitter is in is loaded. */ public void chunkLoad(); - + /** * Remove this transmitter from its network. */ public void removeFromTransmitterNetwork(); - + public boolean canConnectToAcceptor(ForgeDirection side, boolean ignoreActive); /** @@ -50,14 +50,14 @@ public interface IGridTransmitter> extends ITrans public void fixTransmitterNetwork(); public boolean areTransmitterNetworksEqual(TileEntity tileEntity); - - public int getTransmitterNetworkSize(); - public int getTransmitterNetworkAcceptorSize(); + public int getTransmitterNetworkSize(); - public String getTransmitterNetworkNeeded(); + public int getTransmitterNetworkAcceptorSize(); - public String getTransmitterNetworkFlow(); + public String getTransmitterNetworkNeeded(); - public int getCapacity(); + public String getTransmitterNetworkFlow(); + + public int getCapacity(); } diff --git a/common/mekanism/api/transmitters/ITransmitter.java b/common/mekanism/api/transmitters/ITransmitter.java index 477a0dff0..cddc76a7a 100644 --- a/common/mekanism/api/transmitters/ITransmitter.java +++ b/common/mekanism/api/transmitters/ITransmitter.java @@ -4,7 +4,7 @@ public interface ITransmitter { /** * Get the transmitter's transmission type - * + * * @return TransmissionType this transmitter uses */ public TransmissionType getTransmissionType(); diff --git a/common/mekanism/api/transmitters/ITransmitterNetwork.java b/common/mekanism/api/transmitters/ITransmitterNetwork.java index 2d5138a0f..1fbedc161 100644 --- a/common/mekanism/api/transmitters/ITransmitterNetwork.java +++ b/common/mekanism/api/transmitters/ITransmitterNetwork.java @@ -6,38 +6,38 @@ import java.util.Set; public interface ITransmitterNetwork> { public void tick(); - + public int getSize(); - + public int getAcceptorSize(); - + public String getNeeded(); public String getStored(); - + public String getFlow(); - + public Set getAcceptors(Object... data); - + public void removeTransmitter(IGridTransmitter transmitter); - + public void refresh(); - + public void split(IGridTransmitter splitPoint); - + public void merge(N network); - + public void fixMessedUpNetwork(IGridTransmitter transmitter); - + public void register(); - + public void deregister(); - + public void setFixed(boolean value); - + public TransmissionType getTransmissionType(); - + public boolean canMerge(List> networks); - + public void onNetworksCreated(List networks); } diff --git a/common/mekanism/api/transmitters/TransmissionType.java b/common/mekanism/api/transmitters/TransmissionType.java index 36d85677b..ae9388cca 100644 --- a/common/mekanism/api/transmitters/TransmissionType.java +++ b/common/mekanism/api/transmitters/TransmissionType.java @@ -8,36 +8,36 @@ public enum TransmissionType ENERGY, FLUID, GAS, - ITEM; + ITEM; - public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type) - { - return checkTransmissionType(sideTile, type, null); - } - - public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type, TileEntity currentPipe) - { - return type.checkTransmissionType(sideTile, currentPipe); - } - - public boolean checkTransmissionType(TileEntity sideTile, TileEntity currentTile) - { - if(sideTile instanceof ITransmitter) - { - if(((ITransmitter)sideTile).getTransmissionType() == this) - { - return true; - } - } - - if(this == GAS && currentTile instanceof IGasTransmitter) - { - if(((IGasTransmitter)currentTile).canTransferGasToTube(sideTile)) - { - return true; - } - } - - return false; - } + public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type) + { + return checkTransmissionType(sideTile, type, null); + } + + public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type, TileEntity currentPipe) + { + return type.checkTransmissionType(sideTile, currentPipe); + } + + public boolean checkTransmissionType(TileEntity sideTile, TileEntity currentTile) + { + if(sideTile instanceof ITransmitter) + { + if(((ITransmitter)sideTile).getTransmissionType() == this) + { + return true; + } + } + + if(this == GAS && currentTile instanceof IGasTransmitter) + { + if(((IGasTransmitter)currentTile).canTransferGasToTube(sideTile)) + { + return true; + } + } + + return false; + } } \ No newline at end of file diff --git a/common/mekanism/api/transmitters/TransmitterNetworkRegistry.java b/common/mekanism/api/transmitters/TransmitterNetworkRegistry.java index 261d7fe40..638ded221 100644 --- a/common/mekanism/api/transmitters/TransmitterNetworkRegistry.java +++ b/common/mekanism/api/transmitters/TransmitterNetworkRegistry.java @@ -61,8 +61,8 @@ public class TransmitterNetworkRegistry implements ITickHandler public void pruneEmptyNetworks() { - HashSet copySet = new HashSet(networks); - + HashSet copySet = new HashSet(networks); + for(ITransmitterNetwork e : copySet) { if(e.getSize() == 0) @@ -111,13 +111,13 @@ public class TransmitterNetworkRegistry implements ITickHandler { String[] strings = new String[networks.size()]; int i = 0; - + for(ITransmitterNetwork network : networks) { strings[i] = network.toString(); ++i; } - + return strings; } @@ -151,21 +151,21 @@ public class TransmitterNetworkRegistry implements ITickHandler public synchronized void refreshChunk(Chunk c) { try { - if(c != null) - { - Map copy = (Map)((HashMap)c.chunkTileEntityMap).clone(); - - for(Iterator iter = copy.values().iterator(); iter.hasNext();) - { - Object obj = iter.next(); - - if(obj instanceof IGridTransmitter) - { - ((IGridTransmitter)obj).refreshTransmitterNetwork(); - ((IGridTransmitter)obj).chunkLoad(); - } - } - } + if(c != null) + { + Map copy = (Map)((HashMap)c.chunkTileEntityMap).clone(); + + for(Iterator iter = copy.values().iterator(); iter.hasNext();) + { + Object obj = iter.next(); + + if(obj instanceof IGridTransmitter) + { + ((IGridTransmitter)obj).refreshTransmitterNetwork(); + ((IGridTransmitter)obj).chunkLoad(); + } + } + } } catch(Exception e) { e.printStackTrace(); } diff --git a/common/mekanism/client/CapeBufferDownload.java b/common/mekanism/client/CapeBufferDownload.java index 022e8bfa1..f2b6c976b 100644 --- a/common/mekanism/client/CapeBufferDownload.java +++ b/common/mekanism/client/CapeBufferDownload.java @@ -21,38 +21,38 @@ public class CapeBufferDownload extends Thread public String username; public String staticCapeUrl; - + public ResourceLocation resourceLocation; - + public ThreadDownloadImageData capeImage; boolean downloaded = false; - public CapeBufferDownload(String name, String url) + public CapeBufferDownload(String name, String url) { username = name; staticCapeUrl = url; - + setDaemon(true); setName("Cape Downlaod Thread"); } @Override - public void run() + public void run() { try { download(); } catch(Exception e) {} } - private void download() + private void download() { try { resourceLocation = new ResourceLocation("mekanism/" + StringUtils.stripControlCodes(username)); - + Method method = MekanismUtils.getPrivateMethod(AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_getDownloadImage, ResourceLocation.class, String.class, ResourceLocation.class, IImageBuffer.class); Object obj = method.invoke(null, resourceLocation, staticCapeUrl, null, null); - + if(obj instanceof ThreadDownloadImageData) { capeImage = (ThreadDownloadImageData)obj; diff --git a/common/mekanism/client/ClientConnectionHandler.java b/common/mekanism/client/ClientConnectionHandler.java index 30eaa81bd..01019de66 100644 --- a/common/mekanism/client/ClientConnectionHandler.java +++ b/common/mekanism/client/ClientConnectionHandler.java @@ -21,14 +21,14 @@ public class ClientConnectionHandler implements IConnectionHandler public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {} @Override - public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) + public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) { return null; } /* Remote */ @Override - public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) + public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) { if(Mekanism.voiceServerEnabled) { @@ -40,7 +40,7 @@ public class ClientConnectionHandler implements IConnectionHandler /* Integrated */ @Override - public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) + public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) { if(Mekanism.voiceServerEnabled) { diff --git a/common/mekanism/client/ClientProxy.java b/common/mekanism/client/ClientProxy.java index ef37473ec..de2e6995b 100644 --- a/common/mekanism/client/ClientProxy.java +++ b/common/mekanism/client/ClientProxy.java @@ -147,21 +147,21 @@ public class ClientProxy extends CommonProxy public static int MACHINE_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); public static int TRANSMITTER_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); public static int BASIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); - + @Override public void loadConfiguration() { super.loadConfiguration(); - + Mekanism.configuration.load(); MekanismClient.enableSounds = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableSounds", true).getBoolean(true); MekanismClient.fancyUniversalCableRender = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "FancyUniversalCableRender", true).getBoolean(true); MekanismClient.holidays = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Holidays", true).getBoolean(true); MekanismClient.baseSoundVolume = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SoundVolume", 1D).getDouble(1D); MekanismClient.machineEffects = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MachineEffects", true).getBoolean(true); - + String s = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyType", "J").getString(); - + if(s != null) { if(s.trim().equalsIgnoreCase("j") || s.trim().equalsIgnoreCase("joules")) @@ -181,18 +181,18 @@ public class ClientProxy extends CommonProxy Mekanism.activeType = EnergyType.MJ; } } - + Mekanism.configuration.save(); } - + @Override public int getArmorIndex(String string) { return RenderingRegistry.addNewArmourRendererPrefix(string); } - + @Override - public void registerSound(Object obj) + public void registerSound(Object obj) { if(MekanismClient.enableSounds && Minecraft.getMinecraft().sndManager.sndSystem != null) { @@ -202,9 +202,9 @@ public class ClientProxy extends CommonProxy } } } - + @Override - public void unregisterSound(TileEntity tileEntity) + public void unregisterSound(TileEntity tileEntity) { if(MekanismClient.enableSounds && Minecraft.getMinecraft().sndManager.sndSystem != null) { @@ -217,28 +217,28 @@ public class ClientProxy extends CommonProxy } } } - + @Override - public void openElectricChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z) + public void openElectricChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z) { TileEntityElectricChest tileEntity = (TileEntityElectricChest)entityplayer.worldObj.getBlockTileEntity(x, y, z); - + if(id == 0) { if(isBlock) { - FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, tileEntity)); - entityplayer.openContainer.windowId = windowId; + FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, tileEntity)); + entityplayer.openContainer.windowId = windowId; } else { FMLClientHandler.instance().getClient().sndManager.playSoundFX("random.chestopen", 1.0F, 1.0F); ItemStack stack = entityplayer.getCurrentEquippedItem(); - + if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) { - InventoryElectricChest inventory = new InventoryElectricChest(entityplayer); - FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, inventory)); - entityplayer.openContainer.windowId = windowId; + InventoryElectricChest inventory = new InventoryElectricChest(entityplayer); + FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiElectricChest(entityplayer.inventory, inventory)); + entityplayer.openContainer.windowId = windowId; } } } @@ -250,7 +250,7 @@ public class ClientProxy extends CommonProxy } else { ItemStack stack = entityplayer.getCurrentEquippedItem(); - + if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) { FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordEnter(stack)); @@ -265,7 +265,7 @@ public class ClientProxy extends CommonProxy } else { ItemStack stack = entityplayer.getCurrentEquippedItem(); - + if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) { FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPasswordModify(stack)); @@ -273,9 +273,9 @@ public class ClientProxy extends CommonProxy } } } - + @Override - public void registerSpecialTileEntities() + public void registerSpecialTileEntities() { ClientRegistry.registerTileEntity(TileEntityEnrichmentChamber.class, "EnrichmentChamber", new RenderConfigurableMachine()); ClientRegistry.registerTileEntity(TileEntityOsmiumCompressor.class, "OsmiumCompressor", new RenderConfigurableMachine()); @@ -312,49 +312,49 @@ public class ClientProxy extends CommonProxy ClientRegistry.registerTileEntity(TileEntityChemicalWasher.class, "ChemicalWasher", new RenderChemicalWasher()); ClientRegistry.registerTileEntity(TileEntityChemicalCrystalizer.class, "ChemicalCrystalizer", new RenderChemicalCrystalizer()); } - + @Override public void registerRenderInformation() { - RenderPartTransmitter.init(); - + RenderPartTransmitter.init(); + //Register entity rendering handlers RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNTPrimed()); RenderingRegistry.registerEntityRenderingHandler(EntityRobit.class, new RenderRobit()); RenderingRegistry.registerEntityRenderingHandler(EntityBalloon.class, new RenderBalloon()); - + //Register item handler ItemRenderingHandler handler = new ItemRenderingHandler(); - - MinecraftForgeClient.registerItemRenderer(Mekanism.energyCubeID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.machineBlockID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.machineBlock2ID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.Robit.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.WalkieTalkie.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.gasTankID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.obsidianTNTID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.basicBlockID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.Jetpack.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.ArmoredJetpack.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.PartTransmitter.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.GasMask.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.ScubaTank.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.Balloon.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.FreeRunners.itemID, handler); - MinecraftForgeClient.registerItemRenderer(Mekanism.AtomicDisassembler.itemID, handler); - + + MinecraftForgeClient.registerItemRenderer(Mekanism.energyCubeID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.machineBlockID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.machineBlock2ID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.Robit.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.WalkieTalkie.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.gasTankID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.obsidianTNTID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.basicBlockID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.Jetpack.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.ArmoredJetpack.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.PartTransmitter.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.GasMask.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.ScubaTank.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.Balloon.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.FreeRunners.itemID, handler); + MinecraftForgeClient.registerItemRenderer(Mekanism.AtomicDisassembler.itemID, handler); + //Register block handlers RenderingRegistry.registerBlockHandler(new MachineRenderingHandler()); RenderingRegistry.registerBlockHandler(new BasicRenderingHandler()); - + System.out.println("[Mekanism] Render registrations complete."); } - + @Override - public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + switch(ID) { case 0: @@ -448,33 +448,33 @@ public class ClientProxy extends CommonProxy case 37: return new GuiChemicalCrystalizer(player.inventory, (TileEntityChemicalCrystalizer)tileEntity); } - + return null; } - + @Override public void doTankAnimation(TileEntityDynamicTank tileEntity) { new ThreadTankSparkle(tileEntity).start(); } - + @Override public void loadUtilities() { super.loadUtilities(); - + TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT); TickRegistry.registerTickHandler(new RenderTickHandler(), Side.CLIENT); - + NetworkRegistry.instance().registerConnectionHandler(new ClientConnectionHandler()); - + KeyBindingRegistry.registerKeyBinding(new MekanismKeyHandler()); - + GameRegistry.registerPlayerTracker(new ClientPlayerTracker()); - + HolidayManager.init(); } - + @Override public void loadSoundHandler() { @@ -483,7 +483,7 @@ public class ClientProxy extends CommonProxy MekanismClient.audioHandler = new SoundHandler(); } } - + @Override public void unloadSoundHandler() { @@ -495,52 +495,52 @@ public class ClientProxy extends CommonProxy { HashMap sounds = new HashMap(); sounds.putAll(MekanismClient.audioHandler.sounds); - + for(Sound sound : sounds.values()) { sound.remove(); } - + MekanismClient.audioHandler.sounds.clear(); } } } } - + @Override public void preInit() { MekanismRenderer.init(); } - + @Override public double getReach(EntityPlayer player) { return Minecraft.getMinecraft().playerController.getBlockReachDistance(); } - + @Override public boolean isPaused() { if(FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) { GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; - + if(screen != null && screen.doesGuiPauseGame()) { return true; } } - + return false; } - + @Override public File getMinecraftDir() { return Minecraft.getMinecraft().mcDataDir; } - + @Override public void onConfigSync() { diff --git a/common/mekanism/client/ClientTickHandler.java b/common/mekanism/client/ClientTickHandler.java index 6bb75d7ea..0ff564c79 100644 --- a/common/mekanism/client/ClientTickHandler.java +++ b/common/mekanism/client/ClientTickHandler.java @@ -59,25 +59,25 @@ public class ClientTickHandler implements ITickHandler { public boolean hasNotified = false; public boolean initHoliday = false; - + public boolean preloadedSounds = false; - + public boolean lastTickUpdate; - + public boolean shouldReset = false; - + public static Minecraft mc = FMLClientHandler.instance().getClient(); - + public static final String MIKE_CAPE = "https://dl.dropboxusercontent.com/s/ji06yflixnszcby/cape.png"; public static final String DONATE_CAPE = "https://dl.dropboxusercontent.com/u/90411166/donate.png"; public static final String AIDAN_CAPE = "https://dl.dropboxusercontent.com/u/90411166/aidan.png"; - + private Map mikeDownload = new HashMap(); private Map donateDownload = new HashMap(); private Map aidanDownload = new HashMap(); - + public static Set tickingSet = new HashSet(); - + @Override public void tickStart(EnumSet type, Object... tickData) { @@ -92,21 +92,21 @@ public class ClientTickHandler implements ITickHandler } }).start(); } - + MekanismClient.ticksPassed++; - + if(!hasNotified && mc.theWorld != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null) { MekanismUtils.checkForUpdates(mc.thePlayer); hasNotified = true; } - + if(!Mekanism.proxy.isPaused()) { for(Iterator iter = tickingSet.iterator(); iter.hasNext();) { IClientTicker ticker = iter.next(); - + if(ticker.needsTicks()) { ticker.clientTick(); @@ -116,7 +116,7 @@ public class ClientTickHandler implements ITickHandler } } } - + if(mc.theWorld != null) { shouldReset = true; @@ -126,7 +126,7 @@ public class ClientTickHandler implements ITickHandler MekanismClient.reset(); shouldReset = false; } - + if(mc.theWorld != null && !Mekanism.proxy.isPaused()) { if((!initHoliday || MekanismClient.ticksPassed % 1200 == 0) && mc.thePlayer != null) @@ -134,108 +134,108 @@ public class ClientTickHandler implements ITickHandler HolidayManager.check(); initHoliday = true; } - + for(EntityPlayer entityPlayer : (List)mc.theWorld.playerEntities) { if(entityPlayer instanceof AbstractClientPlayer) { AbstractClientPlayer player = (AbstractClientPlayer)entityPlayer; - + if(player != null) { - if(StringUtils.stripControlCodes(player.username).equals("mikeacttck")) - { - CapeBufferDownload download = mikeDownload.get(player.username); - - if(download == null) - { - download = new CapeBufferDownload(player.username, MIKE_CAPE); - mikeDownload.put(player.username, download); - - download.start(); - } - else { - if(!download.downloaded) - { - continue; - } - - MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape); - MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape); - } - } - else if(StringUtils.stripControlCodes(player.username).equals("aidancbrady")) - { - CapeBufferDownload download = aidanDownload.get(player.username); - - if(download == null) - { - download = new CapeBufferDownload(player.username, AIDAN_CAPE); - aidanDownload.put(player.username, download); - - download.start(); - } - else { - if(!download.downloaded) - { - continue; - } - - MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape); - MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape); - } - } - else if(Mekanism.donators.contains(StringUtils.stripControlCodes(player.username))) - { - CapeBufferDownload download = donateDownload.get(player.username); - - if(download == null) - { - download = new CapeBufferDownload(player.username, DONATE_CAPE); - donateDownload.put(player.username, download); - - download.start(); - } - else { - if(!download.downloaded) - { - continue; - } - - MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape); - MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape); - } - } + if(StringUtils.stripControlCodes(player.username).equals("mikeacttck")) + { + CapeBufferDownload download = mikeDownload.get(player.username); + + if(download == null) + { + download = new CapeBufferDownload(player.username, MIKE_CAPE); + mikeDownload.put(player.username, download); + + download.start(); + } + else { + if(!download.downloaded) + { + continue; + } + + MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape); + MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape); + } + } + else if(StringUtils.stripControlCodes(player.username).equals("aidancbrady")) + { + CapeBufferDownload download = aidanDownload.get(player.username); + + if(download == null) + { + download = new CapeBufferDownload(player.username, AIDAN_CAPE); + aidanDownload.put(player.username, download); + + download.start(); + } + else { + if(!download.downloaded) + { + continue; + } + + MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape); + MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape); + } + } + else if(Mekanism.donators.contains(StringUtils.stripControlCodes(player.username))) + { + CapeBufferDownload download = donateDownload.get(player.username); + + if(download == null) + { + download = new CapeBufferDownload(player.username, DONATE_CAPE); + donateDownload.put(player.username, download); + + download.start(); + } + else { + if(!download.downloaded) + { + continue; + } + + MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape); + MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape); + } + } } } } - + ItemStack stack = mc.thePlayer.getCurrentEquippedItem(); - + if(mc.currentScreen == null) { if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemConfigurator) { ItemConfigurator item = (ItemConfigurator)mc.thePlayer.getCurrentEquippedItem().getItem(); - - if(MekanismKeyHandler.modeSwitchKey.pressed) - { - if(!lastTickUpdate) - { - item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0)); - PacketHandler.sendPacket(Transmission.SERVER, new PacketConfiguratorState().setParams(item.getState(stack))); - mc.thePlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + item.getColor(item.getState(stack)) + item.getStateDisplay(item.getState(stack)))); - lastTickUpdate = true; - } - } - else { - lastTickUpdate = false; - } + + if(MekanismKeyHandler.modeSwitchKey.pressed) + { + if(!lastTickUpdate) + { + item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0)); + PacketHandler.sendPacket(Transmission.SERVER, new PacketConfiguratorState().setParams(item.getState(stack))); + mc.thePlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + item.getColor(item.getState(stack)) + item.getStateDisplay(item.getState(stack)))); + lastTickUpdate = true; + } + } + else { + lastTickUpdate = false; + } } else if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemElectricBow) { ItemElectricBow item = (ItemElectricBow)mc.thePlayer.getCurrentEquippedItem().getItem(); - + if(MekanismKeyHandler.modeSwitchKey.pressed) { if(!lastTickUpdate) @@ -253,7 +253,7 @@ public class ClientTickHandler implements ITickHandler else if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemWalkieTalkie) { ItemWalkieTalkie item = (ItemWalkieTalkie)mc.thePlayer.getCurrentEquippedItem().getItem(); - + if(MekanismKeyHandler.modeSwitchKey.pressed && item.getOn(stack)) { if(!lastTickUpdate) @@ -272,7 +272,7 @@ public class ClientTickHandler implements ITickHandler else if(mc.thePlayer.getCurrentItemOrArmor(3) != null && mc.thePlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack) { ItemStack jetpack = mc.thePlayer.getCurrentItemOrArmor(3); - + if(MekanismKeyHandler.modeSwitchKey.pressed) { if(!lastTickUpdate) @@ -290,7 +290,7 @@ public class ClientTickHandler implements ITickHandler else if(mc.thePlayer.getCurrentItemOrArmor(3) != null && mc.thePlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemScubaTank) { ItemStack scubaTank = mc.thePlayer.getCurrentItemOrArmor(3); - + if(MekanismKeyHandler.modeSwitchKey.pressed) { if(!lastTickUpdate) @@ -309,7 +309,7 @@ public class ClientTickHandler implements ITickHandler lastTickUpdate = false; } } - + if(mc.thePlayer.getCurrentItemOrArmor(1) != null && mc.thePlayer.getCurrentItemOrArmor(1).getItem() instanceof ItemFreeRunners) { mc.thePlayer.stepHeight = 1.002F; @@ -320,7 +320,7 @@ public class ClientTickHandler implements ITickHandler mc.thePlayer.stepHeight = 0.5F; } } - + if(Mekanism.jetpackOn.contains(mc.thePlayer.username) != isJetpackOn(mc.thePlayer)) { if(isJetpackOn(mc.thePlayer)) @@ -330,10 +330,10 @@ public class ClientTickHandler implements ITickHandler else { Mekanism.jetpackOn.remove(mc.thePlayer.username); } - + PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(JetpackPacket.UPDATE, mc.thePlayer.username, isJetpackOn(mc.thePlayer))); } - + if(Mekanism.gasmaskOn.contains(mc.thePlayer.username) != isGasMaskOn(mc.thePlayer)) { if(isGasMaskOn(mc.thePlayer) && mc.currentScreen == null) @@ -343,10 +343,10 @@ public class ClientTickHandler implements ITickHandler else { Mekanism.gasmaskOn.remove(mc.thePlayer.username); } - + PacketHandler.sendPacket(Transmission.SERVER, new PacketScubaTankData().setParams(ScubaTankPacket.UPDATE, mc.thePlayer.username, isGasMaskOn(mc.thePlayer))); } - + if(MekanismClient.audioHandler != null) { for(String username : Mekanism.jetpackOn) @@ -359,7 +359,7 @@ public class ClientTickHandler implements ITickHandler } } } - + for(String username : Mekanism.gasmaskOn) { if(mc.theWorld.getPlayerEntityByName(username) != null) @@ -371,17 +371,17 @@ public class ClientTickHandler implements ITickHandler } } } - + if(mc.thePlayer.getCurrentItemOrArmor(3) != null && mc.thePlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack) { MekanismClient.updateKey(mc.gameSettings.keyBindJump.keyCode, KeySync.ASCEND); MekanismClient.updateKey(mc.gameSettings.keyBindSneak.keyCode, KeySync.DESCEND); } - + if(isJetpackOn(mc.thePlayer)) { ItemJetpack jetpack = (ItemJetpack)mc.thePlayer.getCurrentItemOrArmor(3).getItem(); - + if(jetpack.getMode(mc.thePlayer.getCurrentItemOrArmor(3)) == JetpackMode.NORMAL) { mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D); @@ -410,24 +410,24 @@ public class ClientTickHandler implements ITickHandler mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D); } } - + mc.thePlayer.fallDistance = 0.0F; } - + jetpack.useGas(mc.thePlayer.getCurrentItemOrArmor(3)); } - + if(isGasMaskOn(mc.thePlayer)) { ItemScubaTank tank = (ItemScubaTank)mc.thePlayer.getCurrentItemOrArmor(3).getItem(); - + tank.useGas(mc.thePlayer.getCurrentItemOrArmor(3)); mc.thePlayer.setAir(300); mc.thePlayer.clearActivePotions(); } } } - + public static void killDeadNetworks() { for(Iterator iter = tickingSet.iterator(); iter.hasNext();) @@ -438,22 +438,22 @@ public class ClientTickHandler implements ITickHandler } } } - + public static boolean isJetpackOn(EntityPlayer player) { if(player != mc.thePlayer) { return Mekanism.jetpackOn.contains(player.username); } - + ItemStack stack = player.inventory.armorInventory[2]; - + if(stack != null) { if(stack.getItem() instanceof ItemJetpack) { ItemJetpack jetpack = (ItemJetpack)stack.getItem(); - + if(jetpack.getGas(stack) != null) { if((Keyboard.isKeyDown(Keyboard.KEY_SPACE) && jetpack.getMode(stack) == JetpackMode.NORMAL) && mc.currentScreen == null) @@ -467,26 +467,26 @@ public class ClientTickHandler implements ITickHandler } } } - + return false; } - + public static boolean isGasMaskOn(EntityPlayer player) { if(player != mc.thePlayer) { return Mekanism.gasmaskOn.contains(player.username); } - + ItemStack tank = player.inventory.armorInventory[2]; ItemStack mask = player.inventory.armorInventory[3]; - + if(tank != null && mask != null) { if(tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) { ItemScubaTank scubaTank = (ItemScubaTank)tank.getItem(); - + if(scubaTank.getGas(tank) != null) { if(scubaTank.getFlowing(tank)) @@ -496,10 +496,10 @@ public class ClientTickHandler implements ITickHandler } } } - + return false; } - + @Override public void tickEnd(EnumSet type, Object... tickData) { @@ -511,9 +511,9 @@ public class ClientTickHandler implements ITickHandler } } } - + @Override - public EnumSet ticks() + public EnumSet ticks() { return EnumSet.of(TickType.CLIENT); } diff --git a/common/mekanism/client/HolidayManager.java b/common/mekanism/client/HolidayManager.java index 7c73a38d3..990530f9a 100644 --- a/common/mekanism/client/HolidayManager.java +++ b/common/mekanism/client/HolidayManager.java @@ -13,10 +13,10 @@ public final class HolidayManager { private static Calendar calendar = Calendar.getInstance(); private static Minecraft mc = Minecraft.getMinecraft(); - + public static List holidays = new ArrayList(); private static List holidaysNotified = new ArrayList(); - + public static void init() { if(MekanismClient.holidays) @@ -24,15 +24,15 @@ public final class HolidayManager holidays.add(new Christmas()); holidays.add(new NewYear()); } - + System.out.println("[Mekanism] Initialized HolidayManager."); } - + public static void check() { try { YearlyDate date = getDate(); - + for(Holiday holiday : holidays) { if(!holidaysNotified.contains(holiday)) @@ -46,17 +46,17 @@ public final class HolidayManager } } catch(Exception e) {} } - + public static String filterSound(String sound) { if(!MekanismClient.holidays) { return sound; } - + try { YearlyDate date = getDate(); - + for(Holiday holiday : holidays) { if(holiday.getDate().equals(date)) @@ -65,37 +65,37 @@ public final class HolidayManager } } } catch(Exception e) {} - + return sound; } - + private static YearlyDate getDate() { return new YearlyDate(calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)); } - + public static abstract class Holiday { public abstract YearlyDate getDate(); - + public abstract void onEvent(EntityPlayer player); - + public String filterSound(String sound) { return sound; } } - + private static class Christmas extends Holiday { private String[] nutcracker = new String[] {"holiday/Nutcracker1.ogg", "holiday/Nutcracker2.ogg", "holiday/Nutcracker3.ogg", "holiday/Nutcracker4.ogg", "holiday/Nutcracker5.ogg"}; - + @Override public YearlyDate getDate() { return new YearlyDate(12, 25); } - + @Override public void onEvent(EntityPlayer player) { @@ -108,7 +108,7 @@ public final class HolidayManager player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_GREY + "-aidancbrady")); player.sendChatToPlayer(ChatMessageComponent.createFromText(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); } - + @Override public String filterSound(String sound) { @@ -132,11 +132,11 @@ public final class HolidayManager { return nutcracker[4]; } - + return sound; } } - + private static class NewYear extends Holiday { @Override @@ -144,7 +144,7 @@ public final class HolidayManager { return new YearlyDate(1, 1); } - + @Override public void onEvent(EntityPlayer player) { @@ -157,63 +157,63 @@ public final class HolidayManager player.sendChatToPlayer(ChatMessageComponent.createFromText(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); } } - + public static enum Month { - JANUARY("January"), - FEBRUARY("February"), - MARCH("March"), - APRIL("April"), - MAY("May"), - JUNE("June"), - JULY("July"), - AUGUST("August"), - SEPTEMBER("September"), - OCTOBER("October"), - NOVEMBER("November"), + JANUARY("January"), + FEBRUARY("February"), + MARCH("March"), + APRIL("April"), + MAY("May"), + JUNE("June"), + JULY("July"), + AUGUST("August"), + SEPTEMBER("September"), + OCTOBER("October"), + NOVEMBER("November"), DECEMBER("December"); - + private final String name; - + private Month(String n) { name = n; } - + public String getName() { return name; } - + public int month() { return ordinal()+1; } } - + public static class YearlyDate { public Month month; - + public int day; - + public YearlyDate(Month m, int d) { month = m; day = d; } - + public YearlyDate(int m, int d) { this(Month.values()[m-1], d); } - + @Override public boolean equals(Object obj) { return obj instanceof YearlyDate && ((YearlyDate)obj).month == month && ((YearlyDate)obj).day == day; } - + @Override public int hashCode() { @@ -223,16 +223,16 @@ public final class HolidayManager return code; } } - + private static String getThemedLines(EnumColor[] colors, int amount) { StringBuilder builder = new StringBuilder(); - + for(int i = 0; i < amount; i++) { builder.append(colors[i%colors.length] + "-"); } - + return builder.toString(); } } diff --git a/common/mekanism/client/MekanismClient.java b/common/mekanism/client/MekanismClient.java index a40da170c..cec0e6c8e 100644 --- a/common/mekanism/client/MekanismClient.java +++ b/common/mekanism/client/MekanismClient.java @@ -21,28 +21,28 @@ public class MekanismClient extends Mekanism @SideOnly(Side.CLIENT) /** The main SoundHandler instance that is used by all audio sources */ public static SoundHandler audioHandler; - + public static VoiceClient voiceClient; - + //General Configuration public static boolean enableSounds = true; public static boolean fancyUniversalCableRender = true; public static boolean holidays = true; public static double baseSoundVolume = 1; - + public static long ticksPassed = 0; - + public static void updateKey(int key, int type) { boolean down = Minecraft.getMinecraft().currentScreen == null ? Keyboard.isKeyDown(key) : false; - + if(down != keyMap.has(Minecraft.getMinecraft().thePlayer, type)) { PacketHandler.sendPacket(Transmission.SERVER, new PacketKey().setParams(type, down)); keyMap.update(Minecraft.getMinecraft().thePlayer, type, down); } } - + public static void reset() { if(Mekanism.voiceServerEnabled) @@ -53,18 +53,18 @@ public class MekanismClient extends Mekanism MekanismClient.voiceClient = null; } } - + ClientTickHandler.tickingSet.clear(); Mekanism.proxy.unloadSoundHandler(); - + MekanismAPI.getBoxIgnore().clear(); MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent()); - + Mekanism.jetpackOn.clear(); Mekanism.gasmaskOn.clear(); - + Mekanism.proxy.loadConfiguration(); - + System.out.println("[Mekanism] Reloaded config."); } } diff --git a/common/mekanism/client/MekanismKeyHandler.java b/common/mekanism/client/MekanismKeyHandler.java index 156d93b88..a50ff43d4 100644 --- a/common/mekanism/client/MekanismKeyHandler.java +++ b/common/mekanism/client/MekanismKeyHandler.java @@ -16,14 +16,14 @@ public class MekanismKeyHandler extends KeyHandler { public static KeyBinding modeSwitchKey = new KeyBinding("Mekanism Mode Switch", Keyboard.KEY_M); public static KeyBinding voiceKey = new KeyBinding("Mekanism Voice", Keyboard.KEY_U); - + public MekanismKeyHandler() { super(new KeyBinding[] {modeSwitchKey, voiceKey}, new boolean[] {false, false}); } @Override - public String getLabel() + public String getLabel() { return "MekanismKey"; } @@ -35,7 +35,7 @@ public class MekanismKeyHandler extends KeyHandler public void keyUp(EnumSet types, KeyBinding kb, boolean tickEnd) {} @Override - public EnumSet ticks() + public EnumSet ticks() { return EnumSet.of(TickType.CLIENT); } diff --git a/common/mekanism/client/ThreadClientUpdate.java b/common/mekanism/client/ThreadClientUpdate.java index 61cbe7c2e..3105f9522 100644 --- a/common/mekanism/client/ThreadClientUpdate.java +++ b/common/mekanism/client/ThreadClientUpdate.java @@ -30,69 +30,69 @@ public class ThreadClientUpdate extends Thread private int bytesDownloaded; private int lastBytesDownloaded; private byte[] buffer = new byte[10240]; - + private static File modsDir = new File(Mekanism.proxy.getMinecraftDir(), "mods"); private static File tempDir = new File(modsDir, "temp"); private static URL zipUrl = createURL(); - + public static boolean hasUpdated; - + public ThreadClientUpdate() { setDaemon(false); start(); } - + @Override public void run() - { + { try { deleteTemp(); createTemp(); - + File download = new File(tempDir, "builds.zip"); - + prepareForDownload(); download.createNewFile(); - + GuiCredits.updateInfo("Downloading..."); - + FileOutputStream outputStream = new FileOutputStream(download.getAbsolutePath()); InputStream stream = zipUrl.openStream(); - + while((lastBytesDownloaded = stream.read(buffer)) > 0) { outputStream.write(buffer, 0, lastBytesDownloaded); buffer = new byte[10240]; bytesDownloaded += lastBytesDownloaded; } - + outputStream.close(); stream.close(); - + if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1) { ZipInputStream zip = new ZipInputStream(new FileInputStream(download)); deployEntry(zip, "Mekanism-"); zip.close(); } - + for(IModule module : Mekanism.modulesLoaded) { if(module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1) - { + { ZipInputStream zip = new ZipInputStream(new FileInputStream(download)); deployEntry(zip, "Mekanism" + module.getName()); zip.close(); } } - + deleteTemp(); - + hasUpdated = true; GuiCredits.updateInfo("Update installed, reboot Minecraft for changes."); System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ")."); - + finalize(); } catch(Throwable t) { GuiCredits.updateInfo(EnumColor.DARK_RED + "Error updating."); @@ -101,48 +101,48 @@ public class ThreadClientUpdate extends Thread t.printStackTrace(); } } - + private void deployEntry(ZipInputStream zip, String filePrefix) throws IOException { byte[] zipBuffer = new byte[1024]; ZipEntry entry = zip.getNextEntry(); - + while(entry != null) { if(entry.isDirectory()) { continue; } - + if(entry.getName().contains(filePrefix)) { File modFile = new File(modsDir, entry.getName().replace("output/", "")); - + if(modFile.exists()) { modFile.delete(); } - + modFile.createNewFile(); - + FileOutputStream outStream = new FileOutputStream(modFile); - - int len; - - while((len = zip.read(zipBuffer)) > 0) - { - outStream.write(zipBuffer, 0, len); - } - - zip.closeEntry(); + + int len; + + while((len = zip.read(zipBuffer)) > 0) + { + outStream.write(zipBuffer, 0, len); + } + + zip.closeEntry(); outStream.close(); break; } - + entry = zip.getNextEntry(); } } - + private void createTemp() throws IOException { if(!tempDir.exists()) @@ -150,7 +150,7 @@ public class ThreadClientUpdate extends Thread tempDir.mkdir(); } } - + private void deleteTemp() throws IOException { if(tempDir.exists()) @@ -158,7 +158,7 @@ public class ThreadClientUpdate extends Thread clearFiles(tempDir); } } - + private void clearFiles(File file) { if(file.isDirectory()) @@ -168,14 +168,14 @@ public class ThreadClientUpdate extends Thread clearFiles(sub); } } - + file.delete(); } - + private void prepareForDownload() { File[] modsList = new File(new StringBuilder().append(Mekanism.proxy.getMinecraftDir()).append(File.separator + "mods").toString()).listFiles(); - + if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1) { for(File file : modsList) @@ -186,7 +186,7 @@ public class ThreadClientUpdate extends Thread } } } - + for(IModule module : Mekanism.modulesLoaded) { for(File file : modsList) @@ -197,16 +197,16 @@ public class ThreadClientUpdate extends Thread } } } - + System.out.println("[Mekanism] Preparing to update..."); } - + private static URL createURL() { try { return new URL("http://ci.aidancbrady.com/job/Mekanism/Recommended/artifact/*zip*/archive.zip"); } catch(Exception e) {} - + return null; } } diff --git a/common/mekanism/client/ThreadTankSparkle.java b/common/mekanism/client/ThreadTankSparkle.java index b925f8a4f..3b34bf3cb 100644 --- a/common/mekanism/client/ThreadTankSparkle.java +++ b/common/mekanism/client/ThreadTankSparkle.java @@ -17,16 +17,16 @@ import cpw.mods.fml.relauncher.SideOnly; public class ThreadTankSparkle extends Thread { public TileEntityDynamicTank pointer; - + public Random random = new Random(); - + public Set iteratedNodes = new HashSet(); - + public ThreadTankSparkle(TileEntityDynamicTank tileEntity) { pointer = tileEntity; } - + @Override public void run() { @@ -35,54 +35,54 @@ public class ThreadTankSparkle extends Thread { MekanismClient.audioHandler.quickPlay("cj/CJ_" + (random.nextInt(8)+1) + ".ogg", pointer.worldObj, Coord4D.get(pointer)); } - + loop(pointer); } catch(Exception e) {} } - + public void loop(TileEntityDynamicTank tileEntity) { World world = pointer.worldObj; - + for(int i = 0; i < 6; i++) { if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.DOWN, world)) { world.spawnParticle("reddust", tileEntity.xCoord + random.nextDouble(), tileEntity.yCoord + -.01, tileEntity.zCoord + random.nextDouble(), 0, 0, 0); } - + if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.UP, world)) { world.spawnParticle("reddust", tileEntity.xCoord + random.nextDouble(), tileEntity.yCoord + 1.01, tileEntity.zCoord + random.nextDouble(), 0, 0, 0); } - + if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.NORTH, world)) { world.spawnParticle("reddust", tileEntity.xCoord + random.nextDouble(), tileEntity.yCoord + random.nextDouble(), tileEntity.zCoord + -.01, 0, 0, 0); } - + if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.SOUTH, world)) { world.spawnParticle("reddust", tileEntity.xCoord + random.nextDouble(), tileEntity.yCoord + random.nextDouble(), tileEntity.zCoord + 1.01, 0, 0, 0); } - + if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.WEST, world)) { world.spawnParticle("reddust", tileEntity.xCoord + -.01, tileEntity.yCoord + random.nextDouble(), tileEntity.zCoord + random.nextDouble(), 0, 0, 0); } - + if(Coord4D.get(tileEntity).sideVisible(ForgeDirection.EAST, world)) { world.spawnParticle("reddust", tileEntity.xCoord + 1.01, tileEntity.yCoord + random.nextDouble(), tileEntity.zCoord + random.nextDouble(), 0, 0, 0); } } - + iteratedNodes.add(tileEntity); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = Coord4D.get(tileEntity).getFromSide(side).getTileEntity(pointer.worldObj); - + if(tile instanceof TileEntityDynamicTank && !iteratedNodes.contains(tile)) { loop((TileEntityDynamicTank)tile); diff --git a/common/mekanism/client/gui/GuiAdvancedElectricMachine.java b/common/mekanism/client/gui/GuiAdvancedElectricMachine.java index 4ba51a152..417696ec7 100644 --- a/common/mekanism/client/gui/GuiAdvancedElectricMachine.java +++ b/common/mekanism/client/gui/GuiAdvancedElectricMachine.java @@ -19,80 +19,80 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiAdvancedElectricMachine extends GuiMekanism { - public TileEntityAdvancedElectricMachine tileEntity; + public TileEntityAdvancedElectricMachine tileEntity; - public GuiAdvancedElectricMachine(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) - { - super(tentity, new ContainerAdvancedElectricMachine(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, tileEntity.guiLocation)); - } + public GuiAdvancedElectricMachine(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) + { + super(tentity, new ContainerAdvancedElectricMachine(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, tileEntity.guiLocation)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), (xSize/2)-(fontRenderer.getStringWidth(tileEntity.getInvName())/2), 6, 0x404040); - fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); - - if(xAxis >= 61 && xAxis <= 67 && yAxis >= 37 && yAxis <= 49) + + fontRenderer.drawString(tileEntity.getInvName(), (xSize/2)-(fontRenderer.getStringWidth(tileEntity.getInvName())/2), 6, 0x404040); + fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + + if(xAxis >= 61 && xAxis <= 67 && yAxis >= 37 && yAxis <= 49) { drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : MekanismUtils.localize("gui.none"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(tileEntity.guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + mc.renderEngine.bindTexture(tileEntity.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - displayInt = tileEntity.getScaledProgress(24); - drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7); - - if(tileEntity.getScaledGasLevel(12) > 0) - { - displayInt = tileEntity.getScaledGasLevel(12); - displayGauge(61, 37 + 12 - displayInt, 6, displayInt, tileEntity.gasTank.getGas()); - } + int displayInt; + + displayInt = tileEntity.getScaledProgress(24); + drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7); + + if(tileEntity.getScaledGasLevel(12) > 0) + { + displayInt = tileEntity.getScaledGasLevel(12); + displayGauge(61, 37 + 12 - displayInt, 6, displayInt, tileEntity.gasTank.getGas()); + } super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } - + public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) { - if(gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos, gas.getGas().getIcon(), sizeX, sizeY); } diff --git a/common/mekanism/client/gui/GuiBucket.java b/common/mekanism/client/gui/GuiBucket.java index b32e13d86..fbae92f4d 100644 --- a/common/mekanism/client/gui/GuiBucket.java +++ b/common/mekanism/client/gui/GuiBucket.java @@ -18,28 +18,28 @@ public class GuiBucket extends GuiElement { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiBucket.png"), gui, tile, def); } - + @Override public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - + guiObj.drawTexturedModalRect(guiWidth - 26, guiHeight + 4, 0, 0, 26, 57); - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void renderForeground(int xAxis, int yAxis) { mc.renderEngine.bindTexture(RESOURCE); - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void preMouseClicked(int xAxis, int yAxis, int button) {} - + @Override public void mouseClicked(int xAxis, int yAxis, int button) {} } diff --git a/common/mekanism/client/gui/GuiChanceMachine.java b/common/mekanism/client/gui/GuiChanceMachine.java index e08ac3e8a..dc86c56e2 100644 --- a/common/mekanism/client/gui/GuiChanceMachine.java +++ b/common/mekanism/client/gui/GuiChanceMachine.java @@ -13,55 +13,55 @@ import org.lwjgl.opengl.GL11; public class GuiChanceMachine extends GuiMekanism { - public TileEntityChanceMachine tileEntity; + public TileEntityChanceMachine tileEntity; - public GuiChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) - { - super(tentity, new ContainerChanceMachine(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, tileEntity.guiLocation)); - } + public GuiChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) + { + super(tentity, new ContainerChanceMachine(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, tileEntity.guiLocation)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(tileEntity.guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + mc.renderEngine.bindTexture(tileEntity.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledProgress(24); - drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7); + + int displayInt; + + displayInt = tileEntity.getScaledProgress(24); + drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } diff --git a/common/mekanism/client/gui/GuiChemicalCrystalizer.java b/common/mekanism/client/gui/GuiChemicalCrystalizer.java index e7e4dc693..4f2acd5e0 100644 --- a/common/mekanism/client/gui/GuiChemicalCrystalizer.java +++ b/common/mekanism/client/gui/GuiChemicalCrystalizer.java @@ -31,55 +31,55 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiChemicalCrystalizer extends GuiMekanism { - public TileEntityChemicalCrystalizer tileEntity; - - public Gas prevGas; - + public TileEntityChemicalCrystalizer tileEntity; + + public Gas prevGas; + public ItemStack renderStack; - + public int stackSwitch = 0; - + public int stackIndex = 0; - + public List iterStacks = new ArrayList(); - public GuiChemicalCrystalizer(InventoryPlayer inventory, TileEntityChemicalCrystalizer tentity) - { - super(tentity, new ContainerChemicalCrystalizer(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png"), 160, 23)); - guiElements.add(new GuiConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png"))); - } + public GuiChemicalCrystalizer(InventoryPlayer inventory, TileEntityChemicalCrystalizer tentity) + { + super(tentity, new ContainerChemicalCrystalizer(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png"))); + guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png"), 160, 23)); + guiElements.add(new GuiConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png"))); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png"))); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 37, 4, 0x404040); - - if(tileEntity.inputTank.getGas() != null) - { - fontRenderer.drawString(tileEntity.inputTank.getGas().getGas().getLocalizedName(), 29, 15, 0x00CD00); - - if(tileEntity.inputTank.getGas().getGas() instanceof OreGas) - { - fontRenderer.drawString("(" + ((OreGas)tileEntity.inputTank.getGas().getGas()).getOreName() + ")", 29, 24, 0x00CD00); - } - } - - if(renderStack != null) + + fontRenderer.drawString(tileEntity.getInvName(), 37, 4, 0x404040); + + if(tileEntity.inputTank.getGas() != null) + { + fontRenderer.drawString(tileEntity.inputTank.getGas().getGas().getLocalizedName(), 29, 15, 0x00CD00); + + if(tileEntity.inputTank.getGas().getGas() instanceof OreGas) + { + fontRenderer.drawString("(" + ((OreGas)tileEntity.inputTank.getGas().getGas()).getOreName() + ")", 29, 24, 0x00CD00); + } + } + + if(renderStack != null) { try { GL11.glPushMatrix(); @@ -89,109 +89,109 @@ public class GuiChemicalCrystalizer extends GuiMekanism GL11.glPopMatrix(); } catch(Exception e) {} } - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5 && yAxis <= 63) { drawCreativeTabHoveringText(tileEntity.inputTank.getGas() != null ? tileEntity.inputTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.inputTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - displayInt = tileEntity.getScaledProgress(48); - drawTexturedModalRect(guiWidth + 53, guiHeight + 61, 176, 63, displayInt, 8); - - if(tileEntity.getScaledInputGasLevel(58) > 0) - { - displayGauge(6, 5, tileEntity.getScaledInputGasLevel(58), null, tileEntity.inputTank.getGas()); - } - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } - - private Gas getInputGas() - { - return tileEntity.inputTank.getGas() != null ? tileEntity.inputTank.getGas().getGas() : null; - } - - private void resetStacks() - { - iterStacks.clear(); + int displayInt; + + displayInt = tileEntity.getScaledProgress(48); + drawTexturedModalRect(guiWidth + 53, guiHeight + 61, 176, 63, displayInt, 8); + + if(tileEntity.getScaledInputGasLevel(58) > 0) + { + displayGauge(6, 5, tileEntity.getScaledInputGasLevel(58), null, tileEntity.inputTank.getGas()); + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } + + private Gas getInputGas() + { + return tileEntity.inputTank.getGas() != null ? tileEntity.inputTank.getGas().getGas() : null; + } + + private void resetStacks() + { + iterStacks.clear(); renderStack = null; - stackSwitch = 0; - stackIndex = -1; - } - - @Override - protected void mouseClicked(int x, int y, int button) - { + stackSwitch = 0; + stackIndex = -1; + } + + @Override + protected void mouseClicked(int x, int y, int button) + { super.mouseClicked(x, y, button); - + if(button == 0) { int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - + if(xAxis > 24 && xAxis < 42 && yAxis > 56 && yAxis < 64) { ArrayList data = new ArrayList(); data.add(0); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - } - - @Override - public void updateScreen() - { - super.updateScreen(); - - if(prevGas != getInputGas()) - { - prevGas = getInputGas(); - - boolean reset = false; - - if(prevGas == null || !(prevGas instanceof OreGas) || !((OreGas)prevGas).isClean()) - { - reset = true; - resetStacks(); - } - - if(!reset) - { - OreGas gas = (OreGas)prevGas; - String oreDictName = "ore" + gas.getName().substring(5); - - updateStackList(oreDictName); - } - } - + } + + @Override + public void updateScreen() + { + super.updateScreen(); + + if(prevGas != getInputGas()) + { + prevGas = getInputGas(); + + boolean reset = false; + + if(prevGas == null || !(prevGas instanceof OreGas) || !((OreGas)prevGas).isClean()) + { + reset = true; + resetStacks(); + } + + if(!reset) + { + OreGas gas = (OreGas)prevGas; + String oreDictName = "ore" + gas.getName().substring(5); + + updateStackList(oreDictName); + } + } + if(stackSwitch > 0) { stackSwitch--; } - + if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) { stackSwitch = 20; - + if(stackIndex == -1 || stackIndex == iterStacks.size()-1) { stackIndex = 0; @@ -200,43 +200,43 @@ public class GuiChemicalCrystalizer extends GuiMekanism { stackIndex++; } - + renderStack = iterStacks.get(stackIndex); } else if(iterStacks != null && iterStacks.size() == 0) { renderStack = null; } - } - + } + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null && gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -245,7 +245,7 @@ public class GuiChemicalCrystalizer extends GuiMekanism { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) @@ -257,62 +257,62 @@ public class GuiChemicalCrystalizer extends GuiMekanism mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystalizer.png")); drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 4, 16, 59); } - - private void updateStackList(String oreName) - { - if(iterStacks == null) - { - iterStacks = new ArrayList(); - } - else { - iterStacks.clear(); - } - - List keys = new ArrayList(); - - for(String s : OreDictionary.getOreNames()) - { - if(oreName.equals(s) || oreName.equals("*")) - { - keys.add(s); - } - else if(oreName.endsWith("*") && !oreName.startsWith("*")) - { - if(s.startsWith(oreName.substring(0, oreName.length()-1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && !oreName.endsWith("*")) - { - if(s.endsWith(oreName.substring(1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && oreName.endsWith("*")) - { - if(s.contains(oreName.substring(1, oreName.length()-1))) - { - keys.add(s); - } - } - } - - for(String key : keys) - { - for(ItemStack stack : OreDictionary.getOres(key)) - { - ItemStack toAdd = stack.copy(); - - if(!iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) - { - iterStacks.add(stack.copy()); - } - } - } - - stackSwitch = 0; - stackIndex = -1; - } + + private void updateStackList(String oreName) + { + if(iterStacks == null) + { + iterStacks = new ArrayList(); + } + else { + iterStacks.clear(); + } + + List keys = new ArrayList(); + + for(String s : OreDictionary.getOreNames()) + { + if(oreName.equals(s) || oreName.equals("*")) + { + keys.add(s); + } + else if(oreName.endsWith("*") && !oreName.startsWith("*")) + { + if(s.startsWith(oreName.substring(0, oreName.length()-1))) + { + keys.add(s); + } + } + else if(oreName.startsWith("*") && !oreName.endsWith("*")) + { + if(s.endsWith(oreName.substring(1))) + { + keys.add(s); + } + } + else if(oreName.startsWith("*") && oreName.endsWith("*")) + { + if(s.contains(oreName.substring(1, oreName.length()-1))) + { + keys.add(s); + } + } + } + + for(String key : keys) + { + for(ItemStack stack : OreDictionary.getOres(key)) + { + ItemStack toAdd = stack.copy(); + + if(!iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) + { + iterStacks.add(stack.copy()); + } + } + } + + stackSwitch = 0; + stackIndex = -1; + } } diff --git a/common/mekanism/client/gui/GuiChemicalDissolutionChamber.java b/common/mekanism/client/gui/GuiChemicalDissolutionChamber.java index ab3844815..5d079dfa3 100644 --- a/common/mekanism/client/gui/GuiChemicalDissolutionChamber.java +++ b/common/mekanism/client/gui/GuiChemicalDissolutionChamber.java @@ -21,111 +21,111 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiChemicalDissolutionChamber extends GuiMekanism { - public TileEntityChemicalDissolutionChamber tileEntity; + public TileEntityChemicalDissolutionChamber tileEntity; - public GuiChemicalDissolutionChamber(InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tentity) - { - super(tentity, new ContainerChemicalDissolutionChamber(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"))); - } + public GuiChemicalDissolutionChamber(InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tentity) + { + super(tentity, new ContainerChemicalDissolutionChamber(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"))); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"))); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(MekanismUtils.localize("gui.chemicalDissolutionChamber.short"), 35, 4, 0x404040); - + + fontRenderer.drawString(MekanismUtils.localize("gui.chemicalDissolutionChamber.short"), 35, 4, 0x404040); + if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5 && yAxis <= 63) { drawCreativeTabHoveringText(tileEntity.injectTank.getGas() != null ? tileEntity.injectTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.injectTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.outputTank.getGas() != null ? tileEntity.outputTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.outputTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); - displayInt = tileEntity.getScaledProgress(48); - drawTexturedModalRect(guiWidth + 64, guiHeight + 40, 176, 63, displayInt, 8); - - if(tileEntity.getScaledInjectGasLevel(58) > 0) - { - displayGauge(6, 5, tileEntity.getScaledInjectGasLevel(58), null, tileEntity.injectTank.getGas()); - } - - if(tileEntity.getScaledOutputGasLevel(58) > 0) - { - displayGauge(134, 14, tileEntity.getScaledOutputGasLevel(58), null, tileEntity.outputTank.getGas()); - } - } - + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + + displayInt = tileEntity.getScaledProgress(48); + drawTexturedModalRect(guiWidth + 64, guiHeight + 40, 176, 63, displayInt, 8); + + if(tileEntity.getScaledInjectGasLevel(58) > 0) + { + displayGauge(6, 5, tileEntity.getScaledInjectGasLevel(58), null, tileEntity.injectTank.getGas()); + } + + if(tileEntity.getScaledOutputGasLevel(58) > 0) + { + displayGauge(134, 14, tileEntity.getScaledOutputGasLevel(58), null, tileEntity.outputTank.getGas()); + } + } + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null && gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -134,7 +134,7 @@ public class GuiChemicalDissolutionChamber extends GuiMekanism { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) diff --git a/common/mekanism/client/gui/GuiChemicalInfuser.java b/common/mekanism/client/gui/GuiChemicalInfuser.java index 65bf675b1..da8ef2c33 100644 --- a/common/mekanism/client/gui/GuiChemicalInfuser.java +++ b/common/mekanism/client/gui/GuiChemicalInfuser.java @@ -26,112 +26,112 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiChemicalInfuser extends GuiMekanism { - public TileEntityChemicalInfuser tileEntity; + public TileEntityChemicalInfuser tileEntity; - public GuiChemicalInfuser(InventoryPlayer inventory, TileEntityChemicalInfuser tentity) - { - super(tentity, new ContainerChemicalInfuser(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); - } + public GuiChemicalInfuser(InventoryPlayer inventory, TileEntityChemicalInfuser tentity) + { + super(tentity, new ContainerChemicalInfuser(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(MekanismUtils.localize("gui.chemicalInfuser.short"), 5, 5, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); - + + fontRenderer.drawString(MekanismUtils.localize("gui.chemicalInfuser.short"), 5, 5, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); + if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.leftTank.getGas() != null ? tileEntity.leftTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.leftTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.rightTank.getGas() != null ? tileEntity.rightTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.rightTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5 && yAxis <= 63) { drawCreativeTabHoveringText(tileEntity.centerTank.getGas() != null ? tileEntity.centerTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.centerTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); - if(tileEntity.isActive) - { - drawTexturedModalRect(guiWidth + 47, guiHeight + 39, 176, 71, 28, 8); - drawTexturedModalRect(guiWidth + 101, guiHeight + 39, 176, 63, 28, 8); - } - - if(tileEntity.getScaledLeftGasLevel(58) > 0) - { - displayGauge(26, 14, tileEntity.getScaledLeftGasLevel(58), null, tileEntity.leftTank.getGas()); - } - - if(tileEntity.getScaledRightGasLevel(58) > 0) - { - displayGauge(134, 14, tileEntity.getScaledRightGasLevel(58), null, tileEntity.rightTank.getGas()); - } - - if(tileEntity.getScaledCenterGasLevel(58) > 0) - { - displayGauge(80, 5, tileEntity.getScaledCenterGasLevel(58), null, tileEntity.centerTank.getGas()); - } - } - - @Override - protected void mouseClicked(int x, int y, int button) - { + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + + if(tileEntity.isActive) + { + drawTexturedModalRect(guiWidth + 47, guiHeight + 39, 176, 71, 28, 8); + drawTexturedModalRect(guiWidth + 101, guiHeight + 39, 176, 63, 28, 8); + } + + if(tileEntity.getScaledLeftGasLevel(58) > 0) + { + displayGauge(26, 14, tileEntity.getScaledLeftGasLevel(58), null, tileEntity.leftTank.getGas()); + } + + if(tileEntity.getScaledRightGasLevel(58) > 0) + { + displayGauge(134, 14, tileEntity.getScaledRightGasLevel(58), null, tileEntity.rightTank.getGas()); + } + + if(tileEntity.getScaledCenterGasLevel(58) > 0) + { + displayGauge(80, 5, tileEntity.getScaledCenterGasLevel(58), null, tileEntity.centerTank.getGas()); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) + { super.mouseClicked(x, y, button); - + if(button == 0) { int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - + if(xAxis > 44 && xAxis < 62 && yAxis > 13 && yAxis < 21) { ArrayList data = new ArrayList(); data.add(0); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } @@ -139,41 +139,41 @@ public class GuiChemicalInfuser extends GuiMekanism { ArrayList data = new ArrayList(); data.add(1); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - } - + } + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null && gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -182,7 +182,7 @@ public class GuiChemicalInfuser extends GuiMekanism { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) diff --git a/common/mekanism/client/gui/GuiChemicalOxidizer.java b/common/mekanism/client/gui/GuiChemicalOxidizer.java index 2d7c7f18a..02e0f239b 100644 --- a/common/mekanism/client/gui/GuiChemicalOxidizer.java +++ b/common/mekanism/client/gui/GuiChemicalOxidizer.java @@ -21,102 +21,102 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiChemicalOxidizer extends GuiMekanism { - public TileEntityChemicalOxidizer tileEntity; + public TileEntityChemicalOxidizer tileEntity; - public GuiChemicalOxidizer(InventoryPlayer inventory, TileEntityChemicalOxidizer tentity) - { - super(tentity, new ContainerChemicalOxidizer(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); - } + public GuiChemicalOxidizer(InventoryPlayer inventory, TileEntityChemicalOxidizer tentity) + { + super(tentity, new ContainerChemicalOxidizer(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); - displayInt = tileEntity.getScaledProgress(48); - drawTexturedModalRect(guiWidth + 64, guiHeight + 40, 176, 63, displayInt + 1, 8); - - if(tileEntity.getScaledGasLevel(58) > 0) - { - displayGauge(134, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank.getGas()); - } - } - + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + + displayInt = tileEntity.getScaledProgress(48); + drawTexturedModalRect(guiWidth + 64, guiHeight + 40, 176, 63, displayInt + 1, 8); + + if(tileEntity.getScaledGasLevel(58) > 0) + { + displayGauge(134, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank.getGas()); + } + } + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null && gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -125,7 +125,7 @@ public class GuiChemicalOxidizer extends GuiMekanism { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) diff --git a/common/mekanism/client/gui/GuiChemicalWasher.java b/common/mekanism/client/gui/GuiChemicalWasher.java index 929f345b2..80206d28b 100644 --- a/common/mekanism/client/gui/GuiChemicalWasher.java +++ b/common/mekanism/client/gui/GuiChemicalWasher.java @@ -26,145 +26,145 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiChemicalWasher extends GuiMekanism { - public TileEntityChemicalWasher tileEntity; + public TileEntityChemicalWasher tileEntity; - public GuiChemicalWasher(InventoryPlayer inventory, TileEntityChemicalWasher tentity) - { - super(tentity, new ContainerChemicalWasher(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); - guiElements.add(new GuiBucket(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); - } + public GuiChemicalWasher(InventoryPlayer inventory, TileEntityChemicalWasher tentity) + { + super(tentity, new ContainerChemicalWasher(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); + guiElements.add(new GuiBucket(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.ENERGY_USAGE); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 4, 0x404040); - + + fontRenderer.drawString(tileEntity.getInvName(), 45, 4, 0x404040); + if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5 && yAxis <= 63) { drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluidAmount() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 27 && xAxis <= 43 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.inputTank.getGas() != null ? tileEntity.inputTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.inputTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.outputTank.getGas() != null ? tileEntity.outputTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.outputTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); - if(tileEntity.isActive) - { - drawTexturedModalRect(guiWidth + 61, guiHeight + 39, 176, 63, 55, 8); - } - - if(tileEntity.getScaledFluidLevel(58) > 0) - { - displayGauge(6, 5, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null); - } - - if(tileEntity.getScaledInputGasLevel(58) > 0) - { - displayGauge(27, 14, tileEntity.getScaledInputGasLevel(58), null, tileEntity.inputTank.getGas()); - } - - if(tileEntity.getScaledOutputGasLevel(58) > 0) - { - displayGauge(134, 14, tileEntity.getScaledOutputGasLevel(58), null, tileEntity.outputTank.getGas()); - } - } - - @Override - protected void mouseClicked(int x, int y, int button) - { + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + + if(tileEntity.isActive) + { + drawTexturedModalRect(guiWidth + 61, guiHeight + 39, 176, 63, 55, 8); + } + + if(tileEntity.getScaledFluidLevel(58) > 0) + { + displayGauge(6, 5, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null); + } + + if(tileEntity.getScaledInputGasLevel(58) > 0) + { + displayGauge(27, 14, tileEntity.getScaledInputGasLevel(58), null, tileEntity.inputTank.getGas()); + } + + if(tileEntity.getScaledOutputGasLevel(58) > 0) + { + displayGauge(134, 14, tileEntity.getScaledOutputGasLevel(58), null, tileEntity.outputTank.getGas()); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) + { super.mouseClicked(x, y, button); - + if(button == 0) { int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - + if(xAxis > 45 && xAxis < 63 && yAxis > 13 && yAxis < 21) { ArrayList data = new ArrayList(); data.add(0); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - } - + } + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null && gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -173,7 +173,7 @@ public class GuiChemicalWasher extends GuiMekanism { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) diff --git a/common/mekanism/client/gui/GuiConfiguration.java b/common/mekanism/client/gui/GuiConfiguration.java index 090d8b5af..6380eaf89 100644 --- a/common/mekanism/client/gui/GuiConfiguration.java +++ b/common/mekanism/client/gui/GuiConfiguration.java @@ -29,177 +29,177 @@ import org.lwjgl.opengl.GL12; public class GuiConfiguration extends GuiMekanism { public Map slotPosMap = new HashMap(); - + public Map inputPosMap = new HashMap(); - - public IInvConfiguration configurable; - - public GuiConfiguration(EntityPlayer player, IInvConfiguration tile) - { - super(new ContainerNull(player, (TileEntityContainerBlock)tile)); - - ySize = 95; - - configurable = tile; - - slotPosMap.put(0, new GuiPos(126, 64)); - slotPosMap.put(1, new GuiPos(126, 34)); - slotPosMap.put(2, new GuiPos(126, 49)); - slotPosMap.put(3, new GuiPos(111, 64)); - slotPosMap.put(4, new GuiPos(111, 49)); - slotPosMap.put(5, new GuiPos(141, 49)); - - inputPosMap.put(0, new GuiPos(36, 64)); - inputPosMap.put(1, new GuiPos(36, 34)); - inputPosMap.put(2, new GuiPos(36, 49)); - inputPosMap.put(3, new GuiPos(21, 64)); - inputPosMap.put(4, new GuiPos(21, 49)); - inputPosMap.put(5, new GuiPos(51, 49)); - } - + + public IInvConfiguration configurable; + + public GuiConfiguration(EntityPlayer player, IInvConfiguration tile) + { + super(new ContainerNull(player, (TileEntityContainerBlock)tile)); + + ySize = 95; + + configurable = tile; + + slotPosMap.put(0, new GuiPos(126, 64)); + slotPosMap.put(1, new GuiPos(126, 34)); + slotPosMap.put(2, new GuiPos(126, 49)); + slotPosMap.put(3, new GuiPos(111, 64)); + slotPosMap.put(4, new GuiPos(111, 49)); + slotPosMap.put(5, new GuiPos(141, 49)); + + inputPosMap.put(0, new GuiPos(36, 64)); + inputPosMap.put(1, new GuiPos(36, 34)); + inputPosMap.put(2, new GuiPos(36, 49)); + inputPosMap.put(3, new GuiPos(21, 64)); + inputPosMap.put(4, new GuiPos(21, 49)); + inputPosMap.put(5, new GuiPos(51, 49)); + } + @Override protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiConfiguration.png")); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = (mouseX - (width - xSize) / 2); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiConfiguration.png")); + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) + + if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { - drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 14, 0, 14, 14); + drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 14, 0, 14, 14); } else { drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 14, 14, 14, 14); } - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) - { - drawTexturedModalRect(guiWidth + 156, guiHeight + 21, 176 + 42, 0, 14, 14); - } - else { + + if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) + { + drawTexturedModalRect(guiWidth + 156, guiHeight + 21, 176 + 42, 0, 14, 14); + } + else { drawTexturedModalRect(guiWidth + 156, guiHeight + 21, 176 + 42, 14, 14, 14); - } - - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 0, 14, 14); - } - else { + } + + if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) + { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 0, 14, 14); + } + else { drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 14, 14, 14); - } - - for(int i = 0; i < slotPosMap.size(); i++) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; - - SideData data = configurable.getSideData().get(configurable.getConfiguration()[i]); - - if(data.color != EnumColor.GREY) - { - GL11.glColor4f(data.color.getColor(0), data.color.getColor(1), data.color.getColor(2), 1); - } - - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 14, 14, 14); - } - } - - for(int i = 0; i < inputPosMap.size(); i++) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - int x = inputPosMap.get(i).xPos; - int y = inputPosMap.get(i).yPos; - - EnumColor color = configurable.getEjector().getInputColor(ForgeDirection.getOrientation(i)); - - if(color != null) - { - GL11.glColor4f(color.getColor(0), color.getColor(1), color.getColor(2), 1); - } - - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 14, 14, 14); - } - } - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + for(int i = 0; i < slotPosMap.size(); i++) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; + + SideData data = configurable.getSideData().get(configurable.getConfiguration()[i]); + + if(data.color != EnumColor.GREY) + { + GL11.glColor4f(data.color.getColor(0), data.color.getColor(1), data.color.getColor(2), 1); + } + + if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) + { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14); + } + else { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 14, 14, 14); + } + } + + for(int i = 0; i < inputPosMap.size(); i++) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + int x = inputPosMap.get(i).xPos; + int y = inputPosMap.get(i).yPos; + + EnumColor color = configurable.getEjector().getInputColor(ForgeDirection.getOrientation(i)); + + if(color != null) + { + GL11.glColor4f(color.getColor(0), color.getColor(1), color.getColor(2), 1); + } + + if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) + { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14); + } + else { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 14, 14, 14); + } + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(MekanismUtils.localize("gui.configuration"), 60, 5, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("gui.eject") + ": " + (configurable.getEjector().isEjecting() ? "On" : "Off"), 53, 17, 0x00CD00); - - fontRenderer.drawString(MekanismUtils.localize("gui.input") + " (" + (configurable.getEjector().hasStrictInput() ? "On" : "Off") + ")", 18, 81, 0x787878); - fontRenderer.drawString(MekanismUtils.localize("gui.output"), 72, 68, 0x787878); - fontRenderer.drawString(MekanismUtils.localize("gui.slots"), 122, 81, 0x787878); - - if(configurable.getEjector().getOutputColor() != null) - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - itemRenderer.renderIcon(80, 49, MekanismRenderer.getColorIcon(configurable.getEjector().getOutputColor()), 16, 16); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - for(int i = 0; i < slotPosMap.size(); i++) - { - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; - - SideData data = configurable.getSideData().get(configurable.getConfiguration()[i]); - - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - drawCreativeTabHoveringText(data.color != null ? data.color.getName() : MekanismUtils.localize("gui.none"), xAxis, yAxis); - } - } - - for(int i = 0; i < inputPosMap.size(); i++) - { - int x = inputPosMap.get(i).xPos; - int y = inputPosMap.get(i).yPos; - - EnumColor color = configurable.getEjector().getInputColor(ForgeDirection.getOrientation(i)); - - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - drawCreativeTabHoveringText(color != null ? color.getName() : MekanismUtils.localize("gui.none"), xAxis, yAxis); - } - } - - if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65) + + fontRenderer.drawString(MekanismUtils.localize("gui.configuration"), 60, 5, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("gui.eject") + ": " + (configurable.getEjector().isEjecting() ? "On" : "Off"), 53, 17, 0x00CD00); + + fontRenderer.drawString(MekanismUtils.localize("gui.input") + " (" + (configurable.getEjector().hasStrictInput() ? "On" : "Off") + ")", 18, 81, 0x787878); + fontRenderer.drawString(MekanismUtils.localize("gui.output"), 72, 68, 0x787878); + fontRenderer.drawString(MekanismUtils.localize("gui.slots"), 122, 81, 0x787878); + + if(configurable.getEjector().getOutputColor() != null) + { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + itemRenderer.renderIcon(80, 49, MekanismRenderer.getColorIcon(configurable.getEjector().getOutputColor()), 16, 16); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + for(int i = 0; i < slotPosMap.size(); i++) + { + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; + + SideData data = configurable.getSideData().get(configurable.getConfiguration()[i]); + + if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) + { + drawCreativeTabHoveringText(data.color != null ? data.color.getName() : MekanismUtils.localize("gui.none"), xAxis, yAxis); + } + } + + for(int i = 0; i < inputPosMap.size(); i++) + { + int x = inputPosMap.get(i).xPos; + int y = inputPosMap.get(i).yPos; + + EnumColor color = configurable.getEjector().getInputColor(ForgeDirection.getOrientation(i)); + + if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) + { + drawCreativeTabHoveringText(color != null ? color.getName() : MekanismUtils.localize("gui.none"), xAxis, yAxis); + } + } + + if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65) { if(configurable.getEjector().getOutputColor() != null) { @@ -209,106 +209,106 @@ public class GuiConfiguration extends GuiMekanism drawCreativeTabHoveringText(MekanismUtils.localize("gui.none"), xAxis, yAxis); } } - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) - { - drawCreativeTabHoveringText(MekanismUtils.localize("gui.autoEject"), xAxis, yAxis); - } - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) - { - drawCreativeTabHoveringText(MekanismUtils.localize("gui.configuration.strictInput"), xAxis, yAxis); - } - + + if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) + { + drawCreativeTabHoveringText(MekanismUtils.localize("gui.autoEject"), xAxis, yAxis); + } + + if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) + { + drawCreativeTabHoveringText(MekanismUtils.localize("gui.configuration.strictInput"), xAxis, yAxis); + } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); } - + @Override - public void updateScreen() + public void updateScreen() { super.updateScreen(); - + TileEntity tile = (TileEntity)configurable; - + if(tile == null || mc.theWorld.getBlockTileEntity(tile.xCoord, tile.yCoord, tile.zCoord) == null) { mc.displayGuiScreen(null); } } - + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + TileEntity tile = (TileEntity)configurable; - + if(button == 0) - { + { if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { int guiId = MachineType.get(tile.getBlockType().blockID, tile.getBlockMetadata()).guiId; mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketSimpleGui().setParams(Coord4D.get(tile), guiId)); } - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) - { - mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.EJECT, Coord4D.get(tile))); - } - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) - { - mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + + if(xAxis >= 156 && xAxis <= 170 && yAxis >= 21 && yAxis <= 35) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.STRICT_INPUT, Coord4D.get(tile))); - } + } } - + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { button = 2; } - - if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65) + + if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65) { - mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F); + mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.EJECT_COLOR, Coord4D.get(tile), button)); } - - for(int i = 0; i < slotPosMap.size(); i++) - { - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; - - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + for(int i = 0; i < slotPosMap.size(); i++) + { + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; + + if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.SIDE_DATA, Coord4D.get(tile), button, i)); - } - } - - for(int i = 0; i < inputPosMap.size(); i++) - { - int x = inputPosMap.get(i).xPos; - int y = inputPosMap.get(i).yPos; - - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + } + + for(int i = 0; i < inputPosMap.size(); i++) + { + int x = inputPosMap.get(i).xPos; + int y = inputPosMap.get(i).yPos; + + if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.INPUT_COLOR, Coord4D.get(tile), button, i)); - } - } + } + } } - + public static class GuiPos { public int xPos; public int yPos; - + public GuiPos(int x, int y) { xPos = x; diff --git a/common/mekanism/client/gui/GuiConfigurationTab.java b/common/mekanism/client/gui/GuiConfigurationTab.java index 2d74039dc..e44d40909 100644 --- a/common/mekanism/client/gui/GuiConfigurationTab.java +++ b/common/mekanism/client/gui/GuiConfigurationTab.java @@ -16,14 +16,14 @@ public class GuiConfigurationTab extends GuiElement { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiConfigurationTab.png"), gui, tile, def); } - + @Override public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - + guiObj.drawTexturedModalRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26); - + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { guiObj.drawTexturedModalRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18); @@ -31,31 +31,31 @@ public class GuiConfigurationTab extends GuiElement else { guiObj.drawTexturedModalRect(guiWidth - 21, guiHeight + 10, 26, 18, 18, 18); } - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void renderForeground(int xAxis, int yAxis) { mc.renderEngine.bindTexture(RESOURCE); - + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { displayTooltip(MekanismUtils.localize("gui.configuration"), xAxis, yAxis); } - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void preMouseClicked(int xAxis, int yAxis, int button) {} - + @Override public void mouseClicked(int xAxis, int yAxis, int button) { IRedstoneControl control = (IRedstoneControl)tileEntity; - + if(button == 0) { if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) diff --git a/common/mekanism/client/gui/GuiCredits.java b/common/mekanism/client/gui/GuiCredits.java index af7e02558..00c96d6bf 100644 --- a/common/mekanism/client/gui/GuiCredits.java +++ b/common/mekanism/client/gui/GuiCredits.java @@ -12,24 +12,24 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiCredits extends GuiScreen +public class GuiCredits extends GuiScreen { private static String updateProgress = ""; - + @Override public void initGui() { buttonList.clear(); buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 72 + 12, "Update")); buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel")); - ((GuiButton)buttonList.get(0)).enabled = !MekanismUtils.noUpdates() && !ThreadClientUpdate.hasUpdated; + ((GuiButton)buttonList.get(0)).enabled = !MekanismUtils.noUpdates() && !ThreadClientUpdate.hasUpdated; } - + public static void updateInfo(String info) { updateProgress = info; } - + @Override protected void actionPerformed(GuiButton guibutton) { @@ -39,7 +39,7 @@ public class GuiCredits extends GuiScreen { updateProgress = "Preparing to update..."; guibutton.enabled = false; - + new ThreadClientUpdate(); } else { @@ -51,53 +51,53 @@ public class GuiCredits extends GuiScreen mc.displayGuiScreen(null); } } - + public void writeText(String text, int yAxis) { drawString(fontRenderer, text, width / 2 - 140, (height / 4 - 60) + 20 + yAxis, 0xa0a0a0); } - + @Override public boolean doesGuiPauseGame() { return false; } - + @Override public void drawScreen(int mouseX, int mouseY, float partialTick) { drawDefaultBackground(); - drawCenteredString(fontRenderer, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff); - - if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null")) + drawCenteredString(fontRenderer, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff); + + if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null")) { - writeText(EnumColor.INDIGO + "Mekanism " + (Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1 ? EnumColor.DARK_RED : EnumColor.GREY) + Mekanism.versionNumber, 36); + writeText(EnumColor.INDIGO + "Mekanism " + (Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1 ? EnumColor.DARK_RED : EnumColor.GREY) + Mekanism.versionNumber, 36); } - else { - writeText(EnumColor.INDIGO + "Mekanism " + EnumColor.GREY + Mekanism.versionNumber, 36); - } - - int size = 36; - - for(IModule module : Mekanism.modulesLoaded) - { - size += 9; - - if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null")) - { - writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + (module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1 ? EnumColor.DARK_RED : EnumColor.GREY) + " " + module.getVersion(), size); - } - else { - writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + EnumColor.GREY + " " + module.getVersion(), size); - } + else { + writeText(EnumColor.INDIGO + "Mekanism " + EnumColor.GREY + Mekanism.versionNumber, 36); } - - writeText(EnumColor.GREY + "Newest version: " + Mekanism.latestVersionNumber, size+9); - writeText(EnumColor.GREY + "*Developed on Mac OS X 10.8 Mountain Lion", size+18); - writeText(EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", size+27); - writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews : "couldn't access."), size+36); - writeText(EnumColor.GREY + updateProgress, size+45); - - super.drawScreen(mouseX, mouseY, partialTick); + + int size = 36; + + for(IModule module : Mekanism.modulesLoaded) + { + size += 9; + + if(Mekanism.latestVersionNumber != null && !Mekanism.latestVersionNumber.equals("null")) + { + writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + (module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1 ? EnumColor.DARK_RED : EnumColor.GREY) + " " + module.getVersion(), size); + } + else { + writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + EnumColor.GREY + " " + module.getVersion(), size); + } + } + + writeText(EnumColor.GREY + "Newest version: " + Mekanism.latestVersionNumber, size+9); + writeText(EnumColor.GREY + "*Developed on Mac OS X 10.8 Mountain Lion", size+18); + writeText(EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", size+27); + writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews : "couldn't access."), size+36); + writeText(EnumColor.GREY + updateProgress, size+45); + + super.drawScreen(mouseX, mouseY, partialTick); } } diff --git a/common/mekanism/client/gui/GuiDictionary.java b/common/mekanism/client/gui/GuiDictionary.java index 628dda121..1a75d55f6 100644 --- a/common/mekanism/client/gui/GuiDictionary.java +++ b/common/mekanism/client/gui/GuiDictionary.java @@ -15,42 +15,42 @@ import org.lwjgl.opengl.GL11; public class GuiDictionary extends GuiMekanism { - public ItemStack itemType; - - public List oreDictNames; - + public ItemStack itemType; + + public List oreDictNames; + public GuiDictionary(InventoryPlayer inventory) { super(new ContainerDictionary(inventory)); } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(MekanismUtils.localize("item.Dictionary.name"), 64, 5, 0x404040); + + fontRenderer.drawString(MekanismUtils.localize("item.Dictionary.name"), 64, 5, 0x404040); fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); - - if(itemType != null) - { - if(!oreDictNames.isEmpty()) - { - int currentY = 57; - - for(String name : oreDictNames) - { - fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.key") + ": " + name, 9, currentY, 0x00CD00); - currentY += 9; - } - } - else { - fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.noKey"), 9, 57, 0x00CD00); - } - } - - if(itemType != null) + + if(itemType != null) + { + if(!oreDictNames.isEmpty()) + { + int currentY = 57; + + for(String name : oreDictNames) + { + fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.key") + ": " + name, 9, currentY, 0x00CD00); + currentY += 9; + } + } + else { + fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.noKey"), 9, 57, 0x00CD00); + } + } + + if(itemType != null) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_LIGHTING); @@ -58,40 +58,40 @@ public class GuiDictionary extends GuiMekanism GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); } - + @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDictionary.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; - - if(xAxis >= 80 && xAxis <= 96 && yAxis >= 23 && yAxis <= 39) + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + if(xAxis >= 80 && xAxis <= 96 && yAxis >= 23 && yAxis <= 39) { GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - int x = guiWidth + 80; - int y = guiHeight + 23; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int x = guiWidth + 80; + int y = guiHeight + 23; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); } - } - + } + @Override public boolean doesGuiPauseGame() { @@ -109,35 +109,35 @@ public class GuiDictionary extends GuiMekanism if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { Slot hovering = null; - - for(int i = 0; i < inventorySlots.inventorySlots.size(); i++) - { - Slot slot = (Slot)inventorySlots.inventorySlots.get(i); - - if(isMouseOverSlot(slot, mouseX, mouseY)) - { - hovering = slot; - break; - } - } - - if(hovering != null) - { - ItemStack stack = hovering.getStack(); - - if(stack != null) - { - itemType = stack.copy(); + + for(int i = 0; i < inventorySlots.inventorySlots.size(); i++) + { + Slot slot = (Slot)inventorySlots.inventorySlots.get(i); + + if(isMouseOverSlot(slot, mouseX, mouseY)) + { + hovering = slot; + break; + } + } + + if(hovering != null) + { + ItemStack stack = hovering.getStack(); + + if(stack != null) + { + itemType = stack.copy(); itemType.stackSize = 1; - + oreDictNames = MekanismUtils.getOreDictName(itemType); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - - return; - } - } + + return; + } + } } - + if(xAxis >= 80 && xAxis <= 96 && yAxis >= 23 && yAxis <= 39) { ItemStack stack = mc.thePlayer.inventory.getItemStack(); @@ -146,7 +146,7 @@ public class GuiDictionary extends GuiMekanism { itemType = stack.copy(); itemType.stackSize = 1; - + oreDictNames = MekanismUtils.getOreDictName(itemType); } else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) @@ -158,7 +158,7 @@ public class GuiDictionary extends GuiMekanism mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - + super.mouseClicked(mouseX, mouseY, button); } } diff --git a/common/mekanism/client/gui/GuiDigitalMiner.java b/common/mekanism/client/gui/GuiDigitalMiner.java index 762495f49..cdf9bd2d3 100644 --- a/common/mekanism/client/gui/GuiDigitalMiner.java +++ b/common/mekanism/client/gui/GuiDigitalMiner.java @@ -32,82 +32,82 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiDigitalMiner extends GuiMekanism { public TileEntityDigitalMiner tileEntity; - + public GuiButton startButton; public GuiButton stopButton; public GuiButton configButton; - public GuiDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity) - { - super(new ContainerDigitalMiner(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); - guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_USAGE)); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); - - ySize+=64; - } - + public GuiDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity) + { + super(new ContainerDigitalMiner(inventory, tentity)); + tileEntity = tentity; + + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); + guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_USAGE)); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); + + ySize+=64; + } + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); startButton = new GuiButton(0, guiWidth + 69, guiHeight + 17, 60, 20, MekanismUtils.localize("gui.start")); - + if(tileEntity.searcher.state != State.IDLE && tileEntity.running) { startButton.enabled = false; } - + stopButton = new GuiButton(1, guiWidth + 69, guiHeight + 37, 60, 20, MekanismUtils.localize("gui.stop")); - + if(tileEntity.searcher.state == State.IDLE || !tileEntity.running) { stopButton.enabled = false; } - + configButton = new GuiButton(2, guiWidth + 69, guiHeight + 57, 60, 20, MekanismUtils.localize("gui.config")); - + if(tileEntity.searcher.state != State.IDLE) { configButton.enabled = false; } - + buttonList.add(startButton); buttonList.add(stopButton); buttonList.add(configButton); } - + @Override protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - + if(guibutton.id == 0) { ArrayList data = new ArrayList(); data.add(3); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); } else if(guibutton.id == 1) { ArrayList data = new ArrayList(); data.add(4); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); } else if(guibutton.id == 2) @@ -115,12 +115,12 @@ public class GuiDigitalMiner extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } } - + @Override public void updateScreen() { super.updateScreen(); - + if(tileEntity.searcher.state != State.IDLE && tileEntity.running) { startButton.enabled = false; @@ -128,7 +128,7 @@ public class GuiDigitalMiner extends GuiMekanism else { startButton.enabled = true; } - + if(tileEntity.searcher.state == State.IDLE || !tileEntity.running) { stopButton.enabled = false; @@ -136,7 +136,7 @@ public class GuiDigitalMiner extends GuiMekanism else { stopButton.enabled = true; } - + if(tileEntity.searcher.state != State.IDLE) { configButton.enabled = false; @@ -146,26 +146,26 @@ public class GuiDigitalMiner extends GuiMekanism } } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 69, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - fontRenderer.drawString(tileEntity.running ? MekanismUtils.localize("gui.digitalMiner.running") : MekanismUtils.localize("gui.idle"), 9, 10, 0x00CD00); - fontRenderer.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00); - - fontRenderer.drawString(MekanismUtils.localize("gui.eject") + ": " + MekanismUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), 9, 30, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.pull") + ": " + MekanismUtils.localize("gui." + (tileEntity.doPull ? "on" : "off")), 9, 39, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.silk") + ": " + MekanismUtils.localize("gui." + (tileEntity.silkTouch ? "on" : "off")), 9, 48, 0x00CD00); - - fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.toMine") + ":", 9, 59, 0x00CD00); - fontRenderer.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00); - - if(tileEntity.replaceStack != null) + + fontRenderer.drawString(tileEntity.getInvName(), 69, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + + fontRenderer.drawString(tileEntity.running ? MekanismUtils.localize("gui.digitalMiner.running") : MekanismUtils.localize("gui.idle"), 9, 10, 0x00CD00); + fontRenderer.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00); + + fontRenderer.drawString(MekanismUtils.localize("gui.eject") + ": " + MekanismUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), 9, 30, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.pull") + ": " + MekanismUtils.localize("gui." + (tileEntity.doPull ? "on" : "off")), 9, 39, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.silk") + ": " + MekanismUtils.localize("gui." + (tileEntity.silkTouch ? "on" : "off")), 9, 48, 0x00CD00); + + fontRenderer.drawString(MekanismUtils.localize("gui.digitalMiner.toMine") + ":", 9, 59, 0x00CD00); + fontRenderer.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00); + + if(tileEntity.replaceStack != null) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_LIGHTING); @@ -173,59 +173,59 @@ public class GuiDigitalMiner extends GuiMekanism GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + if(xAxis >= 164 && xAxis <= 168 && yAxis >= 25 && yAxis <= 77) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.autoEject"), xAxis, yAxis); } - + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.digitalMiner.autoPull"), xAxis, yAxis); } - + if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.digitalMiner.replaceBlock"), xAxis, yAxis); } - + if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.digitalMiner.reset"), xAxis, yAxis); } - + if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.digitalMiner.silkTouch"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); } - + @Override protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 164, guiHeight + 25 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - + + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 164, guiHeight + 25 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) { drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 0, 14, 14); @@ -233,7 +233,7 @@ public class GuiDigitalMiner extends GuiMekanism else { drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 14, 14, 14); } - + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) { drawTexturedModalRect(guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 0, 14, 14); @@ -241,7 +241,7 @@ public class GuiDigitalMiner extends GuiMekanism else { drawTexturedModalRect(guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 14, 14, 14); } - + if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) { drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 0, 14, 14); @@ -249,7 +249,7 @@ public class GuiDigitalMiner extends GuiMekanism else { drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 14, 14, 14); } - + if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) { drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 0, 14, 14); @@ -257,79 +257,79 @@ public class GuiDigitalMiner extends GuiMekanism else { drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 14, 14, 14); } - + if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43) { GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - int x = guiWidth + 144; - int y = guiHeight + 27; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int x = guiWidth + 144; + int y = guiHeight + 27; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); } } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - if(button == 0) + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - + ArrayList data = new ArrayList(); data.add(0); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); } - + if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - + ArrayList data = new ArrayList(); data.add(1); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); } - + if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - + ArrayList data = new ArrayList(); data.add(5); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); } - + if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - + ArrayList data = new ArrayList(); data.add(9); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); } - + if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43) { boolean doNull = false; ItemStack stack = mc.thePlayer.inventory.getItemStack(); ItemStack toUse = null; - + if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { if(stack.getItem() instanceof ItemBlock) @@ -345,12 +345,12 @@ public class GuiDigitalMiner extends GuiMekanism { doNull = true; } - + if(toUse != null || doNull) { ArrayList data = new ArrayList(); data.add(2); - + if(stack != null) { data.add(false); @@ -360,12 +360,12 @@ public class GuiDigitalMiner extends GuiMekanism else { data.add(true); } - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); } - - mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - } + } } diff --git a/common/mekanism/client/gui/GuiDigitalMinerConfig.java b/common/mekanism/client/gui/GuiDigitalMinerConfig.java index 58343e943..55912f963 100644 --- a/common/mekanism/client/gui/GuiDigitalMinerConfig.java +++ b/common/mekanism/client/gui/GuiDigitalMinerConfig.java @@ -33,56 +33,56 @@ import org.lwjgl.opengl.GL11; public class GuiDigitalMinerConfig extends GuiMekanism { public TileEntityDigitalMiner tileEntity; - + public boolean isDragging = false; - + public int dragOffset = 0; - + public int stackSwitch = 0; - + public Map oreDictStacks = new HashMap(); - + public float scroll; - + private GuiTextField radiusField; private GuiTextField minField; private GuiTextField maxField; - + public GuiDigitalMinerConfig(EntityPlayer player, TileEntityDigitalMiner tentity) { super(new ContainerNull(player, tentity)); tileEntity = tentity; } - + public int getScroll() { return Math.max(Math.min((int)(scroll*123), 123), 0); } - + public int getFilterIndex() { if(tileEntity.filters.size() <= 4) { return 0; } - + return (int)((tileEntity.filters.size()*scroll) - ((4F/(float)tileEntity.filters.size()))*scroll); } - + @Override public void updateScreen() { super.updateScreen(); - + radiusField.updateCursorCounter(); minField.updateCursorCounter(); maxField.updateCursorCounter(); - + if(stackSwitch > 0) { stackSwitch--; } - + if(stackSwitch == 0) { for(Map.Entry entry : oreDictStacks.entrySet()) @@ -97,11 +97,11 @@ public class GuiDigitalMinerConfig extends GuiMekanism { entry.getValue().stackIndex++; } - + entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); } } - + stackSwitch = 20; } else { @@ -113,9 +113,9 @@ public class GuiDigitalMinerConfig extends GuiMekanism } } } - + Set filtersVisible = new HashSet(); - + for(int i = 0; i < 4; i++) { if(tileEntity.filters.get(getFilterIndex()+i) instanceof MOreDictFilter) @@ -123,7 +123,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism filtersVisible.add((MOreDictFilter)tileEntity.filters.get(getFilterIndex()+i)); } } - + for(MinerFilter filter : tileEntity.filters) { if(filter instanceof MOreDictFilter && !filtersVisible.contains(filter)) @@ -135,37 +135,37 @@ public class GuiDigitalMinerConfig extends GuiMekanism } } } - + @Override public void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + radiusField.mouseClicked(mouseX, mouseY, button); minField.mouseClicked(mouseX, mouseY, button); maxField.mouseClicked(mouseX, mouseY, button); - + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15) { dragOffset = yAxis - (getScroll()+18); isDragging = true; } - + for(int i = 0; i < 4; i++) { if(tileEntity.filters.get(getFilterIndex()+i) != null) { int yStart = i*29 + 18; - + if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29) { MinerFilter filter = tileEntity.filters.get(getFilterIndex()+i); - + if(filter instanceof MItemStackFilter) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); @@ -179,104 +179,104 @@ public class GuiDigitalMinerConfig extends GuiMekanism } } } - + if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 3)); } - + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); setRadius(); } - + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 92 && yAxis <= 103) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); setMinY(); } - + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 117 && yAxis <= 128) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); setMaxY(); } - + if(xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) { ArrayList data = new ArrayList(); data.add(10); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } } - + @Override protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) { super.mouseClickMove(mouseX, mouseY, button, ticks); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(isDragging) { scroll = Math.min(Math.max((float)(yAxis-18-dragOffset)/123F, 0), 1); } } - + @Override protected void mouseMovedOrUp(int x, int y, int type) { super.mouseMovedOrUp(x, y, type); - + if(type == 0 && isDragging) { dragOffset = 0; isDragging = false; } } - + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 56, guiHeight + 136, 54, 20, MekanismUtils.localize("gui.itemstack"))); buttonList.add(new GuiButton(1, guiWidth + 110, guiHeight + 136, 43, 20, MekanismUtils.localize("gui.oredict"))); - + String prevRad = radiusField != null ? radiusField.getText() : ""; String prevMin = minField != null ? minField.getText() : ""; String prevMax = maxField != null ? maxField.getText() : ""; - + radiusField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 67, 26, 11); radiusField.setMaxStringLength(2); radiusField.setText(prevRad); - + minField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 92, 26, 11); minField.setMaxStringLength(3); minField.setText(prevMin); - + maxField = new GuiTextField(fontRenderer, guiWidth + 12, guiHeight + 117, 26, 11); maxField.setMaxStringLength(3); maxField.setText(prevMax); } - + @Override protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - + if(guibutton.id == 0) - { + { PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 1)); } else if(guibutton.id == 1) @@ -284,38 +284,38 @@ public class GuiDigitalMinerConfig extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 2)); } } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + fontRenderer.drawString(MekanismUtils.localize("gui.digitalMinerConfig"), 43, 6, 0x404040); - + fontRenderer.drawString(MekanismUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00); fontRenderer.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00); fontRenderer.drawString("IS: " + getItemStackFilters().size(), 11, 37, 0x00CD00); fontRenderer.drawString("OD: " + getOreDictFilters().size(), 11, 46, 0x00CD00); fontRenderer.drawString("I: " + (tileEntity.inverse ? MekanismUtils.localize("gui.on") : MekanismUtils.localize("gui.off")), 11, 131, 0x00CD00); - + fontRenderer.drawString("Radi: " + tileEntity.radius, 11, 58, 0x00CD00); - + fontRenderer.drawString("Min: " + tileEntity.minY, 11, 83, 0x00CD00); - + fontRenderer.drawString("Max: " + tileEntity.maxY, 11, 108, 0x00CD00); - + for(int i = 0; i < 4; i++) { if(tileEntity.filters.get(getFilterIndex()+i) != null) { MinerFilter filter = tileEntity.filters.get(getFilterIndex()+i); int yStart = i*29 + 18; - + if(filter instanceof MItemStackFilter) { MItemStackFilter itemFilter = (MItemStackFilter)filter; - + if(itemFilter.itemType != null) { GL11.glPushMatrix(); @@ -324,18 +324,18 @@ public class GuiDigitalMinerConfig extends GuiMekanism GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + fontRenderer.drawString(MekanismUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040); } else if(filter instanceof MOreDictFilter) { MOreDictFilter oreFilter = (MOreDictFilter)filter; - + if(!oreDictStacks.containsKey(oreFilter)) { updateStackList(oreFilter); } - + if(oreDictStacks.get(filter).renderStack != null) { try { @@ -346,45 +346,45 @@ public class GuiDigitalMinerConfig extends GuiMekanism GL11.glPopMatrix(); } catch(Exception e) {} } - + fontRenderer.drawString(MekanismUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040); } } } - + if(xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.digitalMiner.inverse"), xAxis, yAxis); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMinerConfig.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + drawTexturedModalRect(guiWidth + 154, guiHeight + 18 + getScroll(), 232, 0, 12, 15); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + for(int i = 0; i < 4; i++) { if(tileEntity.filters.get(getFilterIndex()+i) != null) { MinerFilter filter = tileEntity.filters.get(getFilterIndex()+i); int yStart = i*29 + 18; - + boolean mouseOver = xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29; - + if(filter instanceof MItemStackFilter) { drawTexturedModalRect(guiWidth + 56, guiHeight + yStart, mouseOver ? 0 : 96, 166, 96, 29); @@ -395,7 +395,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism } } } - + if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); @@ -403,7 +403,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism else { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); } - + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) { drawTexturedModalRect(guiWidth + 39, guiHeight + 67, 176 + 11, 0, 11, 11); @@ -411,7 +411,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism else { drawTexturedModalRect(guiWidth + 39, guiHeight + 67, 176 + 11, 11, 11, 11); } - + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 92 && yAxis <= 103) { drawTexturedModalRect(guiWidth + 39, guiHeight + 92, 176 + 11, 0, 11, 11); @@ -419,7 +419,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism else { drawTexturedModalRect(guiWidth + 39, guiHeight + 92, 176 + 11, 11, 11, 11); } - + if(xAxis >= 39 && xAxis <= 50 && yAxis >= 117 && yAxis <= 128) { drawTexturedModalRect(guiWidth + 39, guiHeight + 117, 176 + 11, 0, 11, 11); @@ -427,7 +427,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism else { drawTexturedModalRect(guiWidth + 39, guiHeight + 117, 176 + 11, 11, 11, 11); } - + if(xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) { drawTexturedModalRect(guiWidth + 11, guiHeight + 141, 176 + 22, 0, 14, 14); @@ -435,12 +435,12 @@ public class GuiDigitalMinerConfig extends GuiMekanism else { drawTexturedModalRect(guiWidth + 11, guiHeight + 141, 176 + 22, 14, 14, 14); } - + radiusField.drawTextBox(); minField.drawTextBox(); maxField.drawTextBox(); - } - + } + @Override public void keyTyped(char c, int i) { @@ -448,7 +448,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism { super.keyTyped(c, i); } - + if(i == Keyboard.KEY_RETURN) { if(radiusField.isFocused()) @@ -464,7 +464,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism setMaxY(); } } - + if(Character.isDigit(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT) { radiusField.textboxKeyTyped(c, i); @@ -472,59 +472,59 @@ public class GuiDigitalMinerConfig extends GuiMekanism maxField.textboxKeyTyped(c, i); } } - + private void setRadius() { if(!radiusField.getText().isEmpty()) { int toUse = Math.max(0, Math.min(Integer.parseInt(radiusField.getText()), 32)); - + ArrayList data = new ArrayList(); data.add(6); data.add(toUse); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); - + radiusField.setText(""); } } - + private void setMinY() { if(!minField.getText().isEmpty()) { int toUse = Math.max(0, Math.min(Integer.parseInt(minField.getText()), tileEntity.maxY)); - + ArrayList data = new ArrayList(); data.add(7); data.add(toUse); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); - + minField.setText(""); } } - + private void setMaxY() { if(!maxField.getText().isEmpty()) { int toUse = Math.max(tileEntity.minY, Math.min(Integer.parseInt(maxField.getText()), 255)); - + ArrayList data = new ArrayList(); data.add(8); data.add(toUse); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); - + maxField.setText(""); } } - + public ArrayList getItemStackFilters() { ArrayList list = new ArrayList(); - + for(MinerFilter filter : tileEntity.filters) { if(filter instanceof MItemStackFilter) @@ -532,14 +532,14 @@ public class GuiDigitalMinerConfig extends GuiMekanism list.add(filter); } } - + return list; } - + public ArrayList getOreDictFilters() { ArrayList list = new ArrayList(); - + for(MinerFilter filter : tileEntity.filters) { if(filter instanceof MOreDictFilter) @@ -547,74 +547,74 @@ public class GuiDigitalMinerConfig extends GuiMekanism list.add(filter); } } - + return list; } - + private void updateStackList(MOreDictFilter filter) { if(!oreDictStacks.containsKey(filter)) { oreDictStacks.put(filter, new StackData()); } - - if(oreDictStacks.get(filter).iterStacks == null) - { - oreDictStacks.get(filter).iterStacks = new ArrayList(); - } - else { - oreDictStacks.get(filter).iterStacks.clear(); - } - - List keys = new ArrayList(); - - for(String s : OreDictionary.getOreNames()) - { - if(filter.oreDictName.equals(s) || filter.oreDictName.equals("*")) - { - keys.add(s); - } - else if(filter.oreDictName.endsWith("*") && !filter.oreDictName.startsWith("*")) - { - if(s.startsWith(filter.oreDictName.substring(0, filter.oreDictName.length()-1))) - { - keys.add(s); - } - } - else if(filter.oreDictName.startsWith("*") && !filter.oreDictName.endsWith("*")) - { - if(s.endsWith(filter.oreDictName.substring(1))) - { - keys.add(s); - } - } - else if(filter.oreDictName.startsWith("*") && filter.oreDictName.endsWith("*")) - { - if(s.contains(filter.oreDictName.substring(1, filter.oreDictName.length()-1))) - { - keys.add(s); - } - } - } - - for(String key : keys) - { - for(ItemStack stack : OreDictionary.getOres(key)) - { - ItemStack toAdd = stack.copy(); - - if(!oreDictStacks.get(filter).iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) - { - oreDictStacks.get(filter).iterStacks.add(stack.copy()); - } - } - } - - stackSwitch = 0; - updateScreen(); - oreDictStacks.get(filter).stackIndex = -1; - } - + + if(oreDictStacks.get(filter).iterStacks == null) + { + oreDictStacks.get(filter).iterStacks = new ArrayList(); + } + else { + oreDictStacks.get(filter).iterStacks.clear(); + } + + List keys = new ArrayList(); + + for(String s : OreDictionary.getOreNames()) + { + if(filter.oreDictName.equals(s) || filter.oreDictName.equals("*")) + { + keys.add(s); + } + else if(filter.oreDictName.endsWith("*") && !filter.oreDictName.startsWith("*")) + { + if(s.startsWith(filter.oreDictName.substring(0, filter.oreDictName.length()-1))) + { + keys.add(s); + } + } + else if(filter.oreDictName.startsWith("*") && !filter.oreDictName.endsWith("*")) + { + if(s.endsWith(filter.oreDictName.substring(1))) + { + keys.add(s); + } + } + else if(filter.oreDictName.startsWith("*") && filter.oreDictName.endsWith("*")) + { + if(s.contains(filter.oreDictName.substring(1, filter.oreDictName.length()-1))) + { + keys.add(s); + } + } + } + + for(String key : keys) + { + for(ItemStack stack : OreDictionary.getOres(key)) + { + ItemStack toAdd = stack.copy(); + + if(!oreDictStacks.get(filter).iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) + { + oreDictStacks.get(filter).iterStacks.add(stack.copy()); + } + } + } + + stackSwitch = 0; + updateScreen(); + oreDictStacks.get(filter).stackIndex = -1; + } + public static class StackData { public List iterStacks; diff --git a/common/mekanism/client/gui/GuiDynamicTank.java b/common/mekanism/client/gui/GuiDynamicTank.java index 18cff50f2..231beaf58 100644 --- a/common/mekanism/client/gui/GuiDynamicTank.java +++ b/common/mekanism/client/gui/GuiDynamicTank.java @@ -18,76 +18,76 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiDynamicTank extends GuiMekanism { public TileEntityDynamicTank tileEntity; - + public GuiDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity) - { - super(new ContainerDynamicTank(inventory, tentity)); - tileEntity = tentity; - } - + { + super(new ContainerDynamicTank(inventory, tentity)); + tileEntity = tentity; + } + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity/TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00); - fontRenderer.drawString(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getName() + ":" : MekanismUtils.localize("gui.noFluid"), 53, 44, 0x00CD00); - - if(tileEntity.structure.fluidStored != null) - { - fontRenderer.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00); - } - + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity/TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00); + fontRenderer.drawString(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getName() + ":" : MekanismUtils.localize("gui.noFluid"), 53, 44, 0x00CD00); + + if(tileEntity.structure.fluidStored != null) + { + fontRenderer.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00); + } + if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getLocalizedName() + ": " + tileEntity.structure.fluidStored.amount + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - if(tileEntity.getScaledFluidLevel(58) > 0) - { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + if(tileEntity.getScaledFluidLevel(58) > 0) + { displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 0); displayGauge(23, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 1); } - } - + } + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/) { - if(fluid == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; diff --git a/common/mekanism/client/gui/GuiElectricChest.java b/common/mekanism/client/gui/GuiElectricChest.java index 7e217868d..77e7b88cb 100644 --- a/common/mekanism/client/gui/GuiElectricChest.java +++ b/common/mekanism/client/gui/GuiElectricChest.java @@ -31,50 +31,50 @@ public class GuiElectricChest extends GuiMekanism public TileEntityElectricChest tileEntity; public IInventory itemInventory; public boolean isBlock; - + public GuiElectricChest(InventoryPlayer inventory, TileEntityElectricChest tentity) - { - super(new ContainerElectricChest(inventory, tentity, null, true)); - - xSize+=26; - ySize+=64; - tileEntity = tentity; - isBlock = true; - } - + { + super(new ContainerElectricChest(inventory, tentity, null, true)); + + xSize+=26; + ySize+=64; + tileEntity = tentity; + isBlock = true; + } + public GuiElectricChest(InventoryPlayer inventory, IInventory inv) - { - super(new ContainerElectricChest(inventory, null, inv, false)); - - xSize+=26; - ySize+=64; - itemInventory = inv; - isBlock = false; - } - + { + super(new ContainerElectricChest(inventory, null, inv, false)); + + xSize+=26; + ySize+=64; + itemInventory = inv; + isBlock = false; + } + @Override - public void onGuiClosed() + public void onGuiClosed() { super.onGuiClosed(); - + if(!isBlock) { mc.sndManager.playSoundFX("random.chestclosed", 1.0F, 1.0F); } } - + @Override public void initGui() { super.initGui(); - + int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 93, guiHeight + 4, 76, 20, MekanismUtils.localize("gui.electricChest.editPassword"))); } - + @Override protected void actionPerformed(GuiButton guibutton) { @@ -92,43 +92,43 @@ public class GuiElectricChest extends GuiMekanism @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(MekanismUtils.localize("tile.MachineBlock.ElectricChest.name"), 8, 6, 0x404040); - fontRenderer.drawString(getLocked() ? EnumColor.DARK_RED + "Locked" : EnumColor.BRIGHT_GREEN + "Unlocked", 97, 137, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - if(xAxis >= 180 && xAxis <= 184 && yAxis >= 32 && yAxis <= 84) + + fontRenderer.drawString(MekanismUtils.localize("tile.MachineBlock.ElectricChest.name"), 8, 6, 0x404040); + fontRenderer.drawString(getLocked() ? EnumColor.DARK_RED + "Locked" : EnumColor.BRIGHT_GREEN + "Unlocked", 97, 137, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + + if(xAxis >= 180 && xAxis <= 184 && yAxis >= 32 && yAxis <= 84) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(getEnergy()), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 88 && yAxis <= 106) - { + { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); - + if(isBlock) { PacketHandler.sendPacket(Transmission.SERVER, new PacketElectricChest().setParams(ElectricChestPacketType.LOCK, !getLocked(), true, Coord4D.get(tileEntity))); } else { PacketHandler.sendPacket(Transmission.SERVER, new PacketElectricChest().setParams(ElectricChestPacketType.LOCK, !getLocked(), false)); - + ItemStack stack = mc.thePlayer.getCurrentEquippedItem(); ((IElectricChest)stack.getItem()).setLocked(stack, !getLocked()); } @@ -137,17 +137,17 @@ public class GuiElectricChest extends GuiMekanism } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectricChest.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 88 && yAxis <= 106) { drawTexturedModalRect(guiWidth + 179, guiHeight + 88, 176 + 26, 52, 18, 18); @@ -155,11 +155,11 @@ public class GuiElectricChest extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 88, 176 + 26, 70, 18, 18); } - - int displayInt = getScale(); - drawTexturedModalRect(guiWidth + 180, guiHeight + 32 + 52 - displayInt, 176 + 26, 52 - displayInt, 4, displayInt); - } - + + int displayInt = getScale(); + drawTexturedModalRect(guiWidth + 180, guiHeight + 32 + 52 - displayInt, 176 + 26, 52 - displayInt, 4, displayInt); + } + public boolean getLocked() { if(isBlock) @@ -171,7 +171,7 @@ public class GuiElectricChest extends GuiMekanism return ((IElectricChest)stack.getItem()).getLocked(stack); } } - + public int getScale() { if(isBlock) @@ -183,7 +183,7 @@ public class GuiElectricChest extends GuiMekanism return (int)(((IEnergizedItem)stack.getItem()).getEnergy(stack)*52 / ((IEnergizedItem)stack.getItem()).getMaxEnergy(stack)); } } - + public double getEnergy() { if(isBlock) diff --git a/common/mekanism/client/gui/GuiElectricMachine.java b/common/mekanism/client/gui/GuiElectricMachine.java index c2d323fef..c54157945 100644 --- a/common/mekanism/client/gui/GuiElectricMachine.java +++ b/common/mekanism/client/gui/GuiElectricMachine.java @@ -17,55 +17,55 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiElectricMachine extends GuiMekanism { - public TileEntityElectricMachine tileEntity; + public TileEntityElectricMachine tileEntity; - public GuiElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity) - { - super(tentity, new ContainerElectricMachine(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, tileEntity.guiLocation)); - } + public GuiElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity) + { + super(tentity, new ContainerElectricMachine(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, tileEntity.guiLocation)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(tileEntity.guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + mc.renderEngine.bindTexture(tileEntity.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledProgress(24); - drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7); + + int displayInt; + + displayInt = tileEntity.getScaledProgress(24); + drawTexturedModalRect(guiWidth + 79, guiHeight + 39, 176, 0, displayInt + 1, 7); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); } diff --git a/common/mekanism/client/gui/GuiElectricPump.java b/common/mekanism/client/gui/GuiElectricPump.java index 7318b16be..ee9655e2f 100644 --- a/common/mekanism/client/gui/GuiElectricPump.java +++ b/common/mekanism/client/gui/GuiElectricPump.java @@ -20,72 +20,72 @@ public class GuiElectricPump extends GuiMekanism public TileEntityElectricPump tileEntity; public ResourceLocation guiLocation = MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"); - + public GuiElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity) - { - super(new ContainerElectricPump(inventory, tentity)); - tileEntity = tentity; + { + super(new ContainerElectricPump(inventory, tentity)); + tileEntity = tentity; guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 164, 15)); - } - + } + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : MekanismUtils.localize("gui.noFluid"), 51, 35, 0x00CD00); - + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRenderer.drawString(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getName() + ": " + tileEntity.fluidTank.getFluid().amount : MekanismUtils.localize("gui.noFluid"), 51, 35, 0x00CD00); + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { mc.renderEngine.bindTexture(guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(tileEntity.getScaledFluidLevel(58) > 0) - { + if(tileEntity.getScaledFluidLevel(58) > 0) + { displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid()); } super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } - + } + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid) { - if(fluid == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; diff --git a/common/mekanism/client/gui/GuiElectrolyticSeparator.java b/common/mekanism/client/gui/GuiElectrolyticSeparator.java index bc6665bde..c157e8b99 100755 --- a/common/mekanism/client/gui/GuiElectrolyticSeparator.java +++ b/common/mekanism/client/gui/GuiElectrolyticSeparator.java @@ -28,31 +28,31 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiElectrolyticSeparator extends GuiMekanism { public TileEntityElectrolyticSeparator tileEntity; - + public GuiElectrolyticSeparator(InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity) - { - super(new ContainerElectrolyticSeparator(inventory, tentity)); - - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(Mekanism.electrolyticSeparatorUsage); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"))); - - tileEntity = tentity; - } - + { + super(new ContainerElectrolyticSeparator(inventory, tentity)); + + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(Mekanism.electrolyticSeparatorUsage); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"))); + + tileEntity = tentity; + } + @Override - protected void mouseClicked(int x, int y, int button) - { + protected void mouseClicked(int x, int y, int button) + { super.mouseClicked(x, y, button); - + int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - + if(xAxis > 8 && xAxis < 17 && yAxis > 73 && yAxis < 82) { ArrayList data = new ArrayList(); @@ -66,26 +66,26 @@ public class GuiElectrolyticSeparator extends GuiMekanism { ArrayList data = new ArrayList(); data.add((byte)1); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } - } + } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + String name = tileEntity.dumpLeft ? "Dumping..." : tileEntity.leftTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.leftTank.getGas().getGas().getLocalizedName(); - fontRenderer.drawString(name, 21, 73, 0x404040); - + fontRenderer.drawString(name, 21, 73, 0x404040); + name = tileEntity.dumpRight ? "Dumping..." : tileEntity.rightTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.rightTank.getGas().getGas().getLocalizedName(); - fontRenderer.drawString(name, 156-fontRenderer.getStringWidth(name), 73, 0x404040); + fontRenderer.drawString(name, 156-fontRenderer.getStringWidth(name), 73, 0x404040); if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11 && yAxis <= 69) { @@ -103,74 +103,74 @@ public class GuiElectrolyticSeparator extends GuiMekanism { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int displayInt = tileEntity.dumpLeft ? 60 : 52; - drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, displayInt, 8, 8); - - displayInt = tileEntity.dumpRight ? 60 : 52; - drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); - - if(tileEntity.fluidTank.getFluid() != null) - { - displayGauge(58, 6, 11, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null); - } - - if(tileEntity.leftTank.getGas() != null) - { - displayGauge(28, 59, 19, tileEntity.getLeftScaledLevel(28), null, tileEntity.leftTank.getGas()); - } - - if(tileEntity.rightTank.getGas() != null) - { - displayGauge(28, 101, 19, tileEntity.getRightScaledLevel(28), null, tileEntity.rightTank.getGas()); - } - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - } - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int displayInt = tileEntity.dumpLeft ? 60 : 52; + drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, displayInt, 8, 8); + + displayInt = tileEntity.dumpRight ? 60 : 52; + drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); + + if(tileEntity.fluidTank.getFluid() != null) + { + displayGauge(58, 6, 11, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null); + } + + if(tileEntity.leftTank.getGas() != null) + { + displayGauge(28, 59, 19, tileEntity.getLeftScaledLevel(28), null, tileEntity.leftTank.getGas()); + } + + if(tileEntity.rightTank.getGas() != null) + { + displayGauge(28, 101, 19, tileEntity.getRightScaledLevel(28), null, tileEntity.rightTank.getGas()); + } + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + } + public void displayGauge(int length, int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null && gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + length - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -179,7 +179,7 @@ public class GuiElectrolyticSeparator extends GuiMekanism { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + length - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) diff --git a/common/mekanism/client/gui/GuiElement.java b/common/mekanism/client/gui/GuiElement.java index c500a3546..346f00e97 100644 --- a/common/mekanism/client/gui/GuiElement.java +++ b/common/mekanism/client/gui/GuiElement.java @@ -13,15 +13,15 @@ import net.minecraft.util.ResourceLocation; public abstract class GuiElement { protected static Minecraft mc = Minecraft.getMinecraft(); - + protected ResourceLocation RESOURCE; - + public GuiMekanism guiObj; - + public TileEntity tileEntity; - + public ResourceLocation defaultLocation; - + public GuiElement(ResourceLocation resource, GuiMekanism gui, TileEntity tile, ResourceLocation def) { RESOURCE = resource; @@ -29,17 +29,17 @@ public abstract class GuiElement tileEntity = tile; defaultLocation = def; } - + protected void displayTooltip(String s, int xAxis, int yAxis) { guiObj.drawCreativeTabHoveringText(s, xAxis, yAxis); } - + protected void displayTooltips(List list, int xAxis, int yAxis) { guiObj.func_102021_a(list, xAxis, yAxis); } - + protected void offsetX(int xSize) { if(guiObj instanceof GuiContainer) @@ -61,17 +61,17 @@ public abstract class GuiElement } catch(Exception e) {} } } - + protected FontRenderer getFontRenderer() { return guiObj.getFontRenderer(); } - + public abstract void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight); - + public abstract void renderForeground(int xAxis, int yAxis); - + public abstract void preMouseClicked(int xAxis, int yAxis, int button); - + public abstract void mouseClicked(int xAxis, int yAxis, int button); } diff --git a/common/mekanism/client/gui/GuiEnergyCube.java b/common/mekanism/client/gui/GuiEnergyCube.java index a5948d079..2ddea832b 100644 --- a/common/mekanism/client/gui/GuiEnergyCube.java +++ b/common/mekanism/client/gui/GuiEnergyCube.java @@ -18,46 +18,46 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiEnergyCube extends GuiMekanism { public TileEntityEnergyCube tileEntity; - + public GuiEnergyCube(InventoryPlayer inventory, TileEntityEnergyCube tentity) { super(new ContainerEnergyCube(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + String capacityInfo = MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()); String outputInfo = MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"; - + fontRenderer.drawString(tileEntity.getInvName(), 43, 6, 0x404040); fontRenderer.drawString(capacityInfo, 45, 40, 0x00CD00); fontRenderer.drawString(outputInfo, 45, 49, 0x00CD00); fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); } - + @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; - - int displayInt = tileEntity.getScaledEnergyLevel(72); - drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, displayInt, 10); - } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + int displayInt = tileEntity.getScaledEnergyLevel(72); + drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, displayInt, 10); + } } diff --git a/common/mekanism/client/gui/GuiEnergyInfo.java b/common/mekanism/client/gui/GuiEnergyInfo.java index 4a65ce617..e6083def0 100644 --- a/common/mekanism/client/gui/GuiEnergyInfo.java +++ b/common/mekanism/client/gui/GuiEnergyInfo.java @@ -11,11 +11,11 @@ import net.minecraft.util.ResourceLocation; public class GuiEnergyInfo extends GuiElement { public IInfoHandler infoHandler; - + public GuiEnergyInfo(IInfoHandler handler, GuiMekanism gui, TileEntity tile, ResourceLocation def) { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiEnergyInfo.png"), gui, tile, def); - + infoHandler = handler; } @@ -28,9 +28,9 @@ public class GuiEnergyInfo extends GuiElement public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - + guiObj.drawTexturedModalRect(guiWidth - 26, guiHeight + 138, 0, 0, 26, 26); - + mc.renderEngine.bindTexture(defaultLocation); } diff --git a/common/mekanism/client/gui/GuiFactory.java b/common/mekanism/client/gui/GuiFactory.java index c93e260f9..1805f49d4 100644 --- a/common/mekanism/client/gui/GuiFactory.java +++ b/common/mekanism/client/gui/GuiFactory.java @@ -21,119 +21,119 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiFactory extends GuiMekanism { - public TileEntityFactory tileEntity; + public TileEntityFactory tileEntity; - public GuiFactory(InventoryPlayer inventory, TileEntityFactory tentity) - { - super(tentity, new ContainerFactory(inventory, tentity)); - tileEntity = tentity; - - ySize += 11; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiRecipeType(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiSortingTab(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, tileEntity.tier.guiLocation)); - } + public GuiFactory(InventoryPlayer inventory, TileEntityFactory tentity) + { + super(tentity, new ContainerFactory(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + ySize += 11; + + guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.tier.guiLocation)); + guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.tier.guiLocation)); + guiElements.add(new GuiRecipeType(this, tileEntity, tileEntity.tier.guiLocation)); + guiElements.add(new GuiConfigurationTab(this, tileEntity, tileEntity.tier.guiLocation)); + guiElements.add(new GuiSortingTab(this, tileEntity, tileEntity.tier.guiLocation)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, tileEntity.tier.guiLocation)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 48, 4, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 93) + 2, 0x404040); - fontRenderer.drawString(RecipeType.values()[tileEntity.recipeType].getName(), 104, (ySize - 93) + 2, 0x404040); - + + fontRenderer.drawString(tileEntity.getInvName(), 48, 4, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 93) + 2, 0x404040); + fontRenderer.drawString(RecipeType.values()[tileEntity.recipeType].getName(), 104, (ySize - 93) + 2, 0x404040); + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + if(xAxis >= 8 && xAxis <= 168 && yAxis >= 78 && yAxis <= 83) { drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : MekanismUtils.localize("gui.none"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(tileEntity.tier.guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - - if(tileEntity.tier == FactoryTier.BASIC) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xPos = 59 + (i*38); - - displayInt = tileEntity.getScaledProgress(20, i); - drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt); - } - } - else if(tileEntity.tier == FactoryTier.ADVANCED) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xPos = 39 + (i*26); - - displayInt = tileEntity.getScaledProgress(20, i); - drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt); - } - } - else if(tileEntity.tier == FactoryTier.ELITE) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xPos = 33 + (i*19); - - displayInt = tileEntity.getScaledProgress(20, i); - drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt); - } - } - - if(tileEntity.getScaledGasLevel(160) > 0) - { - displayGauge(8, 78, tileEntity.getScaledGasLevel(160), 5, tileEntity.gasTank.getGas()); - } - } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(tileEntity.tier.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + + if(tileEntity.tier == FactoryTier.BASIC) + { + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xPos = 59 + (i*38); + + displayInt = tileEntity.getScaledProgress(20, i); + drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt); + } + } + else if(tileEntity.tier == FactoryTier.ADVANCED) + { + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xPos = 39 + (i*26); + + displayInt = tileEntity.getScaledProgress(20, i); + drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt); + } + } + else if(tileEntity.tier == FactoryTier.ELITE) + { + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xPos = 33 + (i*19); + + displayInt = tileEntity.getScaledProgress(20, i); + drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt); + } + } + + if(tileEntity.getScaledGasLevel(160) > 0) + { + displayGauge(8, 78, tileEntity.getScaledGasLevel(160), 5, tileEntity.gasTank.getGas()); + } + } + public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) { - if(gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos, gas.getGas().getIcon(), sizeX, sizeY); } diff --git a/common/mekanism/client/gui/GuiGasTank.java b/common/mekanism/client/gui/GuiGasTank.java index 9e31e59db..8d04d4227 100644 --- a/common/mekanism/client/gui/GuiGasTank.java +++ b/common/mekanism/client/gui/GuiGasTank.java @@ -22,70 +22,70 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiGasTank extends GuiMekanism { public TileEntityGasTank tileEntity; - + public GuiGasTank(InventoryPlayer inventory, TileEntityGasTank tentity) { super(new ContainerGasTank(inventory, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"))); } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + String capacityInfo = tileEntity.gasTank.getStored() + "/" + tileEntity.MAX_GAS; - + fontRenderer.drawString(tileEntity.getInvName(), 43, 6, 0x404040); fontRenderer.drawString(capacityInfo, 45, 40, 0x404040); fontRenderer.drawString("Gas: " + (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() : "None"), 45, 49, 0x404040); fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); - + String name = tileEntity.dumping ? "Dumping..." : MekanismUtils.localize("gui.idle"); - fontRenderer.drawString(name, 156-fontRenderer.getStringWidth(name), 73, 0x404040); - + fontRenderer.drawString(name, 156-fontRenderer.getStringWidth(name), 73, 0x404040); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); } - + @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int displayInt = tileEntity.dumping ? 18 : 10; - drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int displayInt = tileEntity.dumping ? 18 : 10; + drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); + if(tileEntity.gasTank.getGas() != null) { - int scale = (int)(((double)tileEntity.gasTank.getStored() / tileEntity.MAX_GAS) * 72); - drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 10); + int scale = (int)(((double)tileEntity.gasTank.getStored() / tileEntity.MAX_GAS) * 72); + drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 10); } - } - + } + @Override - protected void mouseClicked(int x, int y, int button) - { + protected void mouseClicked(int x, int y, int button) + { super.mouseClicked(x, y, button); - + int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - + if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) { ArrayList data = new ArrayList(); data.add(0); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } - } + } } diff --git a/common/mekanism/client/gui/GuiLogisticalSorter.java b/common/mekanism/client/gui/GuiLogisticalSorter.java index c8da258c0..e59388222 100644 --- a/common/mekanism/client/gui/GuiLogisticalSorter.java +++ b/common/mekanism/client/gui/GuiLogisticalSorter.java @@ -37,49 +37,49 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiLogisticalSorter extends GuiMekanism { public TileEntityLogisticalSorter tileEntity; - + public boolean isDragging = false; - + public int dragOffset = 0; - + public int stackSwitch = 0; - + public Map oreDictStacks = new HashMap(); - + public float scroll; - + public GuiLogisticalSorter(EntityPlayer player, TileEntityLogisticalSorter tentity) { super(new ContainerNull(player, tentity)); tileEntity = tentity; guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png"))); } - + public int getScroll() { return Math.max(Math.min((int)(scroll*123), 123), 0); } - + public int getFilterIndex() { if(tileEntity.filters.size() <= 4) { return 0; } - + return (int)((tileEntity.filters.size()*scroll) - ((4F/(float)tileEntity.filters.size()))*scroll); } - + @Override public void updateScreen() { super.updateScreen(); - + if(stackSwitch > 0) { stackSwitch--; } - + if(stackSwitch == 0) { for(Map.Entry entry : oreDictStacks.entrySet()) @@ -94,11 +94,11 @@ public class GuiLogisticalSorter extends GuiMekanism { entry.getValue().stackIndex++; } - + entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); } } - + stackSwitch = 20; } else { @@ -110,9 +110,9 @@ public class GuiLogisticalSorter extends GuiMekanism } } } - + Set filtersVisible = new HashSet(); - + for(int i = 0; i < 4; i++) { if(tileEntity.filters.get(getFilterIndex()+i) instanceof TOreDictFilter) @@ -120,7 +120,7 @@ public class GuiLogisticalSorter extends GuiMekanism filtersVisible.add((TOreDictFilter)tileEntity.filters.get(getFilterIndex()+i)); } } - + for(TransporterFilter filter : tileEntity.filters) { if(filter instanceof TOreDictFilter && !filtersVisible.contains(filter)) @@ -132,15 +132,15 @@ public class GuiLogisticalSorter extends GuiMekanism } } } - + @Override public void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(button == 0) { if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15) @@ -148,17 +148,17 @@ public class GuiLogisticalSorter extends GuiMekanism dragOffset = yAxis - (getScroll()+18); isDragging = true; } - + for(int i = 0; i < 4; i++) { if(tileEntity.filters.get(getFilterIndex()+i) != null) { int yStart = i*29 + 18; - + if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29) { TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i); - + if(filter instanceof TItemStackFilter) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); @@ -172,86 +172,86 @@ public class GuiLogisticalSorter extends GuiMekanism } } } - + if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) { ArrayList data = new ArrayList(); data.add(1); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } - + if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) { ArrayList data = new ArrayList(); data.add(2); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { button = 2; } - + if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) { ArrayList data = new ArrayList(); data.add(0); data.add(button); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); - mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F); + mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F); } } - + @Override protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) { super.mouseClickMove(mouseX, mouseY, button, ticks); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(isDragging) { scroll = Math.min(Math.max((float)(yAxis-18-dragOffset)/123F, 0), 1); } } - + @Override protected void mouseMovedOrUp(int x, int y, int type) { super.mouseMovedOrUp(x, y, type); - + if(type == 0 && isDragging) { dragOffset = 0; isDragging = false; } } - + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 56, guiHeight + 136, 54, 20, MekanismUtils.localize("gui.itemstack"))); buttonList.add(new GuiButton(1, guiWidth + 110, guiHeight + 136, 43, 20, MekanismUtils.localize("gui.oredict"))); } - + @Override protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - + if(guibutton.id == 0) { PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 1)); @@ -261,39 +261,39 @@ public class GuiLogisticalSorter extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 2)); } } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + fontRenderer.drawString(tileEntity.getInvName(), 43, 6, 0x404040); - + fontRenderer.drawString(MekanismUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00); fontRenderer.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00); fontRenderer.drawString("IS: " + getItemStackFilters().size(), 11, 37, 0x00CD00); fontRenderer.drawString("OD: " + getOreDictFilters().size(), 11, 46, 0x00CD00); - + fontRenderer.drawString("RR:", 12, 74, 0x00CD00); fontRenderer.drawString(MekanismUtils.localize("gui." + (tileEntity.roundRobin ? "on" : "off")), 27, 86, 0x00CD00); - + fontRenderer.drawString(MekanismUtils.localize("gui.logisticalSorter.auto") + ":", 12, 100, 0x00CD00); fontRenderer.drawString(MekanismUtils.localize("gui." + (tileEntity.autoEject ? "on" : "off")), 27, 112, 0x00CD00); - + fontRenderer.drawString(MekanismUtils.localize("gui.logisticalSorter.default") + ":", 12, 126, 0x00CD00); - + for(int i = 0; i < 4; i++) { if(tileEntity.filters.get(getFilterIndex()+i) != null) { TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i); int yStart = i*29 + 18; - + if(filter instanceof TItemStackFilter) { TItemStackFilter itemFilter = (TItemStackFilter)filter; - + if(itemFilter.itemType != null) { GL11.glPushMatrix(); @@ -302,19 +302,19 @@ public class GuiLogisticalSorter extends GuiMekanism GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + fontRenderer.drawString(MekanismUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040); fontRenderer.drawString(filter.color != null ? filter.color.getName() : MekanismUtils.localize("gui.none"), 78, yStart + 11, 0x404040); } else if(filter instanceof TOreDictFilter) { TOreDictFilter oreFilter = (TOreDictFilter)filter; - + if(!oreDictStacks.containsKey(oreFilter)) { updateStackList(oreFilter); } - + if(oreDictStacks.get(filter).renderStack != null) { try { @@ -325,27 +325,27 @@ public class GuiLogisticalSorter extends GuiMekanism GL11.glPopMatrix(); } catch(Exception e) {} } - + fontRenderer.drawString(MekanismUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040); fontRenderer.drawString(filter.color != null ? filter.color.getName() : MekanismUtils.localize("gui.none"), 78, yStart + 11, 0x404040); } } } - + if(tileEntity.color != null) { GL11.glPushMatrix(); GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); itemRenderer.renderIcon(13, 137, MekanismRenderer.getColorIcon(tileEntity.color), 16, 16); - + GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) { if(tileEntity.color != null) @@ -356,45 +356,45 @@ public class GuiLogisticalSorter extends GuiMekanism drawCreativeTabHoveringText(MekanismUtils.localize("gui.none"), xAxis, yAxis); } } - + if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.autoEject"), xAxis, yAxis); } - + if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.logisticalSorter.roundRobin"), xAxis, yAxis); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + drawTexturedModalRect(guiWidth + 154, guiHeight + 18 + getScroll(), 232, 0, 12, 15); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + for(int i = 0; i < 4; i++) { if(tileEntity.filters.get(getFilterIndex()+i) != null) { TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i); int yStart = i*29 + 18; - + boolean mouseOver = xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29; - + if(filter instanceof TItemStackFilter) { drawTexturedModalRect(guiWidth + 56, guiHeight + yStart, mouseOver ? 0 : 96, 166, 96, 29); @@ -405,7 +405,7 @@ public class GuiLogisticalSorter extends GuiMekanism } } } - + if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) { drawTexturedModalRect(guiWidth + 12, guiHeight + 110, 176, 0, 14, 14); @@ -413,7 +413,7 @@ public class GuiLogisticalSorter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 12, guiHeight + 110, 176, 14, 14, 14); } - + if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) { drawTexturedModalRect(guiWidth + 12, guiHeight + 84, 176 + 14, 0, 14, 14); @@ -421,12 +421,12 @@ public class GuiLogisticalSorter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 12, guiHeight + 84, 176 + 14, 14, 14, 14); } - } - + } + public ArrayList getItemStackFilters() { ArrayList list = new ArrayList(); - + for(TransporterFilter filter : tileEntity.filters) { if(filter instanceof TItemStackFilter) @@ -434,14 +434,14 @@ public class GuiLogisticalSorter extends GuiMekanism list.add(filter); } } - + return list; } - + public ArrayList getOreDictFilters() { ArrayList list = new ArrayList(); - + for(TransporterFilter filter : tileEntity.filters) { if(filter instanceof TOreDictFilter) @@ -449,74 +449,74 @@ public class GuiLogisticalSorter extends GuiMekanism list.add(filter); } } - + return list; } - + private void updateStackList(TOreDictFilter filter) { if(!oreDictStacks.containsKey(filter)) { oreDictStacks.put(filter, new StackData()); } - - if(oreDictStacks.get(filter).iterStacks == null) - { - oreDictStacks.get(filter).iterStacks = new ArrayList(); - } - else { - oreDictStacks.get(filter).iterStacks.clear(); - } - - List keys = new ArrayList(); - - for(String s : OreDictionary.getOreNames()) - { - if(filter.oreDictName.equals(s) || filter.oreDictName.equals("*")) - { - keys.add(s); - } - else if(filter.oreDictName.endsWith("*") && !filter.oreDictName.startsWith("*")) - { - if(s.startsWith(filter.oreDictName.substring(0, filter.oreDictName.length()-1))) - { - keys.add(s); - } - } - else if(filter.oreDictName.startsWith("*") && !filter.oreDictName.endsWith("*")) - { - if(s.endsWith(filter.oreDictName.substring(1))) - { - keys.add(s); - } - } - else if(filter.oreDictName.startsWith("*") && filter.oreDictName.endsWith("*")) - { - if(s.contains(filter.oreDictName.substring(1, filter.oreDictName.length()-1))) - { - keys.add(s); - } - } - } - - for(String key : keys) - { - for(ItemStack stack : OreDictionary.getOres(key)) - { - ItemStack toAdd = stack.copy(); - - if(!oreDictStacks.get(filter).iterStacks.contains(stack)) - { - oreDictStacks.get(filter).iterStacks.add(stack.copy()); - } - } - } - - stackSwitch = 0; - updateScreen(); - oreDictStacks.get(filter).stackIndex = -1; - } - + + if(oreDictStacks.get(filter).iterStacks == null) + { + oreDictStacks.get(filter).iterStacks = new ArrayList(); + } + else { + oreDictStacks.get(filter).iterStacks.clear(); + } + + List keys = new ArrayList(); + + for(String s : OreDictionary.getOreNames()) + { + if(filter.oreDictName.equals(s) || filter.oreDictName.equals("*")) + { + keys.add(s); + } + else if(filter.oreDictName.endsWith("*") && !filter.oreDictName.startsWith("*")) + { + if(s.startsWith(filter.oreDictName.substring(0, filter.oreDictName.length()-1))) + { + keys.add(s); + } + } + else if(filter.oreDictName.startsWith("*") && !filter.oreDictName.endsWith("*")) + { + if(s.endsWith(filter.oreDictName.substring(1))) + { + keys.add(s); + } + } + else if(filter.oreDictName.startsWith("*") && filter.oreDictName.endsWith("*")) + { + if(s.contains(filter.oreDictName.substring(1, filter.oreDictName.length()-1))) + { + keys.add(s); + } + } + } + + for(String key : keys) + { + for(ItemStack stack : OreDictionary.getOres(key)) + { + ItemStack toAdd = stack.copy(); + + if(!oreDictStacks.get(filter).iterStacks.contains(stack)) + { + oreDictStacks.get(filter).iterStacks.add(stack.copy()); + } + } + } + + stackSwitch = 0; + updateScreen(); + oreDictStacks.get(filter).stackIndex = -1; + } + public static class StackData { public List iterStacks; diff --git a/common/mekanism/client/gui/GuiMItemStackFilter.java b/common/mekanism/client/gui/GuiMItemStackFilter.java index 78efd395c..0ba3bf10a 100644 --- a/common/mekanism/client/gui/GuiMItemStackFilter.java +++ b/common/mekanism/client/gui/GuiMItemStackFilter.java @@ -25,57 +25,57 @@ import org.lwjgl.opengl.GL11; public class GuiMItemStackFilter extends GuiMekanism { public TileEntityDigitalMiner tileEntity; - + public boolean isNew = false; - + public MItemStackFilter origFilter; - + public MItemStackFilter filter = new MItemStackFilter(); - + public String status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK"); - + public int ticker; - + public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) { super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; - + origFilter = (MItemStackFilter)tileEntity.filters.get(index); filter = ((MItemStackFilter)tileEntity.filters.get(index)).clone(); } - + public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; - + isNew = true; } - + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.save"))); buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.delete"))); - + if(isNew) { ((GuiButton)buttonList.get(1)).enabled = false; } } - + @Override protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - + if(guibutton.id == 0) { if(filter.itemType != null) @@ -87,7 +87,7 @@ public class GuiMItemStackFilter extends GuiMekanism else { PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Coord4D.get(tileEntity), false, origFilter, filter)); } - + PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } else if(filter.itemType == null) @@ -102,22 +102,22 @@ public class GuiMItemStackFilter extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + fontRenderer.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.itemFilter"), 43, 6, 0x404040); fontRenderer.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); fontRenderer.drawString(MekanismUtils.localize("gui.itemFilter.details") + ":", 35, 32, 0x00CD00); - + if(filter.itemType != null) { fontRenderer.drawString(filter.itemType.getDisplayName(), 35, 41, 0x00CD00); } - + if(filter.itemType != null) { GL11.glPushMatrix(); @@ -126,15 +126,15 @@ public class GuiMItemStackFilter extends GuiMekanism GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - + } + @Override public void updateScreen() { super.updateScreen(); - + if(ticker > 0) { ticker--; @@ -145,19 +145,19 @@ public class GuiMItemStackFilter extends GuiMekanism } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMItemStackFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); @@ -165,43 +165,43 @@ public class GuiMItemStackFilter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); } - + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - int x = guiWidth + 12; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int x = guiWidth + 12; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); } - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - if(button == 0) + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } - + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { ItemStack stack = mc.thePlayer.inventory.getItemStack(); - + if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { if(stack.getItem() instanceof ItemBlock) @@ -217,9 +217,9 @@ public class GuiMItemStackFilter extends GuiMekanism { filter.itemType = null; } - - mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - } + } } diff --git a/common/mekanism/client/gui/GuiMOreDictFilter.java b/common/mekanism/client/gui/GuiMOreDictFilter.java index 3200e5c55..5cafa63e1 100644 --- a/common/mekanism/client/gui/GuiMOreDictFilter.java +++ b/common/mekanism/client/gui/GuiMOreDictFilter.java @@ -29,68 +29,68 @@ import org.lwjgl.opengl.GL11; public class GuiMOreDictFilter extends GuiMekanism { public TileEntityDigitalMiner tileEntity; - + public boolean isNew = false; - + public MOreDictFilter origFilter; - + public MOreDictFilter filter = new MOreDictFilter(); - + private GuiTextField oreDictText; - + public ItemStack renderStack; - + public int ticker = 0; - + public int stackSwitch = 0; - + public int stackIndex = 0; - + public List iterStacks; - + public String status = EnumColor.DARK_GREEN + "All OK"; - + public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) { super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; - + origFilter = (MOreDictFilter)tileEntity.filters.get(index); filter = ((MOreDictFilter)tentity.filters.get(index)).clone(); - + updateStackList(filter.oreDictName); } - + public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; - + isNew = true; } - + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, "Save")); buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, "Delete")); - + if(isNew) { ((GuiButton)buttonList.get(1)).enabled = false; } - + oreDictText = new GuiTextField(fontRenderer, guiWidth + 35, guiHeight + 47, 95, 12); oreDictText.setMaxStringLength(12); oreDictText.setFocused(true); } - + @Override public void keyTyped(char c, int i) { @@ -98,31 +98,31 @@ public class GuiMOreDictFilter extends GuiMekanism { super.keyTyped(c, i); } - + if(oreDictText.isFocused() && i == Keyboard.KEY_RETURN) { setOreDictKey(); return; } - + if(Character.isLetter(c) || Character.isDigit(c) || c == '*' || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT) { oreDictText.textboxKeyTyped(c, i); } } - + @Override protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - + if(guibutton.id == 0) { if(!oreDictText.getText().isEmpty()) { setOreDictKey(); } - + if(filter.oreDictName != null && !filter.oreDictName.isEmpty()) { if(isNew) @@ -132,7 +132,7 @@ public class GuiMOreDictFilter extends GuiMekanism else { PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Coord4D.get(tileEntity), false, origFilter, filter)); } - + PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } else { @@ -146,17 +146,17 @@ public class GuiMOreDictFilter extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + fontRenderer.drawString((isNew ? "New" : "Edit") + " OreDict Filter", 43, 6, 0x404040); fontRenderer.drawString("Status: " + status, 35, 20, 0x00CD00); fontRenderer.drawString("Key: " + filter.oreDictName, 35, 32, 0x00CD00); - + if(renderStack != null) { try { @@ -167,24 +167,24 @@ public class GuiMOreDictFilter extends GuiMekanism GL11.glPopMatrix(); } catch(Exception e) {} } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMOreDictFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); @@ -192,7 +192,7 @@ public class GuiMOreDictFilter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); } - + if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); @@ -200,17 +200,17 @@ public class GuiMOreDictFilter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); } - - oreDictText.drawTextBox(); - } - + + oreDictText.drawTextBox(); + } + @Override public void updateScreen() { super.updateScreen(); - + oreDictText.updateCursorCounter(); - + if(ticker > 0) { ticker--; @@ -218,16 +218,16 @@ public class GuiMOreDictFilter extends GuiMekanism else { status = EnumColor.DARK_GREEN + "All OK"; } - + if(stackSwitch > 0) { stackSwitch--; } - + if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) { stackSwitch = 20; - + if(stackIndex == -1 || stackIndex == iterStacks.size()-1) { stackIndex = 0; @@ -236,7 +236,7 @@ public class GuiMOreDictFilter extends GuiMekanism { stackIndex++; } - + renderStack = iterStacks.get(stackIndex); } else if(iterStacks != null && iterStacks.size() == 0) @@ -244,109 +244,109 @@ public class GuiMOreDictFilter extends GuiMekanism renderStack = null; } } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - oreDictText.mouseClicked(mouseX, mouseY, button); - - if(button == 0) + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + oreDictText.mouseClicked(mouseX, mouseY, button); + + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitalMinerGui().setParams(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } - + if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); setOreDictKey(); } } - } - - private void updateStackList(String oreName) - { - if(iterStacks == null) - { - iterStacks = new ArrayList(); - } - else { - iterStacks.clear(); - } - - List keys = new ArrayList(); - - for(String s : OreDictionary.getOreNames()) - { - if(oreName.equals(s) || oreName.equals("*")) - { - keys.add(s); - } - else if(oreName.endsWith("*") && !oreName.startsWith("*")) - { - if(s.startsWith(oreName.substring(0, oreName.length()-1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && !oreName.endsWith("*")) - { - if(s.endsWith(oreName.substring(1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && oreName.endsWith("*")) - { - if(s.contains(oreName.substring(1, oreName.length()-1))) - { - keys.add(s); - } - } - } - - for(String key : keys) - { - for(ItemStack stack : OreDictionary.getOres(key)) - { - ItemStack toAdd = stack.copy(); - - if(!iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) - { - iterStacks.add(stack.copy()); - } - } - } - - stackSwitch = 0; - stackIndex = -1; - } - - private void setOreDictKey() - { - String oreName = oreDictText.getText(); - - if(oreName == null || oreName.isEmpty()) - { - status = EnumColor.DARK_RED + "No key entered"; - return; - } - else if(oreName.equals(filter.oreDictName)) - { - status = EnumColor.DARK_RED + "Same key"; - return; - } - - updateStackList(oreName); - - filter.oreDictName = oreName; - oreDictText.setText(""); - } + } + + private void updateStackList(String oreName) + { + if(iterStacks == null) + { + iterStacks = new ArrayList(); + } + else { + iterStacks.clear(); + } + + List keys = new ArrayList(); + + for(String s : OreDictionary.getOreNames()) + { + if(oreName.equals(s) || oreName.equals("*")) + { + keys.add(s); + } + else if(oreName.endsWith("*") && !oreName.startsWith("*")) + { + if(s.startsWith(oreName.substring(0, oreName.length()-1))) + { + keys.add(s); + } + } + else if(oreName.startsWith("*") && !oreName.endsWith("*")) + { + if(s.endsWith(oreName.substring(1))) + { + keys.add(s); + } + } + else if(oreName.startsWith("*") && oreName.endsWith("*")) + { + if(s.contains(oreName.substring(1, oreName.length()-1))) + { + keys.add(s); + } + } + } + + for(String key : keys) + { + for(ItemStack stack : OreDictionary.getOres(key)) + { + ItemStack toAdd = stack.copy(); + + if(!iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) + { + iterStacks.add(stack.copy()); + } + } + } + + stackSwitch = 0; + stackIndex = -1; + } + + private void setOreDictKey() + { + String oreName = oreDictText.getText(); + + if(oreName == null || oreName.isEmpty()) + { + status = EnumColor.DARK_RED + "No key entered"; + return; + } + else if(oreName.equals(filter.oreDictName)) + { + status = EnumColor.DARK_RED + "Same key"; + return; + } + + updateStackList(oreName); + + filter.oreDictName = oreName; + oreDictText.setText(""); + } } diff --git a/common/mekanism/client/gui/GuiMekanism.java b/common/mekanism/client/gui/GuiMekanism.java index e04ddc2a6..523921ef5 100644 --- a/common/mekanism/client/gui/GuiMekanism.java +++ b/common/mekanism/client/gui/GuiMekanism.java @@ -21,68 +21,68 @@ import org.lwjgl.opengl.GL11; public abstract class GuiMekanism extends GuiContainer { public Set guiElements = new HashSet(); - + private TileEntityContainerBlock tileEntity; - + public GuiMekanism(Container container) { super(container); } - + public GuiMekanism(TileEntityContainerBlock tile, Container container) { super(container); tileEntity = tile; } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + for(GuiElement element : guiElements) { element.renderForeground(xAxis, yAxis); } - + if(tileEntity != null) { Slot hovering = null; - - for(int i = 0; i < inventorySlots.inventorySlots.size(); i++) - { - Slot slot = (Slot)inventorySlots.inventorySlots.get(i); - - if(isMouseOverSlot(slot, mouseX, mouseY)) - { - hovering = slot; - break; - } - } - - ItemStack stack = mc.thePlayer.inventory.getItemStack(); - - if(stack != null && stack.getItem() instanceof ItemConfigurator && hovering != null) - { - SideData data = getFromSlot(hovering); - - if(data != null) - { - drawCreativeTabHoveringText(data.color.getName(), xAxis, yAxis); - } - } + + for(int i = 0; i < inventorySlots.inventorySlots.size(); i++) + { + Slot slot = (Slot)inventorySlots.inventorySlots.get(i); + + if(isMouseOverSlot(slot, mouseX, mouseY)) + { + hovering = slot; + break; + } + } + + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if(stack != null && stack.getItem() instanceof ItemConfigurator && hovering != null) + { + SideData data = getFromSlot(hovering); + + if(data != null) + { + drawCreativeTabHoveringText(data.color.getName(), xAxis, yAxis); + } + } } } - + private SideData getFromSlot(Slot slot) { if(slot.slotNumber < tileEntity.getSizeInventory()) { IInvConfiguration config = (IInvConfiguration)tileEntity; - + for(SideData data : config.getSideData()) { for(int id : data.availableSlots) @@ -94,43 +94,43 @@ public abstract class GuiMekanism extends GuiContainer } } } - + return null; } - - protected boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) - { - return isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY); - } + + protected boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) + { + return isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY); + } @Override protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - int xAxis = mouseX - guiWidth; + int guiHeight = (height - ySize) / 2; + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - + for(GuiElement element : guiElements) { element.renderBackground(xAxis, yAxis, guiWidth, guiHeight); } } - + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + for(GuiElement element : guiElements) { element.preMouseClicked(xAxis, yAxis, button); } - + super.mouseClicked(mouseX, mouseY, button); - + for(GuiElement element : guiElements) { element.mouseClicked(xAxis, yAxis, button); @@ -142,9 +142,9 @@ public abstract class GuiMekanism extends GuiContainer { func_102021_a(Arrays.asList(new String[] {text}), x, y); } - + @Override - protected void func_102021_a(List list, int x, int y) + protected void func_102021_a(List list, int x, int y) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT + GL11.GL_LIGHTING_BIT); super.func_102021_a(list, x, y); diff --git a/common/mekanism/client/gui/GuiMetallurgicInfuser.java b/common/mekanism/client/gui/GuiMetallurgicInfuser.java index f3c225ad5..6a44d5f8c 100644 --- a/common/mekanism/client/gui/GuiMetallurgicInfuser.java +++ b/common/mekanism/client/gui/GuiMetallurgicInfuser.java @@ -24,95 +24,95 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiMetallurgicInfuser extends GuiMekanism { public TileEntityMetallurgicInfuser tileEntity; - + public GuiMetallurgicInfuser(InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity) - { - super(tentity, new ContainerMetallurgicInfuser(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - guiElements.add(new GuiConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); - return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - } + { + super(tentity, new ContainerMetallurgicInfuser(inventory, tentity)); + tileEntity = tentity; + + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); + guiElements.add(new GuiUpgradeManagement(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); + guiElements.add(new GuiConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() + { + String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity.getSpeedMultiplier(), tileEntity.getEnergyMultiplier(), tileEntity.ENERGY_PER_TICK)); + return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); + } + }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); + } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + if(xAxis >= 7 && xAxis <= 11 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(tileEntity.type != null ? tileEntity.type.getLocalizedName() + ": " + tileEntity.infuseStored : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledProgress(32); - drawTexturedModalRect(guiWidth + 72, guiHeight + 47, 176, 52, displayInt + 1, 8); - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - - if(tileEntity.type != null) - { - displayInt = tileEntity.getScaledInfuseLevel(52); - mc.renderEngine.bindTexture(tileEntity.type.texture); - drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, tileEntity.type.texX, tileEntity.type.texY + 52 - displayInt, 4, displayInt); - } - } - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + int displayInt; + + displayInt = tileEntity.getScaledProgress(32); + drawTexturedModalRect(guiWidth + 72, guiHeight + 47, 176, 52, displayInt + 1, 8); + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + + if(tileEntity.type != null) + { + displayInt = tileEntity.getScaledInfuseLevel(52); + mc.renderEngine.bindTexture(tileEntity.type.texture); + drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, tileEntity.type.texX, tileEntity.type.texY + 52 - displayInt, 4, displayInt); + } + } + @Override - protected void mouseClicked(int x, int y, int button) - { + protected void mouseClicked(int x, int y, int button) + { super.mouseClicked(x, y, button); - + if(button == 0) { int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - + if(xAxis > 148 && xAxis < 168 && yAxis > 73 && yAxis < 82) { ArrayList data = new ArrayList(); data.add(0); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - } + } } diff --git a/common/mekanism/client/gui/GuiPasswordEnter.java b/common/mekanism/client/gui/GuiPasswordEnter.java index d4f85643c..2cd1cbfe1 100644 --- a/common/mekanism/client/gui/GuiPasswordEnter.java +++ b/common/mekanism/client/gui/GuiPasswordEnter.java @@ -25,80 +25,80 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiPasswordEnter extends GuiScreen { - public int xSize = 176; - public int ySize = 95; - + public int xSize = 176; + public int ySize = 95; + public TileEntityElectricChest tileEntity; - + public ItemStack itemStack; - + public boolean isBlock; - + public GuiTextField passwordField; - + public String displayText = EnumColor.BRIGHT_GREEN + MekanismUtils.localize("gui.password.enterPassword"); - + public int ticker = 0; - + public GuiPasswordEnter(TileEntityElectricChest tileentity) { isBlock = true; tileEntity = tileentity; } - + public GuiPasswordEnter(ItemStack itemstack) { isBlock = false; itemStack = itemstack; } - + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); passwordField.mouseClicked(mouseX, mouseY, button); } - + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 55, guiHeight + 68, 60, 20, MekanismUtils.localize("gui.open"))); - + passwordField = new GuiTextField(fontRenderer, guiWidth + 45, guiHeight + 50, 80, 12); passwordField.setMaxStringLength(12); passwordField.setFocused(true); } - + @Override public void keyTyped(char c, int i) { super.keyTyped(c, i); - + if(i == Keyboard.KEY_RETURN) { tryOpen(); } - + passwordField.textboxKeyTyped(c, i); } - + @Override public boolean doesGuiPauseGame() { return false; } - + @Override public void updateScreen() { passwordField.updateCursorCounter(); - + if(ticker > 0) { ticker--; @@ -107,7 +107,7 @@ public class GuiPasswordEnter extends GuiScreen displayText = EnumColor.BRIGHT_GREEN + MekanismUtils.localize("gui.password.enterPassword"); } } - + @Override protected void actionPerformed(GuiButton guibutton) { @@ -116,7 +116,7 @@ public class GuiPasswordEnter extends GuiScreen tryOpen(); } } - + public void tryOpen() { if(passwordField.getText() == null || passwordField.getText() == "") @@ -142,11 +142,11 @@ public class GuiPasswordEnter extends GuiScreen ((IEnergizedItem)itemStack.getItem()).setEnergy(itemStack, ((IEnergizedItem)itemStack.getItem()).getEnergy(itemStack) - 100); PacketHandler.sendPacket(Transmission.SERVER, new PacketElectricChest().setParams(ElectricChestPacketType.SERVER_OPEN, true, false)); } - + mc.sndManager.playSoundFX("mekanism:etc.Success", 1.0F, 1.0F); } } - + public String getPassword() { if(isBlock) @@ -157,28 +157,28 @@ public class GuiPasswordEnter extends GuiScreen return ((IElectricChest)itemStack.getItem()).getPassword(itemStack); } } - + @Override public void drawScreen(int mouseX, int mouseY, float partialTick) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPasswordEnter.png")); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - passwordField.drawTextBox(); - - super.drawScreen(mouseX, mouseY, partialTick); - - fontRenderer.drawString(MekanismUtils.localize("gui.password"), guiWidth + 64, guiHeight + 5, 0x404040); - fontRenderer.drawString("Enter:", guiWidth + 45, guiHeight + 40, 0x404040); - fontRenderer.drawString(displayText, guiWidth + 37, guiHeight + 19, 0x404040); - - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPasswordEnter.png")); + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + passwordField.drawTextBox(); + + super.drawScreen(mouseX, mouseY, partialTick); + + fontRenderer.drawString(MekanismUtils.localize("gui.password"), guiWidth + 64, guiHeight + 5, 0x404040); + fontRenderer.drawString("Enter:", guiWidth + 45, guiHeight + 40, 0x404040); + fontRenderer.drawString(displayText, guiWidth + 37, guiHeight + 19, 0x404040); + + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_DEPTH_TEST); } } diff --git a/common/mekanism/client/gui/GuiPasswordModify.java b/common/mekanism/client/gui/GuiPasswordModify.java index 2d473c837..c221ae409 100644 --- a/common/mekanism/client/gui/GuiPasswordModify.java +++ b/common/mekanism/client/gui/GuiPasswordModify.java @@ -24,55 +24,55 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiPasswordModify extends GuiScreen { - public int xSize = 176; - public int ySize = 95; - + public int xSize = 176; + public int ySize = 95; + public TileEntityElectricChest tileEntity; - + public ItemStack itemStack; - + public boolean isBlock; - + public GuiTextField newPasswordField; - + public GuiTextField confirmPasswordField; - + public String displayText = EnumColor.BRIGHT_GREEN + MekanismUtils.localize("gui.password.setPassword"); - + public int ticker = 0; - + public GuiPasswordModify(TileEntityElectricChest tileentity) { isBlock = true; tileEntity = tileentity; } - + public GuiPasswordModify(ItemStack itemstack) { isBlock = false; itemStack = itemstack; } - + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 55, guiHeight + 68, 60, 20, MekanismUtils.localize("gui.confirm"))); - + newPasswordField = new GuiTextField(fontRenderer, guiWidth + 60, guiHeight + 34, 80, 12); newPasswordField.setMaxStringLength(12); newPasswordField.setFocused(true); - + confirmPasswordField = new GuiTextField(fontRenderer, guiWidth + 60, guiHeight + 51, 80, 12); confirmPasswordField.setMaxStringLength(12); confirmPasswordField.setFocused(false); } - + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { @@ -80,12 +80,12 @@ public class GuiPasswordModify extends GuiScreen newPasswordField.mouseClicked(mouseX, mouseY, button); confirmPasswordField.mouseClicked(mouseX, mouseY, button); } - + @Override public void keyTyped(char c, int i) { super.keyTyped(c, i); - + if(i == Keyboard.KEY_TAB) { if(!newPasswordField.isFocused() && !confirmPasswordField.isFocused()) @@ -109,22 +109,22 @@ public class GuiPasswordModify extends GuiScreen { tryModify(); } - + newPasswordField.textboxKeyTyped(c, i); confirmPasswordField.textboxKeyTyped(c, i); } - + @Override public boolean doesGuiPauseGame() { return false; } - + @Override public void updateScreen() { newPasswordField.updateCursorCounter(); - + if(ticker > 0) { ticker--; @@ -133,7 +133,7 @@ public class GuiPasswordModify extends GuiScreen displayText = EnumColor.BRIGHT_GREEN + MekanismUtils.localize("gui.password.setPassword"); } } - + @Override protected void actionPerformed(GuiButton guibutton) { @@ -142,7 +142,7 @@ public class GuiPasswordModify extends GuiScreen tryModify(); } } - + public void tryModify() { if(newPasswordField.getText() == null || newPasswordField.getText().equals("") || confirmPasswordField.getText() == null || confirmPasswordField.getText().equals("")) @@ -173,7 +173,7 @@ public class GuiPasswordModify extends GuiScreen } } } - + public String getPassword() { if(isBlock) @@ -184,29 +184,29 @@ public class GuiPasswordModify extends GuiScreen return ((IElectricChest)itemStack.getItem()).getPassword(itemStack); } } - + @Override public void drawScreen(int mouseX, int mouseY, float partialTick) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPasswordModify.png")); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - super.drawScreen(mouseX, mouseY, partialTick); - - fontRenderer.drawString(MekanismUtils.localize("gui.password"), guiWidth + 64, guiHeight + 5, 0x404040); - fontRenderer.drawString(displayText, guiWidth + 37, guiHeight + 19, 0x404040); - fontRenderer.drawString("Enter:", guiWidth + 27, guiHeight + 37, 0x404040); - fontRenderer.drawString("Repeat:", guiWidth + 21, guiHeight + 54, 0x404040); - newPasswordField.drawTextBox(); - confirmPasswordField.drawTextBox(); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPasswordModify.png")); + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawScreen(mouseX, mouseY, partialTick); + + fontRenderer.drawString(MekanismUtils.localize("gui.password"), guiWidth + 64, guiHeight + 5, 0x404040); + fontRenderer.drawString(displayText, guiWidth + 37, guiHeight + 19, 0x404040); + fontRenderer.drawString("Enter:", guiWidth + 27, guiHeight + 37, 0x404040); + fontRenderer.drawString("Repeat:", guiWidth + 21, guiHeight + 54, 0x404040); + newPasswordField.drawTextBox(); + confirmPasswordField.drawTextBox(); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_DEPTH_TEST); } } diff --git a/common/mekanism/client/gui/GuiPortableTeleporter.java b/common/mekanism/client/gui/GuiPortableTeleporter.java index 18938a416..bbc457068 100644 --- a/common/mekanism/client/gui/GuiPortableTeleporter.java +++ b/common/mekanism/client/gui/GuiPortableTeleporter.java @@ -21,63 +21,63 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiPortableTeleporter extends GuiScreen { public EntityPlayer entityPlayer; - public ItemStack itemStack; - - public int xSize = 176; - public int ySize = 166; + public ItemStack itemStack; - public GuiPortableTeleporter(EntityPlayer player, ItemStack itemstack) - { - entityPlayer = player; - itemStack = itemstack; - } - - @Override - public void initGui() - { - buttonList.clear(); - buttonList.add(new GuiButton(0, 173, 105, 80, 20, MekanismUtils.localize("gui.teleport"))); - } + public int xSize = 176; + public int ySize = 166; + + public GuiPortableTeleporter(EntityPlayer player, ItemStack itemstack) + { + entityPlayer = player; + itemStack = itemstack; + } + + @Override + public void initGui() + { + buttonList.clear(); + buttonList.add(new GuiButton(0, 173, 105, 80, 20, MekanismUtils.localize("gui.teleport"))); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTick) + { + if(mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter) + { + itemStack = mc.thePlayer.getCurrentEquippedItem(); + } + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTeleporter.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int displayInt; + + displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0)); + drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1)); + drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2)); + drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3)); + drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13); + + ItemPortableTeleporter item = (ItemPortableTeleporter)itemStack.getItem(); + + ((GuiButton)buttonList.get(0)).xPosition = guiWidth+48; + ((GuiButton)buttonList.get(0)).yPosition = guiHeight+68; + + fontRenderer.drawString(MekanismUtils.localize("gui.portableTeleporter"), guiWidth+39, guiHeight+6, 0x404040); + fontRenderer.drawString(item.getStatusAsString(item.getStatus(itemStack)), guiWidth+53, guiHeight+19, 0x00CD00); + + super.drawScreen(mouseX, mouseY, partialTick); + } - @Override - public void drawScreen(int mouseX, int mouseY, float partialTick) - { - if(mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter) - { - itemStack = mc.thePlayer.getCurrentEquippedItem(); - } - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTeleporter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int displayInt; - - displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0)); - drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13); - - displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1)); - drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13); - - displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2)); - drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13); - - displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3)); - drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13); - - ItemPortableTeleporter item = (ItemPortableTeleporter)itemStack.getItem(); - - ((GuiButton)buttonList.get(0)).xPosition = guiWidth+48; - ((GuiButton)buttonList.get(0)).yPosition = guiHeight+68; - - fontRenderer.drawString(MekanismUtils.localize("gui.portableTeleporter"), guiWidth+39, guiHeight+6, 0x404040); - fontRenderer.drawString(item.getStatusAsString(item.getStatus(itemStack)), guiWidth+53, guiHeight+19, 0x00CD00); - - super.drawScreen(mouseX, mouseY, partialTick); - } - @Override protected void actionPerformed(GuiButton guibutton) { @@ -87,15 +87,15 @@ public class GuiPortableTeleporter extends GuiScreen mc.setIngameFocus(); } } - + @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { + protected void mouseClicked(int mouseX, int mouseY, int button) + { super.mouseClicked(mouseX, mouseY, button); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58) { PacketHandler.sendPacket(Transmission.SERVER, new PacketDigitUpdate().setParams(0, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0)))); @@ -120,24 +120,24 @@ public class GuiPortableTeleporter extends GuiScreen ((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 3, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3))); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } - } - - public int getIncrementedNumber(int i) - { - if(i < 9) i++; - else if(i == 9) i=0; - - return i; - } - - public int getYAxisForNumber(int i) - { - return i*13; - } - - @Override - public boolean doesGuiPauseGame() - { - return false; - } + } + + public int getIncrementedNumber(int i) + { + if(i < 9) i++; + else if(i == 9) i=0; + + return i; + } + + public int getYAxisForNumber(int i) + { + return i*13; + } + + @Override + public boolean doesGuiPauseGame() + { + return false; + } } diff --git a/common/mekanism/client/gui/GuiPrecisionSawmill.java b/common/mekanism/client/gui/GuiPrecisionSawmill.java index 2cf2a8538..0647eee75 100644 --- a/common/mekanism/client/gui/GuiPrecisionSawmill.java +++ b/common/mekanism/client/gui/GuiPrecisionSawmill.java @@ -5,8 +5,8 @@ import net.minecraft.entity.player.InventoryPlayer; public class GuiPrecisionSawmill extends GuiChanceMachine { - public GuiPrecisionSawmill(InventoryPlayer inventory, TileEntityChanceMachine tentity) - { - super(inventory, tentity); - } + public GuiPrecisionSawmill(InventoryPlayer inventory, TileEntityChanceMachine tentity) + { + super(inventory, tentity); + } } diff --git a/common/mekanism/client/gui/GuiRecipeType.java b/common/mekanism/client/gui/GuiRecipeType.java index 9561cd00d..1c8905c8b 100644 --- a/common/mekanism/client/gui/GuiRecipeType.java +++ b/common/mekanism/client/gui/GuiRecipeType.java @@ -15,17 +15,17 @@ public class GuiRecipeType extends GuiElement } @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - + guiObj.drawTexturedModalRect(guiWidth + 176, guiHeight + 70, 0, 0, 26, 63); - + TileEntityFactory factory = (TileEntityFactory)tileEntity; - int displayInt = factory.getScaledRecipeProgress(15); - - guiObj.drawTexturedModalRect(guiWidth + 181, guiHeight + 94, 26, 0, 10, displayInt); - + int displayInt = factory.getScaledRecipeProgress(15); + + guiObj.drawTexturedModalRect(guiWidth + 181, guiHeight + 94, 26, 0, 10, displayInt); + mc.renderEngine.bindTexture(defaultLocation); } @@ -33,7 +33,7 @@ public class GuiRecipeType extends GuiElement public void renderForeground(int xAxis, int yAxis) {} @Override - public void preMouseClicked(int xAxis, int yAxis, int button) + public void preMouseClicked(int xAxis, int yAxis, int button) { if(button == 0) { @@ -49,7 +49,7 @@ public class GuiRecipeType extends GuiElement } @Override - public void mouseClicked(int xAxis, int yAxis, int button) + public void mouseClicked(int xAxis, int yAxis, int button) { if(button == 0) { diff --git a/common/mekanism/client/gui/GuiRedstoneControl.java b/common/mekanism/client/gui/GuiRedstoneControl.java index 78ed99aed..5d982010f 100644 --- a/common/mekanism/client/gui/GuiRedstoneControl.java +++ b/common/mekanism/client/gui/GuiRedstoneControl.java @@ -18,17 +18,17 @@ public class GuiRedstoneControl extends GuiElement { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRedstoneControl.png"), gui, tile, def); } - + @Override public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - + guiObj.drawTexturedModalRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26); - + IRedstoneControl control = (IRedstoneControl)tileEntity; int renderX = 26 + (18*control.getControlType().ordinal()); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { guiObj.drawTexturedModalRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18); @@ -36,40 +36,40 @@ public class GuiRedstoneControl extends GuiElement else { guiObj.drawTexturedModalRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18); } - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void renderForeground(int xAxis, int yAxis) { mc.renderEngine.bindTexture(RESOURCE); - + IRedstoneControl control = (IRedstoneControl)tileEntity; - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { displayTooltip(control.getControlType().getDisplay(), xAxis, yAxis); } - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void preMouseClicked(int xAxis, int yAxis, int button) {} - + @Override public void mouseClicked(int xAxis, int yAxis, int button) { IRedstoneControl control = (IRedstoneControl)tileEntity; - + if(button == 0) { if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { RedstoneControl current = control.getControlType(); int ordinalToSet = current.ordinal() < (RedstoneControl.values().length-1) ? current.ordinal()+1 : 0; - + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketRedstoneControl().setParams(Coord4D.get(tileEntity), RedstoneControl.values()[ordinalToSet])); } diff --git a/common/mekanism/client/gui/GuiRobitCrafting.java b/common/mekanism/client/gui/GuiRobitCrafting.java index d532f2c4c..4872ee3cf 100644 --- a/common/mekanism/client/gui/GuiRobitCrafting.java +++ b/common/mekanism/client/gui/GuiRobitCrafting.java @@ -20,37 +20,37 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiRobitCrafting extends GuiMekanism { public int entityId; - - public GuiRobitCrafting(InventoryPlayer inventory, World world, int id) - { - super(new ContainerRobitCrafting(inventory, world)); - entityId = id; - xSize += 25; - } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRenderer.drawString(MekanismUtils.localize("gui.robit.crafting"), 8, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + public GuiRobitCrafting(InventoryPlayer inventory, World world, int id) + { + super(new ContainerRobitCrafting(inventory, world)); + entityId = id; + xSize += 25; + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + fontRenderer.drawString(MekanismUtils.localize("gui.robit.crafting"), 8, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitCrafting.png")); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitCrafting.png")); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); @@ -58,7 +58,7 @@ public class GuiRobitCrafting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); @@ -66,7 +66,7 @@ public class GuiRobitCrafting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); @@ -74,7 +74,7 @@ public class GuiRobitCrafting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); @@ -82,7 +82,7 @@ public class GuiRobitCrafting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); @@ -90,18 +90,18 @@ public class GuiRobitCrafting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); } - } - + } + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); diff --git a/common/mekanism/client/gui/GuiRobitInventory.java b/common/mekanism/client/gui/GuiRobitInventory.java index 80ca3def3..11569a09c 100644 --- a/common/mekanism/client/gui/GuiRobitInventory.java +++ b/common/mekanism/client/gui/GuiRobitInventory.java @@ -20,37 +20,37 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiRobitInventory extends GuiMekanism { public EntityRobit robit; - + public GuiRobitInventory(InventoryPlayer inventory, EntityRobit entity) { super(new ContainerRobitInventory(inventory, entity)); xSize += 25; robit = entity; } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRenderer.drawString(MekanismUtils.localize("gui.robit.inventory"), 8, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitInventory.png")); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + fontRenderer.drawString(MekanismUtils.localize("gui.robit.inventory"), 8, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitInventory.png")); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); @@ -58,7 +58,7 @@ public class GuiRobitInventory extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); @@ -66,7 +66,7 @@ public class GuiRobitInventory extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); @@ -74,7 +74,7 @@ public class GuiRobitInventory extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); @@ -82,7 +82,7 @@ public class GuiRobitInventory extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); @@ -90,18 +90,18 @@ public class GuiRobitInventory extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); } - } - + } + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); diff --git a/common/mekanism/client/gui/GuiRobitMain.java b/common/mekanism/client/gui/GuiRobitMain.java index 7dd57134c..1279e13ea 100644 --- a/common/mekanism/client/gui/GuiRobitMain.java +++ b/common/mekanism/client/gui/GuiRobitMain.java @@ -23,36 +23,36 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiRobitMain extends GuiMekanism { public EntityRobit robit; - + public boolean displayNameChange; - + private GuiTextField nameChangeField; private GuiButton confirmName; - - public GuiRobitMain(InventoryPlayer inventory, EntityRobit entity) - { - super(new ContainerRobitMain(inventory, entity)); - xSize += 25; - robit = entity; - } - - private void toggleNameChange() - { - displayNameChange = !displayNameChange; - confirmName.drawButton = displayNameChange; - nameChangeField.setFocused(displayNameChange); - } - - private void changeName() - { - if(nameChangeField.getText() != null && !nameChangeField.getText().isEmpty()) - { - PacketHandler.sendPacket(Transmission.SERVER, new PacketRobit().setParams(RobitPacketType.NAME, nameChangeField.getText(), robit.entityId)); - toggleNameChange(); - nameChangeField.setText(""); - } - } - + + public GuiRobitMain(InventoryPlayer inventory, EntityRobit entity) + { + super(new ContainerRobitMain(inventory, entity)); + xSize += 25; + robit = entity; + } + + private void toggleNameChange() + { + displayNameChange = !displayNameChange; + confirmName.drawButton = displayNameChange; + nameChangeField.setFocused(displayNameChange); + } + + private void changeName() + { + if(nameChangeField.getText() != null && !nameChangeField.getText().isEmpty()) + { + PacketHandler.sendPacket(Transmission.SERVER, new PacketRobit().setParams(RobitPacketType.NAME, nameChangeField.getText(), robit.entityId)); + toggleNameChange(); + nameChangeField.setText(""); + } + } + @Override protected void actionPerformed(GuiButton guibutton) { @@ -61,24 +61,24 @@ public class GuiRobitMain extends GuiMekanism changeName(); } } - - @Override - public void initGui() + + @Override + public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(confirmName = new GuiButton(0, guiWidth + 58, guiHeight + 47, 60, 20, MekanismUtils.localize("gui.confirm"))); confirmName.drawButton = displayNameChange; - + nameChangeField = new GuiTextField(fontRenderer, guiWidth + 48, guiHeight + 21, 80, 12); nameChangeField.setMaxStringLength(12); nameChangeField.setFocused(true); } - + @Override public void keyTyped(char c, int i) { @@ -95,29 +95,29 @@ public class GuiRobitMain extends GuiMekanism { mc.thePlayer.closeScreen(); } - + nameChangeField.textboxKeyTyped(c, i); } } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRenderer.drawString(MekanismUtils.localize("gui.robit"), 76, 6, 0x404040); - - if(!displayNameChange) - { - CharSequence owner = robit.getOwnerName().length() > 14 ? robit.getOwnerName().subSequence(0, 14) : robit.getOwnerName(); - fontRenderer.drawString(MekanismUtils.localize("gui.robit.greeting") + " " + robit.getTranslatedEntityName() + "!", 29, 18, 0x00CD00); - fontRenderer.drawString("Energy: " + MekanismUtils.getEnergyDisplay(robit.getEnergy()), 29, 36-4, 0x00CD00); - fontRenderer.drawString("Following: " + robit.getFollowing(), 29, 45-4, 0x00CD00); - fontRenderer.drawString("Drop pickup: " + robit.getDropPickup(), 29, 54-4, 0x00CD00); - fontRenderer.drawString("Owner: " + owner, 29, 63-4, 0x00CD00); - } - + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + fontRenderer.drawString(MekanismUtils.localize("gui.robit"), 76, 6, 0x404040); + + if(!displayNameChange) + { + CharSequence owner = robit.getOwnerName().length() > 14 ? robit.getOwnerName().subSequence(0, 14) : robit.getOwnerName(); + fontRenderer.drawString(MekanismUtils.localize("gui.robit.greeting") + " " + robit.getTranslatedEntityName() + "!", 29, 18, 0x00CD00); + fontRenderer.drawString("Energy: " + MekanismUtils.getEnergyDisplay(robit.getEnergy()), 29, 36-4, 0x00CD00); + fontRenderer.drawString("Following: " + robit.getFollowing(), 29, 45-4, 0x00CD00); + fontRenderer.drawString("Drop pickup: " + robit.getDropPickup(), 29, 54-4, 0x00CD00); + fontRenderer.drawString("Owner: " + owner, 29, 63-4, 0x00CD00); + } + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 28 && xAxis <= 148 && yAxis >= 75 && yAxis <= 79) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(robit.getEnergy()), xAxis, yAxis); @@ -138,24 +138,24 @@ public class GuiRobitMain extends GuiMekanism { drawCreativeTabHoveringText(MekanismUtils.localize("gui.robit.togglePickup"), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitMain.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitMain.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); @@ -163,7 +163,7 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); @@ -171,7 +171,7 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); @@ -179,7 +179,7 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); @@ -187,7 +187,7 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); @@ -195,7 +195,7 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); } - + if(xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { drawTexturedModalRect(guiWidth + 152, guiHeight + 54, 176 + 25, 180, 18, 18); @@ -203,7 +203,7 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 152, guiHeight + 54, 176 + 25, 198, 18, 18); } - + if(xAxis >= 6 && xAxis <= 24 && yAxis >= 54 && yAxis <= 72) { drawTexturedModalRect(guiWidth + 6, guiHeight + 54, 176 + 25, 216, 18, 18); @@ -211,7 +211,7 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 6, guiHeight + 54, 176 + 25, 234, 18, 18); } - + if(xAxis >= 6 && xAxis <= 24 && yAxis >= 16 && yAxis <= 34) { drawTexturedModalRect(guiWidth + 6, guiHeight + 16, 176 + 25 + 18, 36, 18, 18); @@ -219,7 +219,7 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 6, guiHeight + 16, 176 + 25 + 18, 54, 18, 18); } - + if(xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) { drawTexturedModalRect(guiWidth + 6, guiHeight + 35, 176 + 25 + 18, 72, 18, 18); @@ -227,46 +227,46 @@ public class GuiRobitMain extends GuiMekanism else { drawTexturedModalRect(guiWidth + 6, guiHeight + 35, 176 + 25 + 18, 90, 18, 18); } - + int displayInt; - - displayInt = getScaledEnergyLevel(120); - drawTexturedModalRect(guiWidth + 28, guiHeight + 75, 0, 166, displayInt, 4); - - if(displayNameChange) - { - drawTexturedModalRect(guiWidth + 28, guiHeight + 17, 0, 166 + 4, 120, 54); - nameChangeField.drawTextBox(); - } - } - + + displayInt = getScaledEnergyLevel(120); + drawTexturedModalRect(guiWidth + 28, guiHeight + 75, 0, 166, displayInt, 4); + + if(displayNameChange) + { + drawTexturedModalRect(guiWidth + 28, guiHeight + 17, 0, 166 + 4, 120, 54); + nameChangeField.drawTextBox(); + } + } + private int getScaledEnergyLevel(int i) { return (int)(robit.getEnergy()*i / robit.MAX_ELECTRICITY); } - + @Override public void updateScreen() { super.updateScreen(); - + nameChangeField.updateCursorCounter(); } - + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + nameChangeField.mouseClicked(mouseX, mouseY, button); - + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { + { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) diff --git a/common/mekanism/client/gui/GuiRobitRepair.java b/common/mekanism/client/gui/GuiRobitRepair.java index 60cc7b153..9e14f8b73 100644 --- a/common/mekanism/client/gui/GuiRobitRepair.java +++ b/common/mekanism/client/gui/GuiRobitRepair.java @@ -30,11 +30,11 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiRobitRepair extends GuiMekanism implements ICrafting { public int entityId; - private ContainerRepair repairContainer; - private GuiTextField itemNameField; - private InventoryPlayer playerInventory; - - public GuiRobitRepair(InventoryPlayer inventory, World world, int id) + private ContainerRepair repairContainer; + private GuiTextField itemNameField; + private InventoryPlayer playerInventory; + + public GuiRobitRepair(InventoryPlayer inventory, World world, int id) { super(new ContainerRobitRepair(inventory, world)); xSize += 25; @@ -44,108 +44,108 @@ public class GuiRobitRepair extends GuiMekanism implements ICrafting } @Override - public void initGui() - { - super.initGui(); - Keyboard.enableRepeatEvents(true); - - int i = (width - xSize) / 2; - int j = (height - ySize) / 2; - - itemNameField = new GuiTextField(fontRenderer, i + 62, j + 24, 103, 12); - itemNameField.setTextColor(-1); - itemNameField.setDisabledTextColour(-1); - itemNameField.setEnableBackgroundDrawing(false); - itemNameField.setMaxStringLength(30); - inventorySlots.removeCraftingFromCrafters(this); - inventorySlots.addCraftingToCrafters(this); - } + public void initGui() + { + super.initGui(); + Keyboard.enableRepeatEvents(true); + + int i = (width - xSize) / 2; + int j = (height - ySize) / 2; + + itemNameField = new GuiTextField(fontRenderer, i + 62, j + 24, 103, 12); + itemNameField.setTextColor(-1); + itemNameField.setDisabledTextColour(-1); + itemNameField.setEnableBackgroundDrawing(false); + itemNameField.setMaxStringLength(30); + inventorySlots.removeCraftingFromCrafters(this); + inventorySlots.addCraftingToCrafters(this); + } @Override - public void onGuiClosed() - { - super.onGuiClosed(); - Keyboard.enableRepeatEvents(false); - inventorySlots.removeCraftingFromCrafters(this); - } + public void onGuiClosed() + { + super.onGuiClosed(); + Keyboard.enableRepeatEvents(false); + inventorySlots.removeCraftingFromCrafters(this); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - GL11.glDisable(GL11.GL_LIGHTING); - fontRenderer.drawString(MekanismUtils.localize("container.repair"), 60, 6, 4210752); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + GL11.glDisable(GL11.GL_LIGHTING); + fontRenderer.drawString(MekanismUtils.localize("container.repair"), 60, 6, 4210752); - if(repairContainer.maximumCost > 0) - { - int k = 8453920; - boolean flag = true; - String s = StatCollector.translateToLocalFormatted("container.repair.cost", new Object[] {Integer.valueOf(repairContainer.maximumCost)}); + if(repairContainer.maximumCost > 0) + { + int k = 8453920; + boolean flag = true; + String s = StatCollector.translateToLocalFormatted("container.repair.cost", new Object[] {Integer.valueOf(repairContainer.maximumCost)}); - if(repairContainer.maximumCost >= 40 && !mc.thePlayer.capabilities.isCreativeMode) - { - s = MekanismUtils.localize("container.repair.expensive"); - k = 16736352; - } - else if(!repairContainer.getSlot(2).getHasStack()) - { - flag = false; - } - else if(!repairContainer.getSlot(2).canTakeStack(playerInventory.player)) - { - k = 16736352; - } + if(repairContainer.maximumCost >= 40 && !mc.thePlayer.capabilities.isCreativeMode) + { + s = MekanismUtils.localize("container.repair.expensive"); + k = 16736352; + } + else if(!repairContainer.getSlot(2).getHasStack()) + { + flag = false; + } + else if(!repairContainer.getSlot(2).canTakeStack(playerInventory.player)) + { + k = 16736352; + } - if(flag) - { - int l = -16777216 | (k & 16579836) >> 2 | k & -16777216; - int i1 = (xSize - 25) - 8 - fontRenderer.getStringWidth(s); - byte b0 = 67; + if(flag) + { + int l = -16777216 | (k & 16579836) >> 2 | k & -16777216; + int i1 = (xSize - 25) - 8 - fontRenderer.getStringWidth(s); + byte b0 = 67; - if(fontRenderer.getUnicodeFlag()) - { - drawRect(i1 - 3, b0 - 2, (xSize - 25) - 7, b0 + 10, -16777216); - drawRect(i1 - 2, b0 - 1, (xSize - 25) - 8, b0 + 9, -12895429); - } - else { - fontRenderer.drawString(s, i1, b0 + 1, l); - fontRenderer.drawString(s, i1 + 1, b0, l); - fontRenderer.drawString(s, i1 + 1, b0 + 1, l); - } + if(fontRenderer.getUnicodeFlag()) + { + drawRect(i1 - 3, b0 - 2, (xSize - 25) - 7, b0 + 10, -16777216); + drawRect(i1 - 2, b0 - 1, (xSize - 25) - 8, b0 + 9, -12895429); + } + else { + fontRenderer.drawString(s, i1, b0 + 1, l); + fontRenderer.drawString(s, i1 + 1, b0, l); + fontRenderer.drawString(s, i1 + 1, b0 + 1, l); + } - fontRenderer.drawString(s, i1, b0, k); - } - } + fontRenderer.drawString(s, i1, b0, k); + } + } - GL11.glEnable(GL11.GL_LIGHTING); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + GL11.glEnable(GL11.GL_LIGHTING); - @Override - protected void keyTyped(char c, int i) - { - if(itemNameField.textboxKeyTyped(c, i)) - { - repairContainer.updateItemName(itemNameField.getText()); - mc.thePlayer.sendQueue.addToSendQueue(new Packet250CustomPayload("MC|ItemName", itemNameField.getText().getBytes())); - } - else { - super.keyTyped(c, i); - } - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void keyTyped(char c, int i) + { + if(itemNameField.textboxKeyTyped(c, i)) + { + repairContainer.updateItemName(itemNameField.getText()); + mc.thePlayer.sendQueue.addToSendQueue(new Packet250CustomPayload("MC|ItemName", itemNameField.getText().getBytes())); + } + else { + super.keyTyped(c, i); + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + itemNameField.mouseClicked(mouseX, mouseY, button); - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - itemNameField.mouseClicked(mouseX, mouseY, button); - if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); @@ -175,31 +175,31 @@ public class GuiRobitRepair extends GuiMekanism implements ICrafting mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - } + } - @Override - public void drawScreen(int mouseX, int mouseY, float partialTick) - { - super.drawScreen(mouseX, mouseY, partialTick); - - GL11.glDisable(GL11.GL_LIGHTING); - itemNameField.drawTextBox(); - } + @Override + public void drawScreen(int mouseX, int mouseY, float partialTick) + { + super.drawScreen(mouseX, mouseY, partialTick); + + GL11.glDisable(GL11.GL_LIGHTING); + itemNameField.drawTextBox(); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitRepair.png")); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitRepair.png")); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); @@ -207,7 +207,7 @@ public class GuiRobitRepair extends GuiMekanism implements ICrafting else { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); @@ -215,7 +215,7 @@ public class GuiRobitRepair extends GuiMekanism implements ICrafting else { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); @@ -223,7 +223,7 @@ public class GuiRobitRepair extends GuiMekanism implements ICrafting else { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); @@ -231,7 +231,7 @@ public class GuiRobitRepair extends GuiMekanism implements ICrafting else { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); @@ -239,37 +239,37 @@ public class GuiRobitRepair extends GuiMekanism implements ICrafting else { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); } - - drawTexturedModalRect(guiWidth + 59, guiHeight + 20, 0, ySize + (repairContainer.getSlot(0).getHasStack() ? 0 : 16), 110, 16); - if((repairContainer.getSlot(0).getHasStack() || repairContainer.getSlot(1).getHasStack()) && !repairContainer.getSlot(2).getHasStack()) - { - drawTexturedModalRect(guiWidth + 99, guiHeight + 45, xSize + 18, 36, 28, 21); - } - } + drawTexturedModalRect(guiWidth + 59, guiHeight + 20, 0, ySize + (repairContainer.getSlot(0).getHasStack() ? 0 : 16), 110, 16); - @Override - public void sendContainerAndContentsToPlayer(Container container, List list) - { - sendSlotContents(container, 0, container.getSlot(0).getStack()); - } + if((repairContainer.getSlot(0).getHasStack() || repairContainer.getSlot(1).getHasStack()) && !repairContainer.getSlot(2).getHasStack()) + { + drawTexturedModalRect(guiWidth + 99, guiHeight + 45, xSize + 18, 36, 28, 21); + } + } - @Override - public void sendSlotContents(Container container, int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - itemNameField.setText(itemstack == null ? "" : itemstack.getDisplayName()); - itemNameField.setEnabled(itemstack != null); + @Override + public void sendContainerAndContentsToPlayer(Container container, List list) + { + sendSlotContents(container, 0, container.getSlot(0).getStack()); + } - if(itemstack != null) - { - repairContainer.updateItemName(itemNameField.getText()); - mc.thePlayer.sendQueue.addToSendQueue(new Packet250CustomPayload("MC|ItemName", itemNameField.getText().getBytes())); - } - } - } + @Override + public void sendSlotContents(Container container, int slotID, ItemStack itemstack) + { + if(slotID == 0) + { + itemNameField.setText(itemstack == null ? "" : itemstack.getDisplayName()); + itemNameField.setEnabled(itemstack != null); - @Override - public void sendProgressBarUpdate(Container par1Container, int par2, int par3) {} + if(itemstack != null) + { + repairContainer.updateItemName(itemNameField.getText()); + mc.thePlayer.sendQueue.addToSendQueue(new Packet250CustomPayload("MC|ItemName", itemNameField.getText().getBytes())); + } + } + } + + @Override + public void sendProgressBarUpdate(Container par1Container, int par2, int par3) {} } diff --git a/common/mekanism/client/gui/GuiRobitSmelting.java b/common/mekanism/client/gui/GuiRobitSmelting.java index 4e2cbd488..8c8f8902e 100644 --- a/common/mekanism/client/gui/GuiRobitSmelting.java +++ b/common/mekanism/client/gui/GuiRobitSmelting.java @@ -16,37 +16,37 @@ import org.lwjgl.opengl.GL11; public class GuiRobitSmelting extends GuiMekanism { public EntityRobit robit; - + public GuiRobitSmelting(InventoryPlayer inventory, EntityRobit entity) { super(new ContainerRobitSmelting(inventory, entity)); xSize += 25; robit = entity; } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRenderer.drawString(MekanismUtils.localize("gui.robit.smelting"), 8, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitSmelting.png")); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + fontRenderer.drawString(MekanismUtils.localize("gui.robit.smelting"), 8, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitSmelting.png")); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); @@ -54,7 +54,7 @@ public class GuiRobitSmelting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); @@ -62,7 +62,7 @@ public class GuiRobitSmelting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); @@ -70,7 +70,7 @@ public class GuiRobitSmelting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); @@ -78,7 +78,7 @@ public class GuiRobitSmelting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); } - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); @@ -86,29 +86,29 @@ public class GuiRobitSmelting extends GuiMekanism else { drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); } - - int displayInt; - if(robit.furnaceBurnTime > 0) - { - displayInt = getBurnTimeRemainingScaled(12); - drawTexturedModalRect(guiWidth + 56, guiHeight + 36 + 12 - displayInt, 176 + 25 + 18, 36 + 12 - displayInt, 14, displayInt + 2); - } + int displayInt; + + if(robit.furnaceBurnTime > 0) + { + displayInt = getBurnTimeRemainingScaled(12); + drawTexturedModalRect(guiWidth + 56, guiHeight + 36 + 12 - displayInt, 176 + 25 + 18, 36 + 12 - displayInt, 14, displayInt + 2); + } + + displayInt = getCookProgressScaled(24); + drawTexturedModalRect(guiWidth + 79, guiHeight + 34, 176 + 25 + 18, 36 + 14, displayInt + 1, 16); + } - displayInt = getCookProgressScaled(24); - drawTexturedModalRect(guiWidth + 79, guiHeight + 34, 176 + 25 + 18, 36 + 14, displayInt + 1, 16); - } - @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); @@ -139,19 +139,19 @@ public class GuiRobitSmelting extends GuiMekanism } } } - - private int getCookProgressScaled(int i) - { - return robit.furnaceCookTime * i / 200; - } - private int getBurnTimeRemainingScaled(int i) - { - if(robit.currentItemBurnTime == 0) - { - robit.currentItemBurnTime = 200; - } + private int getCookProgressScaled(int i) + { + return robit.furnaceCookTime * i / 200; + } - return robit.furnaceBurnTime * i / robit.currentItemBurnTime; - } + private int getBurnTimeRemainingScaled(int i) + { + if(robit.currentItemBurnTime == 0) + { + robit.currentItemBurnTime = 200; + } + + return robit.furnaceBurnTime * i / robit.currentItemBurnTime; + } } diff --git a/common/mekanism/client/gui/GuiRotaryCondensentrator.java b/common/mekanism/client/gui/GuiRotaryCondensentrator.java index 9208b9a63..9e5b81931 100644 --- a/common/mekanism/client/gui/GuiRotaryCondensentrator.java +++ b/common/mekanism/client/gui/GuiRotaryCondensentrator.java @@ -25,75 +25,75 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiRotaryCondensentrator extends GuiMekanism { public TileEntityRotaryCondensentrator tileEntity; - + public GuiRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity) - { - super(new ContainerRotaryCondensentrator(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); - } - + { + super(new ContainerRotaryCondensentrator(inventory, tentity)); + tileEntity = tentity; + + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); + } + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 26, 4, 0x404040); - fontRenderer.drawString(tileEntity.mode == 0 ? MekanismUtils.localize("gui.condensentrating") : MekanismUtils.localize("gui.decondensentrating"), 6, (ySize - 94) + 2, 0x404040); - + + fontRenderer.drawString(tileEntity.getInvName(), 26, 4, 0x404040); + fontRenderer.drawString(tileEntity.mode == 0 ? MekanismUtils.localize("gui.condensentrating") : MekanismUtils.localize("gui.decondensentrating"), 6, (ySize - 94) + 2, 0x404040); + if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { drawCreativeTabHoveringText(MekanismUtils.localize("gui.rotaryCondensentrator.toggleOperation"), xAxis, yAxis); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int displayInt; - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int displayInt; + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4); - - if(tileEntity.getScaledGasLevel(58) > 0) - { - displayGauge(26, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank.getGas()); + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4); + + if(tileEntity.getScaledGasLevel(58) > 0) + { + displayGauge(26, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank.getGas()); } - - if(tileEntity.getScaledFluidLevel(58) > 0) - { + + if(tileEntity.getScaledFluidLevel(58) > 0) + { displayGauge(134, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null); - } - + } + if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 0, 18, 18); @@ -101,7 +101,7 @@ public class GuiRotaryCondensentrator extends GuiMekanism else { drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 18, 18, 18); } - + if(tileEntity.mode == 0) { drawTexturedModalRect(guiWidth + 64, guiHeight + 39, 176, tileEntity.isActive ? 123 : 107, 48, 8); @@ -110,57 +110,57 @@ public class GuiRotaryCondensentrator extends GuiMekanism { drawTexturedModalRect(guiWidth + 64, guiHeight + 39, 176, tileEntity.isActive ? 115 : 99, 48, 8); } - } - + } + @Override protected void mouseClicked(int mouseX, int mouseY, int button) { super.mouseClicked(mouseX, mouseY, button); - + if(button == 0) { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { ArrayList data = new ArrayList(); data.add(0); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } } - + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null && gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -169,7 +169,7 @@ public class GuiRotaryCondensentrator extends GuiMekanism { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) diff --git a/common/mekanism/client/gui/GuiSalinationController.java b/common/mekanism/client/gui/GuiSalinationController.java index d89d5e1a0..892b73e0e 100644 --- a/common/mekanism/client/gui/GuiSalinationController.java +++ b/common/mekanism/client/gui/GuiSalinationController.java @@ -19,173 +19,173 @@ import org.lwjgl.opengl.GL11; public class GuiSalinationController extends GuiMekanism { - public TileEntitySalinationController tileEntity; + public TileEntitySalinationController tileEntity; - public GuiSalinationController(InventoryPlayer inventory, TileEntitySalinationController tentity) - { - super(tentity, new ContainerSalinationController(inventory, tentity)); - tileEntity = tentity; - } + public GuiSalinationController(InventoryPlayer inventory, TileEntitySalinationController tentity) + { + super(tentity, new ContainerSalinationController(inventory, tentity)); + tileEntity = tentity; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); - - fontRenderer.drawString(getStruct(), 50, 21, 0x00CD00); - fontRenderer.drawString("Height: " + tileEntity.height, 50, 30, 0x00CD00); - fontRenderer.drawString("Mult: " + getTempMult(), 50, 39, 0x00CD00); - fontRenderer.drawString("Max: " + getMaxTemp(), 50, 48, 0x00CD00); - + + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); + + fontRenderer.drawString(getStruct(), 50, 21, 0x00CD00); + fontRenderer.drawString("Height: " + tileEntity.height, 50, 30, 0x00CD00); + fontRenderer.drawString("Mult: " + getTempMult(), 50, 39, 0x00CD00); + fontRenderer.drawString("Max: " + getMaxTemp(), 50, 48, 0x00CD00); + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.waterTank.getFluid() != null ? tileEntity.waterTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.waterTank.getFluidAmount() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14 && yAxis <= 72) { drawCreativeTabHoveringText(tileEntity.brineTank.getFluid() != null ? tileEntity.brineTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.brineTank.getFluidAmount() : MekanismUtils.localize("gui.empty"), xAxis, yAxis); } - + if(xAxis >= 49 && xAxis <= 127 && yAxis >= 64 && yAxis <= 72) { drawCreativeTabHoveringText(getTemp(), xAxis, yAxis); } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - private String getStruct() - { - if(tileEntity.structured) - { - return "Structured"; - } - else if(!tileEntity.structured) - { - if(tileEntity.controllerConflict) - { - return "Conflict"; - } - else { - return "Incomplete"; - } - } - - return null; - } - - private String getTemp() - { - float temp = (float)Math.round((tileEntity.getTemperature()*200)*10)/10F; - - return temp + " F"; - } - - private String getMaxTemp() - { - float temp = (float)Math.round((tileEntity.getMaxTemperature()*200)*10)/10F; - - return temp + " F"; - } - - private String getTempMult() - { - float temp = (float)Math.round((tileEntity.getTempMultiplier())*10)/10F; - - return temp + "x"; - } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSalinationController.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + private String getStruct() + { + if(tileEntity.structured) + { + return "Structured"; + } + else if(!tileEntity.structured) + { + if(tileEntity.controllerConflict) + { + return "Conflict"; + } + else { + return "Incomplete"; + } + } + + return null; + } + + private String getTemp() + { + float temp = (float)Math.round((tileEntity.getTemperature()*200)*10)/10F; + + return temp + " F"; + } + + private String getMaxTemp() + { + float temp = (float)Math.round((tileEntity.getMaxTemperature()*200)*10)/10F; + + return temp + " F"; + } + + private String getTempMult() + { + float temp = (float)Math.round((tileEntity.getTempMultiplier())*10)/10F; + + return temp + "x"; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSalinationController.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - if(tileEntity.getScaledWaterLevel(58) > 0) - { - displayGauge(7, 14, tileEntity.getScaledWaterLevel(58), tileEntity.waterTank.getFluid(), null); - } - - if(tileEntity.getScaledBrineLevel(58) > 0) - { - displayGauge(153, 14, tileEntity.getScaledBrineLevel(58), tileEntity.brineTank.getFluid(), null); - } - - displayInt = tileEntity.getScaledTempLevel(78); - drawTexturedModalRect(guiWidth + 49, guiHeight + 64, 176, 59, displayInt, 8); - - if(xAxis >= 48 && xAxis <= 128 && yAxis >= 5 && yAxis <= 17) + + int displayInt; + + if(tileEntity.getScaledWaterLevel(58) > 0) + { + displayGauge(7, 14, tileEntity.getScaledWaterLevel(58), tileEntity.waterTank.getFluid(), null); + } + + if(tileEntity.getScaledBrineLevel(58) > 0) + { + displayGauge(153, 14, tileEntity.getScaledBrineLevel(58), tileEntity.brineTank.getFluid(), null); + } + + displayInt = tileEntity.getScaledTempLevel(78); + drawTexturedModalRect(guiWidth + 49, guiHeight + 64, 176, 59, displayInt, 8); + + if(xAxis >= 48 && xAxis <= 128 && yAxis >= 5 && yAxis <= 17) { drawTexturedModalRect(guiWidth + 48, guiHeight + 5, 176, 79, 80, 12); } else { drawTexturedModalRect(guiWidth + 48, guiHeight + 5, 176, 67, 80, 12); } - } - - @Override - protected void mouseClicked(int x, int y, int button) - { + } + + @Override + protected void mouseClicked(int x, int y, int button) + { super.mouseClicked(x, y, button); - + if(button == 0) { int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - + if(xAxis >= 48 && xAxis <= 128 && yAxis >= 5 && yAxis <= 17) { ArrayList data = new ArrayList(); data.add(0); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } } - } - + } + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + if(fluid == null && gas == null) + { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -194,7 +194,7 @@ public class GuiSalinationController extends GuiMekanism { drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) diff --git a/common/mekanism/client/gui/GuiSortingTab.java b/common/mekanism/client/gui/GuiSortingTab.java index 7065c128a..1fcb629f1 100644 --- a/common/mekanism/client/gui/GuiSortingTab.java +++ b/common/mekanism/client/gui/GuiSortingTab.java @@ -19,14 +19,14 @@ public class GuiSortingTab extends GuiElement { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSortingTab.png"), gui, tile, def); } - + @Override public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - + guiObj.drawTexturedModalRect(guiWidth - 26, guiHeight + 34, 0, 0, 26, 35); - + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) { guiObj.drawTexturedModalRect(guiWidth - 21, guiHeight + 38, 26, 0, 18, 18); @@ -34,28 +34,28 @@ public class GuiSortingTab extends GuiElement else { guiObj.drawTexturedModalRect(guiWidth - 21, guiHeight + 38, 26, 18, 18, 18); } - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void renderForeground(int xAxis, int yAxis) { mc.renderEngine.bindTexture(RESOURCE); - + getFontRenderer().drawString(((TileEntityFactory)tileEntity).sorting ? "On" : "Off", -21, 58, 0x0404040); - + if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) { displayTooltip(MekanismUtils.localize("gui.factory.autoSort"), xAxis, yAxis); } - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void preMouseClicked(int xAxis, int yAxis, int button) {} - + @Override public void mouseClicked(int xAxis, int yAxis, int button) { diff --git a/common/mekanism/client/gui/GuiTItemStackFilter.java b/common/mekanism/client/gui/GuiTItemStackFilter.java index db42071e9..1037faa89 100644 --- a/common/mekanism/client/gui/GuiTItemStackFilter.java +++ b/common/mekanism/client/gui/GuiTItemStackFilter.java @@ -27,80 +27,80 @@ import org.lwjgl.opengl.GL12; public class GuiTItemStackFilter extends GuiMekanism { public TileEntityLogisticalSorter tileEntity; - + public boolean isNew = false; - + public TItemStackFilter origFilter; - + public TItemStackFilter filter = new TItemStackFilter(); - + public String status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK"); - + public int ticker; - + private GuiTextField minField; private GuiTextField maxField; - + public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) { super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; - + origFilter = (TItemStackFilter)tileEntity.filters.get(index); filter = ((TItemStackFilter)tileEntity.filters.get(index)).clone(); } - + public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; - + isNew = true; } - + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.save"))); buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.delete"))); - + if(isNew) { ((GuiButton)buttonList.get(1)).enabled = false; } - + minField = new GuiTextField(fontRenderer, guiWidth + 149, guiHeight + 19, 20, 11); minField.setMaxStringLength(2); minField.setText("" + filter.min); - + maxField = new GuiTextField(fontRenderer, guiWidth + 149, guiHeight + 31, 20, 11); maxField.setMaxStringLength(2); maxField.setText("" + filter.max); } - + @Override protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - + if(guibutton.id == 0) { if(filter.itemType != null && !minField.getText().isEmpty() && !maxField.getText().isEmpty()) { int min = Integer.parseInt(minField.getText()); int max = Integer.parseInt(maxField.getText()); - + if(max >= min && max <= 64 && min <= 64) { filter.min = Integer.parseInt(minField.getText()); filter.max = Integer.parseInt(maxField.getText()); - + if(isNew) { PacketHandler.sendPacket(Transmission.SERVER, new PacketNewFilter().setParams(Coord4D.get(tileEntity), filter)); @@ -108,7 +108,7 @@ public class GuiTItemStackFilter extends GuiMekanism else { PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Coord4D.get(tileEntity), false, origFilter, filter)); } - + PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } else if(min > max) @@ -139,7 +139,7 @@ public class GuiTItemStackFilter extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } } - + @Override public void keyTyped(char c, int i) { @@ -147,33 +147,33 @@ public class GuiTItemStackFilter extends GuiMekanism { super.keyTyped(c, i); } - + if(Character.isDigit(c) || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT) { minField.textboxKeyTyped(c, i); maxField.textboxKeyTyped(c, i); } } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + fontRenderer.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.itemFilter"), 43, 6, 0x404040); fontRenderer.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); fontRenderer.drawString(MekanismUtils.localize("gui.itemFilter.details") + ":", 35, 32, 0x00CD00); - + fontRenderer.drawString(MekanismUtils.localize("gui.itemFilter.min") + ":", 128, 20, 0x404040); fontRenderer.drawString(MekanismUtils.localize("gui.itemFilter.max") + ":", 128, 32, 0x404040); fontRenderer.drawString(MekanismUtils.localize("gui." + (filter.sizeMode ? "on" : "off")), 141, 46, 0x404040); - + if(filter.itemType != null) { fontRenderer.drawString(filter.itemType.getDisplayName(), 35, 41, 0x00CD00); } - + if(filter.itemType != null) { GL11.glPushMatrix(); @@ -182,21 +182,21 @@ public class GuiTItemStackFilter extends GuiMekanism GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + if(filter.color != null) { GL11.glPushMatrix(); GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16); - + GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { if(filter.color != null) @@ -207,18 +207,18 @@ public class GuiTItemStackFilter extends GuiMekanism drawCreativeTabHoveringText(MekanismUtils.localize("gui.none"), xAxis, yAxis); } } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - + } + @Override public void updateScreen() { super.updateScreen(); - + minField.updateCursorCounter(); maxField.updateCursorCounter(); - + if(ticker > 0) { ticker--; @@ -229,19 +229,19 @@ public class GuiTItemStackFilter extends GuiMekanism } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTItemStackFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); @@ -249,7 +249,7 @@ public class GuiTItemStackFilter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); } - + if(xAxis >= 128 && xAxis <= 139 && yAxis >= 44 && yAxis <= 55) { drawTexturedModalRect(guiWidth + 128, guiHeight + 44, 187, 0, 11, 11); @@ -257,49 +257,49 @@ public class GuiTItemStackFilter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 128, guiHeight + 44, 187, 11, 11, 11); } - + minField.drawTextBox(); maxField.drawTextBox(); - + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - int x = guiWidth + 12; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int x = guiWidth + 12; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); } - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - minField.mouseClicked(mouseX, mouseY, button); - maxField.mouseClicked(mouseX, mouseY, button); - + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + minField.mouseClicked(mouseX, mouseY, button); + maxField.mouseClicked(mouseX, mouseY, button); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - if(button == 0) + + if(button == 0) { if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } - + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { ItemStack stack = mc.thePlayer.inventory.getItemStack(); - + if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { filter.itemType = stack.copy(); @@ -309,38 +309,38 @@ public class GuiTItemStackFilter extends GuiMekanism { filter.itemType = null; } - - mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } - + if(xAxis >= 128 && xAxis <= 139 && yAxis >= 44 && yAxis <= 55) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); filter.sizeMode = !filter.sizeMode; } } - - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) + + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { button = 2; } - + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { - mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F); - - if(button == 0) - { - filter.color = TransporterUtils.increment(filter.color); - } - else if(button == 1) - { - filter.color = TransporterUtils.decrement(filter.color); - } - else if(button == 2) - { - filter.color = null; - } + mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F); + + if(button == 0) + { + filter.color = TransporterUtils.increment(filter.color); + } + else if(button == 1) + { + filter.color = TransporterUtils.decrement(filter.color); + } + else if(button == 2) + { + filter.color = null; + } } - } + } } diff --git a/common/mekanism/client/gui/GuiTOreDictFilter.java b/common/mekanism/client/gui/GuiTOreDictFilter.java index 13fb71310..d08375e83 100644 --- a/common/mekanism/client/gui/GuiTOreDictFilter.java +++ b/common/mekanism/client/gui/GuiTOreDictFilter.java @@ -33,68 +33,68 @@ import org.lwjgl.opengl.GL12; public class GuiTOreDictFilter extends GuiMekanism { public TileEntityLogisticalSorter tileEntity; - + public boolean isNew = false; - + public TOreDictFilter origFilter; - + public TOreDictFilter filter = new TOreDictFilter(); - + private GuiTextField oreDictText; - + public ItemStack renderStack; - + public int ticker = 0; - + public int stackSwitch = 0; - + public int stackIndex = 0; - + public List iterStacks; - + public String status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK"); - + public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) { super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; - + origFilter = (TOreDictFilter)tileEntity.filters.get(index); filter = ((TOreDictFilter)tentity.filters.get(index)).clone(); - + updateStackList(filter.oreDictName); } - + public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { super(new ContainerFilter(player.inventory, tentity)); tileEntity = tentity; - + isNew = true; } - + @Override public void initGui() { super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + buttonList.clear(); buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.save"))); buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, MekanismUtils.localize("gui.delete"))); - + if(isNew) { ((GuiButton)buttonList.get(1)).enabled = false; } - + oreDictText = new GuiTextField(fontRenderer, guiWidth + 35, guiHeight + 47, 95, 12); oreDictText.setMaxStringLength(12); oreDictText.setFocused(true); } - + @Override public void keyTyped(char c, int i) { @@ -102,31 +102,31 @@ public class GuiTOreDictFilter extends GuiMekanism { super.keyTyped(c, i); } - + if(oreDictText.isFocused() && i == Keyboard.KEY_RETURN) { setOreDictKey(); return; } - + if(Character.isLetter(c) || Character.isDigit(c) || c == '*' || i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT) { oreDictText.textboxKeyTyped(c, i); } } - + @Override protected void actionPerformed(GuiButton guibutton) { super.actionPerformed(guibutton); - + if(guibutton.id == 0) { if(!oreDictText.getText().isEmpty()) { setOreDictKey(); } - + if(filter.oreDictName != null && !filter.oreDictName.isEmpty()) { if(isNew) @@ -136,7 +136,7 @@ public class GuiTOreDictFilter extends GuiMekanism else { PacketHandler.sendPacket(Transmission.SERVER, new PacketEditFilter().setParams(Coord4D.get(tileEntity), false, origFilter, filter)); } - + PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } else { @@ -150,17 +150,17 @@ public class GuiTOreDictFilter extends GuiMekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } } - + @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + fontRenderer.drawString((isNew ? MekanismUtils.localize("gui.new") : MekanismUtils.localize("gui.edit")) + " " + MekanismUtils.localize("gui.oredictFilter"), 43, 6, 0x404040); fontRenderer.drawString(MekanismUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); fontRenderer.drawString("Key: " + filter.oreDictName, 35, 32, 0x00CD00); - + if(renderStack != null) { try { @@ -171,21 +171,21 @@ public class GuiTOreDictFilter extends GuiMekanism GL11.glPopMatrix(); } catch(Exception e) {} } - + if(filter.color != null) { GL11.glPushMatrix(); GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); itemRenderer.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16); - + GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } - + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { if(filter.color != null) @@ -196,24 +196,24 @@ public class GuiTOreDictFilter extends GuiMekanism drawCreativeTabHoveringText(MekanismUtils.localize("gui.none"), xAxis, yAxis); } } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTOreDictFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); @@ -221,7 +221,7 @@ public class GuiTOreDictFilter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); } - + if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); @@ -229,17 +229,17 @@ public class GuiTOreDictFilter extends GuiMekanism else { drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); } - - oreDictText.drawTextBox(); - } - + + oreDictText.drawTextBox(); + } + @Override public void updateScreen() { super.updateScreen(); - + oreDictText.updateCursorCounter(); - + if(ticker > 0) { ticker--; @@ -247,16 +247,16 @@ public class GuiTOreDictFilter extends GuiMekanism else { status = EnumColor.DARK_GREEN + MekanismUtils.localize("gui.allOK"); } - + if(stackSwitch > 0) { stackSwitch--; } - + if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) { stackSwitch = 20; - + if(stackIndex == -1 || stackIndex == iterStacks.size()-1) { stackIndex = 0; @@ -265,7 +265,7 @@ public class GuiTOreDictFilter extends GuiMekanism { stackIndex++; } - + renderStack = iterStacks.get(stackIndex); } else if(iterStacks != null && iterStacks.size() == 0) @@ -273,132 +273,132 @@ public class GuiTOreDictFilter extends GuiMekanism renderStack = null; } } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - oreDictText.mouseClicked(mouseX, mouseY, button); - + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + oreDictText.mouseClicked(mouseX, mouseY, button); + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - if(button == 0) - { + + if(button == 0) + { if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0)); } - + if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); setOreDictKey(); } } - - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) + + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { button = 2; } - + if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { - mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F); - - if(button == 0) - { - filter.color = TransporterUtils.increment(filter.color); - } - else if(button == 1) - { - filter.color = TransporterUtils.decrement(filter.color); - } - else if(button == 2) - { - filter.color = null; - } + mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F); + + if(button == 0) + { + filter.color = TransporterUtils.increment(filter.color); + } + else if(button == 1) + { + filter.color = TransporterUtils.decrement(filter.color); + } + else if(button == 2) + { + filter.color = null; + } } - } - - private void updateStackList(String oreName) - { - if(iterStacks == null) - { - iterStacks = new ArrayList(); - } - else { - iterStacks.clear(); - } - - List keys = new ArrayList(); - - for(String s : OreDictionary.getOreNames()) - { - if(oreName.equals(s) || oreName.equals("*")) - { - keys.add(s); - } - else if(oreName.endsWith("*") && !oreName.startsWith("*")) - { - if(s.startsWith(oreName.substring(0, oreName.length()-1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && !oreName.endsWith("*")) - { - if(s.endsWith(oreName.substring(1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && oreName.endsWith("*")) - { - if(s.contains(oreName.substring(1, oreName.length()-1))) - { - keys.add(s); - } - } - } - - for(String key : keys) - { - for(ItemStack stack : OreDictionary.getOres(key)) - { - ItemStack toAdd = stack.copy(); - - if(!iterStacks.contains(stack)) - { - iterStacks.add(stack.copy()); - } - } - } - - stackSwitch = 0; - stackIndex = -1; - } - - private void setOreDictKey() - { - String oreName = oreDictText.getText(); - - if(oreName == null || oreName.isEmpty()) - { - status = EnumColor.DARK_RED + MekanismUtils.localize("gui.oredictFilter.noKey"); - return; - } - else if(oreName.equals(filter.oreDictName)) - { - status = EnumColor.DARK_RED + MekanismUtils.localize("gui.oredictFilter.sameKey"); - return; - } - - updateStackList(oreName); - - filter.oreDictName = oreName; - oreDictText.setText(""); - } + } + + private void updateStackList(String oreName) + { + if(iterStacks == null) + { + iterStacks = new ArrayList(); + } + else { + iterStacks.clear(); + } + + List keys = new ArrayList(); + + for(String s : OreDictionary.getOreNames()) + { + if(oreName.equals(s) || oreName.equals("*")) + { + keys.add(s); + } + else if(oreName.endsWith("*") && !oreName.startsWith("*")) + { + if(s.startsWith(oreName.substring(0, oreName.length()-1))) + { + keys.add(s); + } + } + else if(oreName.startsWith("*") && !oreName.endsWith("*")) + { + if(s.endsWith(oreName.substring(1))) + { + keys.add(s); + } + } + else if(oreName.startsWith("*") && oreName.endsWith("*")) + { + if(s.contains(oreName.substring(1, oreName.length()-1))) + { + keys.add(s); + } + } + } + + for(String key : keys) + { + for(ItemStack stack : OreDictionary.getOres(key)) + { + ItemStack toAdd = stack.copy(); + + if(!iterStacks.contains(stack)) + { + iterStacks.add(stack.copy()); + } + } + } + + stackSwitch = 0; + stackIndex = -1; + } + + private void setOreDictKey() + { + String oreName = oreDictText.getText(); + + if(oreName == null || oreName.isEmpty()) + { + status = EnumColor.DARK_RED + MekanismUtils.localize("gui.oredictFilter.noKey"); + return; + } + else if(oreName.equals(filter.oreDictName)) + { + status = EnumColor.DARK_RED + MekanismUtils.localize("gui.oredictFilter.sameKey"); + return; + } + + updateStackList(oreName); + + filter.oreDictName = oreName; + oreDictText.setText(""); + } } diff --git a/common/mekanism/client/gui/GuiTeleporter.java b/common/mekanism/client/gui/GuiTeleporter.java index 7da26e816..a0476a2ca 100644 --- a/common/mekanism/client/gui/GuiTeleporter.java +++ b/common/mekanism/client/gui/GuiTeleporter.java @@ -20,47 +20,47 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiTeleporter extends GuiMekanism { - public TileEntityTeleporter tileEntity; + public TileEntityTeleporter tileEntity; - public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) - { - super(new ContainerTeleporter(inventory, tentity)); - tileEntity = tentity; - } + public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) + { + super(new ContainerTeleporter(inventory, tentity)); + tileEntity = tentity; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(tileEntity.status, 66, 19, 0x00CD00); - + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRenderer.drawString(tileEntity.status, 66, 19, 0x00CD00); + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - + } + @Override - protected void mouseClicked(int x, int y, int button) - { + protected void mouseClicked(int x, int y, int button) + { super.mouseClicked(x, y, button); - + int xAxis = (x - (width - xSize) / 2); int yAxis = (y - (height - ySize) / 2); - + ArrayList data = new ArrayList(); - + if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58) { data.add(0); data.add(getIncrementedNumber(tileEntity.code.digitOne)); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); tileEntity.code.digitOne = getIncrementedNumber(tileEntity.code.digitOne); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); @@ -69,7 +69,7 @@ public class GuiTeleporter extends GuiMekanism { data.add(1); data.add(getIncrementedNumber(tileEntity.code.digitTwo)); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); tileEntity.code.digitTwo = getIncrementedNumber(tileEntity.code.digitTwo); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); @@ -78,7 +78,7 @@ public class GuiTeleporter extends GuiMekanism { data.add(2); data.add(getIncrementedNumber(tileEntity.code.digitThree)); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); tileEntity.code.digitThree = getIncrementedNumber(tileEntity.code.digitThree); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); @@ -87,57 +87,57 @@ public class GuiTeleporter extends GuiMekanism { data.add(3); data.add(getIncrementedNumber(tileEntity.code.digitFour)); - + PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data)); tileEntity.code.digitFour = getIncrementedNumber(tileEntity.code.digitFour); mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } - } + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 13, 52 - displayInt, 4, displayInt); - - displayInt = getYAxisForNumber(tileEntity.code.digitOne); - drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13); - - displayInt = getYAxisForNumber(tileEntity.code.digitTwo); - drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13); - - displayInt = getYAxisForNumber(tileEntity.code.digitThree); - drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13); - - displayInt = getYAxisForNumber(tileEntity.code.digitFour); - drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13); - } - - public int getIncrementedNumber(int i) - { - if(i < 9) + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 13, 52 - displayInt, 4, displayInt); + + displayInt = getYAxisForNumber(tileEntity.code.digitOne); + drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(tileEntity.code.digitTwo); + drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(tileEntity.code.digitThree); + drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(tileEntity.code.digitFour); + drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13); + } + + public int getIncrementedNumber(int i) + { + if(i < 9) { - i++; + i++; } - else if(i == 9) - { - i = 0; - } - - return i; - } - - public int getYAxisForNumber(int i) - { - return i*13; - } + else if(i == 9) + { + i = 0; + } + + return i; + } + + public int getYAxisForNumber(int i) + { + return i*13; + } } diff --git a/common/mekanism/client/gui/GuiUpgradeManagement.java b/common/mekanism/client/gui/GuiUpgradeManagement.java index 5cffcc84e..1f144ce27 100644 --- a/common/mekanism/client/gui/GuiUpgradeManagement.java +++ b/common/mekanism/client/gui/GuiUpgradeManagement.java @@ -17,48 +17,48 @@ public class GuiUpgradeManagement extends GuiElement { super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiUpgradeManagement.png"), gui, tile, def); } - + @Override public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { mc.renderEngine.bindTexture(RESOURCE); - + guiObj.drawTexturedModalRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 63); - + IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity; int displayInt = upgradeTile.getComponent().getScaledUpgradeProgress(14); - - guiObj.drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 26, 0, 10, displayInt); - + + guiObj.drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 26, 0, 10, displayInt); + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void renderForeground(int xAxis, int yAxis) { mc.renderEngine.bindTexture(RESOURCE); - + IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity; - + if(getFontRenderer() != null) { getFontRenderer().drawString("S:" + (upgradeTile.getSpeedMultiplier()+1) + "x", 179, 47, 0x404040); - getFontRenderer().drawString("E:" + (upgradeTile.getEnergyMultiplier()+1) + "x", 179, 57, 0x404040); + getFontRenderer().drawString("E:" + (upgradeTile.getEnergyMultiplier()+1) + "x", 179, 57, 0x404040); } - + if(xAxis >= 179 && xAxis <= 198 && yAxis >= 47 && yAxis <= 54) { displayTooltip(MekanismUtils.localize("gui.removeSpeedUpgrade"), xAxis, yAxis); } - + if(xAxis >= 179 && xAxis <= 198 && yAxis >= 57 && yAxis <= 64) { displayTooltip(MekanismUtils.localize("gui.removeEnergyUpgrade"), xAxis, yAxis); } - + mc.renderEngine.bindTexture(defaultLocation); } - + @Override public void preMouseClicked(int xAxis, int yAxis, int button) { @@ -70,7 +70,7 @@ public class GuiUpgradeManagement extends GuiElement } } } - + @Override public void mouseClicked(int xAxis, int yAxis, int button) { @@ -81,13 +81,13 @@ public class GuiUpgradeManagement extends GuiElement mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketRemoveUpgrade().setParams(Coord4D.get(tileEntity), (byte)0)); } - + if(xAxis >= 179 && xAxis <= 198 && yAxis >= 57 && yAxis <= 64) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.SERVER, new PacketRemoveUpgrade().setParams(Coord4D.get(tileEntity), (byte)1)); } - + if(xAxis >= 180 && xAxis <= 196 && yAxis >= 11 && yAxis <= 27) { offsetX(-26); diff --git a/common/mekanism/client/model/ModelArmoredJetpack.java b/common/mekanism/client/model/ModelArmoredJetpack.java index 683d3ca2f..34cde2b37 100644 --- a/common/mekanism/client/model/ModelArmoredJetpack.java +++ b/common/mekanism/client/model/ModelArmoredJetpack.java @@ -44,183 +44,183 @@ public class ModelArmoredJetpack extends ModelBase textureWidth = 128; textureHeight = 64; - Packtop = new ModelRenderer(this, 92, 28); - Packtop.addBox(-4F, 0F, 4F, 8, 4, 1); - Packtop.setRotationPoint(0F, 0F, 0F); - Packtop.setTextureSize(128, 64); - Packtop.mirror = true; - setRotation(Packtop, 0.2094395F, 0F, 0F); - Packbottom = new ModelRenderer(this, 92, 42); - Packbottom.addBox(-4F, 4.1F, 1.5F, 8, 4, 4); - Packbottom.setRotationPoint(0F, 0F, 0F); - Packbottom.setTextureSize(128, 64); - Packbottom.mirror = true; - setRotation(Packbottom, -0.0872665F, 0F, 0F); - Thrusterleft = new ModelRenderer(this, 69, 30); - Thrusterleft.addBox(7.8F, 1.5F, -2.4F, 3, 3, 3); - Thrusterleft.setRotationPoint(0F, 0F, 0F); - Thrusterleft.setTextureSize(128, 64); - Thrusterleft.mirror = true; - setRotation(Thrusterleft, 0.7853982F, -0.715585F, 0.3490659F); - Thrusterright = new ModelRenderer(this, 69, 30); - Thrusterright.addBox(-10.8F, 1.5F, -2.4F, 3, 3, 3); - Thrusterright.setRotationPoint(0F, 0F, 0F); - Thrusterright.setTextureSize(128, 64); - Thrusterright.mirror = true; - setRotation(Thrusterright, 0.7853982F, 0.715585F, -0.3490659F); - Fueltuberight = new ModelRenderer(this, 92, 23); - Fueltuberight.addBox(-11.2F, 2F, -1.9F, 8, 2, 2); - Fueltuberight.setRotationPoint(0F, 0F, 0F); - Fueltuberight.setTextureSize(128, 64); - Fueltuberight.mirror = true; - setRotation(Fueltuberight, 0.7853982F, 0.715585F, -0.3490659F); - Fueltubeleft = new ModelRenderer(this, 92, 23); - Fueltubeleft.addBox(3.2F, 2F, -1.9F, 8, 2, 2); - Fueltubeleft.setRotationPoint(0F, 0F, 0F); - Fueltubeleft.setTextureSize(128, 64); - Fueltubeleft.mirror = true; - setRotation(Fueltubeleft, 0.7853982F, -0.715585F, 0.3490659F); - Packmid = new ModelRenderer(this, 92, 34); - Packmid.addBox(-4F, 3.3F, 1.5F, 8, 1, 4); - Packmid.setRotationPoint(0F, 0F, 0F); - Packmid.setTextureSize(128, 64); - Packmid.mirror = true; - setRotation(Packmid, 0F, 0F, 0F); - Packcore = new ModelRenderer(this, 69, 2); - Packcore.addBox(-3.5F, 3F, 2F, 7, 1, 3); - Packcore.setRotationPoint(0F, 0F, 0F); - Packcore.setTextureSize(128, 64); - Packcore.mirror = true; - setRotation(Packcore, 0F, 0F, 0F); - WingsupportL = new ModelRenderer(this, 71, 55); - WingsupportL.addBox(3F, -1F, 2.2F, 7, 2, 2); - WingsupportL.setRotationPoint(0F, 0F, 0F); - WingsupportL.setTextureSize(128, 64); - WingsupportL.mirror = true; - setRotation(WingsupportL, 0F, 0F, 0.2792527F); - WingsupportR = new ModelRenderer(this, 71, 55); - WingsupportR.addBox(-10F, -1F, 2.2F, 7, 2, 2); - WingsupportR.setRotationPoint(0F, 0F, 0F); - WingsupportR.setTextureSize(128, 64); - WingsupportR.mirror = true; - setRotation(WingsupportR, 0F, 0F, -0.2792527F); - Packtoprear = new ModelRenderer(this, 106, 28); - Packtoprear.addBox(-4F, 1F, 1F, 8, 3, 3); - Packtoprear.setRotationPoint(0F, 0F, 0F); - Packtoprear.setTextureSize(128, 64); - Packtoprear.mirror = true; - setRotation(Packtoprear, 0.2094395F, 0F, 0F); - ExtendosupportL = new ModelRenderer(this, 94, 16); - ExtendosupportL.addBox(8F, -0.2F, 2.5F, 9, 1, 1); - ExtendosupportL.setRotationPoint(0F, 0F, 0F); - ExtendosupportL.setTextureSize(128, 64); - ExtendosupportL.mirror = true; - setRotation(ExtendosupportL, 0F, 0F, 0.2792527F); - ExtendosupportR = new ModelRenderer(this, 94, 16); - ExtendosupportR.addBox(-17F, -0.2F, 2.5F, 9, 1, 1); - ExtendosupportR.setRotationPoint(0F, 0F, 0F); - ExtendosupportR.setTextureSize(128, 64); - ExtendosupportR.mirror = true; - setRotation(ExtendosupportR, 0F, 0F, -0.2792527F); - WingbladeL = new ModelRenderer(this, 62, 5); - WingbladeL.addBox(3.3F, 1.1F, 3F, 14, 2, 0); - WingbladeL.setRotationPoint(0F, 0F, 0F); - WingbladeL.setTextureSize(128, 64); - WingbladeL.mirror = true; - setRotation(WingbladeL, 0F, 0F, 0.2094395F); - WingbladeR = new ModelRenderer(this, 62, 5); - WingbladeR.addBox(-17.3F, 1.1F, 3F, 14, 2, 0); - WingbladeR.setRotationPoint(0F, 0F, 0F); - WingbladeR.setTextureSize(128, 64); - WingbladeR.mirror = true; - setRotation(WingbladeR, 0F, 0F, -0.2094395F); - Packdoodad2 = new ModelRenderer(this, 116, 0); - Packdoodad2.addBox(1F, 0.5F, 4.2F, 2, 1, 1); - Packdoodad2.setRotationPoint(0F, 0F, 0F); - Packdoodad2.setTextureSize(128, 64); - Packdoodad2.mirror = true; - setRotation(Packdoodad2, 0.2094395F, 0F, 0F); - Packdoodad3 = new ModelRenderer(this, 116, 0); - Packdoodad3.addBox(1F, 2F, 4.2F, 2, 1, 1); - Packdoodad3.setRotationPoint(0F, 0F, 0F); - Packdoodad3.setTextureSize(128, 64); - Packdoodad3.mirror = true; - setRotation(Packdoodad3, 0.2094395F, 0F, 0F); - Bottomthruster = new ModelRenderer(this, 68, 26); - Bottomthruster.addBox(-3F, 8F, 2.333333F, 6, 1, 2); - Bottomthruster.setRotationPoint(0F, 0F, 0F); - Bottomthruster.setTextureSize(128, 64); - Bottomthruster.mirror = true; - setRotation(Bottomthruster, 0F, 0F, 0F); - light1 = new ModelRenderer(this, 55, 2); - light1.addBox(2F, 6.55F, 4F, 1, 1, 1); - light1.setRotationPoint(0F, 0F, 0F); - light1.setTextureSize(128, 64); - light1.mirror = true; - setRotation(light1, 0F, 0F, 0F); - light2 = new ModelRenderer(this, 55, 2); - light2.addBox(0F, 6.55F, 4F, 1, 1, 1); - light2.setRotationPoint(0F, 0F, 0F); - light2.setTextureSize(128, 64); - light2.mirror = true; - setRotation(light2, 0F, 0F, 0F); - light3 = new ModelRenderer(this, 55, 2); - light3.addBox(-3F, 6.55F, 4F, 1, 1, 1); - light3.setRotationPoint(0F, 0F, 0F); - light3.setTextureSize(128, 64); - light3.mirror = true; - setRotation(light3, 0F, 0F, 0F); - Chestplate = new ModelRenderer(this, 104, 22); - Chestplate.addBox(-4F, 1.333333F, -3F, 8, 4, 3); - Chestplate.setRotationPoint(0F, 0F, 0F); - Chestplate.setTextureSize(128, 64); - Chestplate.mirror = true; - setRotation(Chestplate, -0.3665191F, 0F, 0F); - Leftguardtop = new ModelRenderer(this, 87, 31); - Leftguardtop.addBox(0.95F, 3F, -5F, 3, 4, 2); - Leftguardtop.setRotationPoint(0F, 0F, 0F); - Leftguardtop.setTextureSize(128, 64); - Leftguardtop.mirror = true; - setRotation(Leftguardtop, 0.2094395F, 0F, 0F); - Leftguardtop.mirror = false; - Rightguardtop = new ModelRenderer(this, 87, 31); - Rightguardtop.addBox(-3.95F, 3F, -5F, 3, 4, 2); - Rightguardtop.setRotationPoint(0F, 0F, 0F); - Rightguardtop.setTextureSize(128, 64); - Rightguardtop.mirror = true; - setRotation(Rightguardtop, 0.2094395F, 0F, 0F); - middleplate = new ModelRenderer(this, 93, 20); - middleplate.addBox(-1.5F, 3F, -6.2F, 3, 5, 3); - middleplate.setRotationPoint(0F, 0F, 0F); - middleplate.setTextureSize(128, 64); - middleplate.mirror = true; - setRotation(middleplate, 0.2094395F, 0F, 0F); - middleplate.mirror = false; - Rightguardbot = new ModelRenderer(this, 84, 30); - Rightguardbot.addBox(-3.5F, 5.5F, -6.5F, 2, 2, 2); - Rightguardbot.setRotationPoint(0F, 0F, 0F); - Rightguardbot.setTextureSize(128, 64); - Rightguardbot.mirror = true; - setRotation(Rightguardbot, 0.4712389F, 0F, 0F); - Rightguardbot.mirror = false; - Leftguardbot = new ModelRenderer(this, 84, 30); - Leftguardbot.addBox(1.5F, 5.5F, -6.5F, 2, 2, 2); - Leftguardbot.setRotationPoint(0F, 0F, 0F); - Leftguardbot.setTextureSize(128, 64); - Leftguardbot.mirror = true; - setRotation(Leftguardbot, 0.4712389F, 0F, 0F); - Rightlight = new ModelRenderer(this, 81, 0); - Rightlight.addBox(-3F, 4F, -4.5F, 1, 3, 1); - Rightlight.setRotationPoint(0F, 0F, 0F); - Rightlight.setTextureSize(128, 64); - Rightlight.mirror = true; - setRotation(Rightlight, 0F, 0F, 0F); - Leftlight = new ModelRenderer(this, 81, 0); - Leftlight.addBox(2F, 4F, -4.5F, 1, 3, 1); - Leftlight.setRotationPoint(0F, 0F, 0F); - Leftlight.setTextureSize(128, 64); - Leftlight.mirror = true; - setRotation(Leftlight, 0F, 0F, 0F); + Packtop = new ModelRenderer(this, 92, 28); + Packtop.addBox(-4F, 0F, 4F, 8, 4, 1); + Packtop.setRotationPoint(0F, 0F, 0F); + Packtop.setTextureSize(128, 64); + Packtop.mirror = true; + setRotation(Packtop, 0.2094395F, 0F, 0F); + Packbottom = new ModelRenderer(this, 92, 42); + Packbottom.addBox(-4F, 4.1F, 1.5F, 8, 4, 4); + Packbottom.setRotationPoint(0F, 0F, 0F); + Packbottom.setTextureSize(128, 64); + Packbottom.mirror = true; + setRotation(Packbottom, -0.0872665F, 0F, 0F); + Thrusterleft = new ModelRenderer(this, 69, 30); + Thrusterleft.addBox(7.8F, 1.5F, -2.4F, 3, 3, 3); + Thrusterleft.setRotationPoint(0F, 0F, 0F); + Thrusterleft.setTextureSize(128, 64); + Thrusterleft.mirror = true; + setRotation(Thrusterleft, 0.7853982F, -0.715585F, 0.3490659F); + Thrusterright = new ModelRenderer(this, 69, 30); + Thrusterright.addBox(-10.8F, 1.5F, -2.4F, 3, 3, 3); + Thrusterright.setRotationPoint(0F, 0F, 0F); + Thrusterright.setTextureSize(128, 64); + Thrusterright.mirror = true; + setRotation(Thrusterright, 0.7853982F, 0.715585F, -0.3490659F); + Fueltuberight = new ModelRenderer(this, 92, 23); + Fueltuberight.addBox(-11.2F, 2F, -1.9F, 8, 2, 2); + Fueltuberight.setRotationPoint(0F, 0F, 0F); + Fueltuberight.setTextureSize(128, 64); + Fueltuberight.mirror = true; + setRotation(Fueltuberight, 0.7853982F, 0.715585F, -0.3490659F); + Fueltubeleft = new ModelRenderer(this, 92, 23); + Fueltubeleft.addBox(3.2F, 2F, -1.9F, 8, 2, 2); + Fueltubeleft.setRotationPoint(0F, 0F, 0F); + Fueltubeleft.setTextureSize(128, 64); + Fueltubeleft.mirror = true; + setRotation(Fueltubeleft, 0.7853982F, -0.715585F, 0.3490659F); + Packmid = new ModelRenderer(this, 92, 34); + Packmid.addBox(-4F, 3.3F, 1.5F, 8, 1, 4); + Packmid.setRotationPoint(0F, 0F, 0F); + Packmid.setTextureSize(128, 64); + Packmid.mirror = true; + setRotation(Packmid, 0F, 0F, 0F); + Packcore = new ModelRenderer(this, 69, 2); + Packcore.addBox(-3.5F, 3F, 2F, 7, 1, 3); + Packcore.setRotationPoint(0F, 0F, 0F); + Packcore.setTextureSize(128, 64); + Packcore.mirror = true; + setRotation(Packcore, 0F, 0F, 0F); + WingsupportL = new ModelRenderer(this, 71, 55); + WingsupportL.addBox(3F, -1F, 2.2F, 7, 2, 2); + WingsupportL.setRotationPoint(0F, 0F, 0F); + WingsupportL.setTextureSize(128, 64); + WingsupportL.mirror = true; + setRotation(WingsupportL, 0F, 0F, 0.2792527F); + WingsupportR = new ModelRenderer(this, 71, 55); + WingsupportR.addBox(-10F, -1F, 2.2F, 7, 2, 2); + WingsupportR.setRotationPoint(0F, 0F, 0F); + WingsupportR.setTextureSize(128, 64); + WingsupportR.mirror = true; + setRotation(WingsupportR, 0F, 0F, -0.2792527F); + Packtoprear = new ModelRenderer(this, 106, 28); + Packtoprear.addBox(-4F, 1F, 1F, 8, 3, 3); + Packtoprear.setRotationPoint(0F, 0F, 0F); + Packtoprear.setTextureSize(128, 64); + Packtoprear.mirror = true; + setRotation(Packtoprear, 0.2094395F, 0F, 0F); + ExtendosupportL = new ModelRenderer(this, 94, 16); + ExtendosupportL.addBox(8F, -0.2F, 2.5F, 9, 1, 1); + ExtendosupportL.setRotationPoint(0F, 0F, 0F); + ExtendosupportL.setTextureSize(128, 64); + ExtendosupportL.mirror = true; + setRotation(ExtendosupportL, 0F, 0F, 0.2792527F); + ExtendosupportR = new ModelRenderer(this, 94, 16); + ExtendosupportR.addBox(-17F, -0.2F, 2.5F, 9, 1, 1); + ExtendosupportR.setRotationPoint(0F, 0F, 0F); + ExtendosupportR.setTextureSize(128, 64); + ExtendosupportR.mirror = true; + setRotation(ExtendosupportR, 0F, 0F, -0.2792527F); + WingbladeL = new ModelRenderer(this, 62, 5); + WingbladeL.addBox(3.3F, 1.1F, 3F, 14, 2, 0); + WingbladeL.setRotationPoint(0F, 0F, 0F); + WingbladeL.setTextureSize(128, 64); + WingbladeL.mirror = true; + setRotation(WingbladeL, 0F, 0F, 0.2094395F); + WingbladeR = new ModelRenderer(this, 62, 5); + WingbladeR.addBox(-17.3F, 1.1F, 3F, 14, 2, 0); + WingbladeR.setRotationPoint(0F, 0F, 0F); + WingbladeR.setTextureSize(128, 64); + WingbladeR.mirror = true; + setRotation(WingbladeR, 0F, 0F, -0.2094395F); + Packdoodad2 = new ModelRenderer(this, 116, 0); + Packdoodad2.addBox(1F, 0.5F, 4.2F, 2, 1, 1); + Packdoodad2.setRotationPoint(0F, 0F, 0F); + Packdoodad2.setTextureSize(128, 64); + Packdoodad2.mirror = true; + setRotation(Packdoodad2, 0.2094395F, 0F, 0F); + Packdoodad3 = new ModelRenderer(this, 116, 0); + Packdoodad3.addBox(1F, 2F, 4.2F, 2, 1, 1); + Packdoodad3.setRotationPoint(0F, 0F, 0F); + Packdoodad3.setTextureSize(128, 64); + Packdoodad3.mirror = true; + setRotation(Packdoodad3, 0.2094395F, 0F, 0F); + Bottomthruster = new ModelRenderer(this, 68, 26); + Bottomthruster.addBox(-3F, 8F, 2.333333F, 6, 1, 2); + Bottomthruster.setRotationPoint(0F, 0F, 0F); + Bottomthruster.setTextureSize(128, 64); + Bottomthruster.mirror = true; + setRotation(Bottomthruster, 0F, 0F, 0F); + light1 = new ModelRenderer(this, 55, 2); + light1.addBox(2F, 6.55F, 4F, 1, 1, 1); + light1.setRotationPoint(0F, 0F, 0F); + light1.setTextureSize(128, 64); + light1.mirror = true; + setRotation(light1, 0F, 0F, 0F); + light2 = new ModelRenderer(this, 55, 2); + light2.addBox(0F, 6.55F, 4F, 1, 1, 1); + light2.setRotationPoint(0F, 0F, 0F); + light2.setTextureSize(128, 64); + light2.mirror = true; + setRotation(light2, 0F, 0F, 0F); + light3 = new ModelRenderer(this, 55, 2); + light3.addBox(-3F, 6.55F, 4F, 1, 1, 1); + light3.setRotationPoint(0F, 0F, 0F); + light3.setTextureSize(128, 64); + light3.mirror = true; + setRotation(light3, 0F, 0F, 0F); + Chestplate = new ModelRenderer(this, 104, 22); + Chestplate.addBox(-4F, 1.333333F, -3F, 8, 4, 3); + Chestplate.setRotationPoint(0F, 0F, 0F); + Chestplate.setTextureSize(128, 64); + Chestplate.mirror = true; + setRotation(Chestplate, -0.3665191F, 0F, 0F); + Leftguardtop = new ModelRenderer(this, 87, 31); + Leftguardtop.addBox(0.95F, 3F, -5F, 3, 4, 2); + Leftguardtop.setRotationPoint(0F, 0F, 0F); + Leftguardtop.setTextureSize(128, 64); + Leftguardtop.mirror = true; + setRotation(Leftguardtop, 0.2094395F, 0F, 0F); + Leftguardtop.mirror = false; + Rightguardtop = new ModelRenderer(this, 87, 31); + Rightguardtop.addBox(-3.95F, 3F, -5F, 3, 4, 2); + Rightguardtop.setRotationPoint(0F, 0F, 0F); + Rightguardtop.setTextureSize(128, 64); + Rightguardtop.mirror = true; + setRotation(Rightguardtop, 0.2094395F, 0F, 0F); + middleplate = new ModelRenderer(this, 93, 20); + middleplate.addBox(-1.5F, 3F, -6.2F, 3, 5, 3); + middleplate.setRotationPoint(0F, 0F, 0F); + middleplate.setTextureSize(128, 64); + middleplate.mirror = true; + setRotation(middleplate, 0.2094395F, 0F, 0F); + middleplate.mirror = false; + Rightguardbot = new ModelRenderer(this, 84, 30); + Rightguardbot.addBox(-3.5F, 5.5F, -6.5F, 2, 2, 2); + Rightguardbot.setRotationPoint(0F, 0F, 0F); + Rightguardbot.setTextureSize(128, 64); + Rightguardbot.mirror = true; + setRotation(Rightguardbot, 0.4712389F, 0F, 0F); + Rightguardbot.mirror = false; + Leftguardbot = new ModelRenderer(this, 84, 30); + Leftguardbot.addBox(1.5F, 5.5F, -6.5F, 2, 2, 2); + Leftguardbot.setRotationPoint(0F, 0F, 0F); + Leftguardbot.setTextureSize(128, 64); + Leftguardbot.mirror = true; + setRotation(Leftguardbot, 0.4712389F, 0F, 0F); + Rightlight = new ModelRenderer(this, 81, 0); + Rightlight.addBox(-3F, 4F, -4.5F, 1, 3, 1); + Rightlight.setRotationPoint(0F, 0F, 0F); + Rightlight.setTextureSize(128, 64); + Rightlight.mirror = true; + setRotation(Rightlight, 0F, 0F, 0F); + Leftlight = new ModelRenderer(this, 81, 0); + Leftlight.addBox(2F, 4F, -4.5F, 1, 3, 1); + Leftlight.setRotationPoint(0F, 0F, 0F); + Leftlight.setTextureSize(128, 64); + Leftlight.mirror = true; + setRotation(Leftlight, 0F, 0F, 0F); } public void render(float size) @@ -240,42 +240,42 @@ public class ModelArmoredJetpack extends ModelBase Packdoodad2.render(size); Packdoodad3.render(size); Bottomthruster.render(size); - + GL11.glPushMatrix(); MekanismRenderer.blendOn(); MekanismRenderer.glowOn(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glColor4f(1, 1, 1, 0.2F); - + WingbladeL.render(size); WingbladeR.render(size); - + GL11.glColor4f(1, 1, 1, 1); GL11.glDisable(GL11.GL_CULL_FACE); MekanismRenderer.glowOff(); MekanismRenderer.blendOff(); GL11.glPopMatrix(); - + MekanismRenderer.glowOn(); light1.render(size); light2.render(size); light3.render(size); Packcore.render(size); - + GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.0F, -0.0625F); - + Rightlight.render(size); Leftlight.render(size); MekanismRenderer.glowOff(); - + Chestplate.render(size); Leftguardtop.render(size); Rightguardtop.render(size); middleplate.render(size); Rightguardbot.render(size); Leftguardbot.render(size); - + GL11.glPopMatrix(); } diff --git a/common/mekanism/client/model/ModelAtomicDisassembler.java b/common/mekanism/client/model/ModelAtomicDisassembler.java index 164688d1c..567c9d3f4 100644 --- a/common/mekanism/client/model/ModelAtomicDisassembler.java +++ b/common/mekanism/client/model/ModelAtomicDisassembler.java @@ -133,16 +133,16 @@ public class ModelAtomicDisassembler extends ModelBase { GL11.glPushMatrix(); MekanismRenderer.glowOn(); - + Shape3.render(size); Shape5.render(size); Shape9.render(size); Shape16.render(size); Shape14.render(size); - + MekanismRenderer.glowOff(); GL11.glPopMatrix(); - + Shape1.render(size); Shape2.render(size); Shape6.render(size); diff --git a/common/mekanism/client/model/ModelBalloon.java b/common/mekanism/client/model/ModelBalloon.java index d384ca3b4..610729801 100644 --- a/common/mekanism/client/model/ModelBalloon.java +++ b/common/mekanism/client/model/ModelBalloon.java @@ -53,22 +53,22 @@ public class ModelBalloon extends ModelBase String.mirror = true; setRotation(String, 0F, 0F, 0F); } - + public void render(float size, EnumColor color) { GL11.glPushMatrix(); GL11.glColor3f(color.getColor(0), color.getColor(1), color.getColor(2)); GL11.glScalef(1.5F, 1.5F, 1.5F); GL11.glTranslatef(0, -0.07F, 0); - + Balloon2.render(size); Balloon1.render(size); Balloon3.render(size); Balloonnub.render(size); - + GL11.glColor3f(1, 1, 1); GL11.glPopMatrix(); - + GL11.glPushMatrix(); GL11.glScalef(0.2F, 1, 0.2F); String.render(size); diff --git a/common/mekanism/client/model/ModelBoxSelectiveFace.java b/common/mekanism/client/model/ModelBoxSelectiveFace.java index 7fada5760..f36ee01d8 100644 --- a/common/mekanism/client/model/ModelBoxSelectiveFace.java +++ b/common/mekanism/client/model/ModelBoxSelectiveFace.java @@ -9,97 +9,97 @@ import net.minecraft.client.renderer.Tessellator; @SideOnly(Side.CLIENT) public class ModelBoxSelectiveFace { - private PositionTextureVertex[] vertexPositions; - - private TexturedQuad[] quadList; - - public final float posX1; - public final float posY1; - public final float posZ1; - - public final float posX2; - public final float posY2; - public final float posZ2; + private PositionTextureVertex[] vertexPositions; - public ModelBoxSelectiveFace(ModelRendererSelectiveFace modelRenderer, int textureOffsetU, int textureOffsetV, float xMin, float yMin, float zMin, int xSize, int ySize, int zSize, float scaleFactor) - { - posX1 = xMin; - posY1 = yMin; - posZ1 = zMin; - - posX2 = xMin + xSize; - posY2 = yMin + ySize; - posZ2 = zMin + zSize; - - vertexPositions = new PositionTextureVertex[8]; - - quadList = new TexturedQuad[6]; - - float xMax = xMin + xSize; - float yMax = yMin + ySize; - float zMax = zMin + zSize; - - xMin -= scaleFactor; - yMin -= scaleFactor; - zMin -= scaleFactor; - - xMax += scaleFactor; - yMax += scaleFactor; - zMax += scaleFactor; + private TexturedQuad[] quadList; - if(modelRenderer.mirror) - { - float placeholder = xMax; - xMax = xMin; - xMin = placeholder; - } + public final float posX1; + public final float posY1; + public final float posZ1; - PositionTextureVertex positiontexturevertex0 = new PositionTextureVertex(xMin, yMin, zMin, 0.0F, 0.0F); - PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(xMax, yMin, zMin, 0.0F, 8.0F); - PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(xMax, yMax, zMin, 8.0F, 8.0F); - PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(xMin, yMax, zMin, 8.0F, 0.0F); - PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(xMin, yMin, zMax, 0.0F, 0.0F); - PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(xMax, yMin, zMax, 0.0F, 8.0F); - PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(xMax, yMax, zMax, 8.0F, 8.0F); - PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(xMin, yMax, zMax, 8.0F, 0.0F); - - vertexPositions[0] = positiontexturevertex0; - vertexPositions[1] = positiontexturevertex1; - vertexPositions[2] = positiontexturevertex2; - vertexPositions[3] = positiontexturevertex3; - vertexPositions[4] = positiontexturevertex4; - vertexPositions[5] = positiontexturevertex5; - vertexPositions[6] = positiontexturevertex6; - vertexPositions[7] = positiontexturevertex7; - - quadList[0] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex2, positiontexturevertex3, positiontexturevertex7, positiontexturevertex6}, textureOffsetU + zSize + xSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + xSize, textureOffsetV, modelRenderer.textureWidth, modelRenderer.textureHeight); - quadList[1] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex5, positiontexturevertex4, positiontexturevertex0, positiontexturevertex1}, textureOffsetU + zSize, textureOffsetV, textureOffsetU + zSize + xSize, textureOffsetV + zSize, modelRenderer.textureWidth, modelRenderer.textureHeight); - quadList[2] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex4, positiontexturevertex5, positiontexturevertex6, positiontexturevertex7}, textureOffsetU + zSize + xSize + zSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + zSize + xSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight); - quadList[3] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex1, positiontexturevertex0, positiontexturevertex3, positiontexturevertex2}, textureOffsetU + zSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight); - quadList[4] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex0, positiontexturevertex4, positiontexturevertex7, positiontexturevertex3}, textureOffsetU, textureOffsetV + zSize, textureOffsetU + zSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight); - quadList[5] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex5, positiontexturevertex1, positiontexturevertex2, positiontexturevertex6}, textureOffsetU + zSize + xSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + zSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight); + public final float posX2; + public final float posY2; + public final float posZ2; - if(modelRenderer.mirror) - { - for(int quad = 0; quad < quadList.length; quad++) - { - quadList[quad].flipFace(); - } - } - } + public ModelBoxSelectiveFace(ModelRendererSelectiveFace modelRenderer, int textureOffsetU, int textureOffsetV, float xMin, float yMin, float zMin, int xSize, int ySize, int zSize, float scaleFactor) + { + posX1 = xMin; + posY1 = yMin; + posZ1 = zMin; - @SideOnly(Side.CLIENT) - public void render(Tessellator tessellator, boolean[] skippedFaces, float scaleFactor) - { - if(skippedFaces.length == quadList.length) + posX2 = xMin + xSize; + posY2 = yMin + ySize; + posZ2 = zMin + zSize; + + vertexPositions = new PositionTextureVertex[8]; + + quadList = new TexturedQuad[6]; + + float xMax = xMin + xSize; + float yMax = yMin + ySize; + float zMax = zMin + zSize; + + xMin -= scaleFactor; + yMin -= scaleFactor; + zMin -= scaleFactor; + + xMax += scaleFactor; + yMax += scaleFactor; + zMax += scaleFactor; + + if(modelRenderer.mirror) { - for(int i = 0; i < skippedFaces.length; ++i) - { - if(!skippedFaces[i]) - { - quadList[i].draw(tessellator, scaleFactor); - } - } + float placeholder = xMax; + xMax = xMin; + xMin = placeholder; } - } + + PositionTextureVertex positiontexturevertex0 = new PositionTextureVertex(xMin, yMin, zMin, 0.0F, 0.0F); + PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(xMax, yMin, zMin, 0.0F, 8.0F); + PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(xMax, yMax, zMin, 8.0F, 8.0F); + PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(xMin, yMax, zMin, 8.0F, 0.0F); + PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(xMin, yMin, zMax, 0.0F, 0.0F); + PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(xMax, yMin, zMax, 0.0F, 8.0F); + PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(xMax, yMax, zMax, 8.0F, 8.0F); + PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(xMin, yMax, zMax, 8.0F, 0.0F); + + vertexPositions[0] = positiontexturevertex0; + vertexPositions[1] = positiontexturevertex1; + vertexPositions[2] = positiontexturevertex2; + vertexPositions[3] = positiontexturevertex3; + vertexPositions[4] = positiontexturevertex4; + vertexPositions[5] = positiontexturevertex5; + vertexPositions[6] = positiontexturevertex6; + vertexPositions[7] = positiontexturevertex7; + + quadList[0] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex2, positiontexturevertex3, positiontexturevertex7, positiontexturevertex6}, textureOffsetU + zSize + xSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + xSize, textureOffsetV, modelRenderer.textureWidth, modelRenderer.textureHeight); + quadList[1] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex5, positiontexturevertex4, positiontexturevertex0, positiontexturevertex1}, textureOffsetU + zSize, textureOffsetV, textureOffsetU + zSize + xSize, textureOffsetV + zSize, modelRenderer.textureWidth, modelRenderer.textureHeight); + quadList[2] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex4, positiontexturevertex5, positiontexturevertex6, positiontexturevertex7}, textureOffsetU + zSize + xSize + zSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + zSize + xSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight); + quadList[3] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex1, positiontexturevertex0, positiontexturevertex3, positiontexturevertex2}, textureOffsetU + zSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight); + quadList[4] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex0, positiontexturevertex4, positiontexturevertex7, positiontexturevertex3}, textureOffsetU, textureOffsetV + zSize, textureOffsetU + zSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight); + quadList[5] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex5, positiontexturevertex1, positiontexturevertex2, positiontexturevertex6}, textureOffsetU + zSize + xSize, textureOffsetV + zSize, textureOffsetU + zSize + xSize + zSize, textureOffsetV + zSize + ySize, modelRenderer.textureWidth, modelRenderer.textureHeight); + + if(modelRenderer.mirror) + { + for(int quad = 0; quad < quadList.length; quad++) + { + quadList[quad].flipFace(); + } + } + } + + @SideOnly(Side.CLIENT) + public void render(Tessellator tessellator, boolean[] skippedFaces, float scaleFactor) + { + if(skippedFaces.length == quadList.length) + { + for(int i = 0; i < skippedFaces.length; ++i) + { + if(!skippedFaces[i]) + { + quadList[i].draw(tessellator, scaleFactor); + } + } + } + } } \ No newline at end of file diff --git a/common/mekanism/client/model/ModelChargepad.java b/common/mekanism/client/model/ModelChargepad.java index 418284224..9e449fd2e 100644 --- a/common/mekanism/client/model/ModelChargepad.java +++ b/common/mekanism/client/model/ModelChargepad.java @@ -15,7 +15,7 @@ public class ModelChargepad extends ModelBase ModelRenderer Shape4; ModelRenderer Shape5; - public ModelChargepad() + public ModelChargepad() { textureWidth = 64; textureHeight = 64; @@ -61,7 +61,7 @@ public class ModelChargepad extends ModelBase Shape5.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/client/model/ModelChemicalCrystalizer.java b/common/mekanism/client/model/ModelChemicalCrystalizer.java index 65b165ee3..a93d272ee 100644 --- a/common/mekanism/client/model/ModelChemicalCrystalizer.java +++ b/common/mekanism/client/model/ModelChemicalCrystalizer.java @@ -44,12 +44,12 @@ public class ModelChemicalCrystalizer extends ModelBase ModelRenderer Vial2; ModelRenderer Vial3; ModelRenderer Vial4; - + public ModelChemicalCrystalizer() { textureWidth = 128; textureHeight = 64; - + Base = new ModelRenderer(this, 16, 0); Base.addBox(0F, 0F, 0F, 14, 1, 14); Base.setRotationPoint(-7F, 23F, -7F); @@ -261,11 +261,11 @@ public class ModelChemicalCrystalizer extends ModelBase Vial4.mirror = true; setRotation(Vial4, 0F, 0F, 0F); } - + public void render(float size) { MekanismRenderer.blendOn(); - + Base.render(size); IO1.render(size); IO2.render(size); @@ -301,23 +301,23 @@ public class ModelChemicalCrystalizer extends ModelBase Vial2.render(size); Vial3.render(size); Vial4.render(size); - + MekanismRenderer.blendOff(); } - + public void renderWithRotation(float size, float rotate) { rotate *= Math.PI; - + Spin.rotateAngleY = rotate; Vial1.rotateAngleY = rotate; Vial2.rotateAngleY = rotate; Vial3.rotateAngleY = rotate; Vial4.rotateAngleY = rotate; - + render(size); } - + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; diff --git a/common/mekanism/client/model/ModelChemicalDissolutionChamber.java b/common/mekanism/client/model/ModelChemicalDissolutionChamber.java index 4972bd6d3..470ae4726 100644 --- a/common/mekanism/client/model/ModelChemicalDissolutionChamber.java +++ b/common/mekanism/client/model/ModelChemicalDissolutionChamber.java @@ -44,12 +44,12 @@ public class ModelChemicalDissolutionChamber extends ModelBase ModelRenderer Coil2; ModelRenderer Coil3; ModelRenderer Coil4; - + public ModelChemicalDissolutionChamber() { textureWidth = 128; textureHeight = 64; - + Centre = new ModelRenderer(this, 0, 17); Centre.addBox(0F, 0F, 0F, 2, 13, 2); Centre.setRotationPoint(-1F, 9F, -1F); @@ -261,11 +261,11 @@ public class ModelChemicalDissolutionChamber extends ModelBase Coil4.mirror = true; setRotation(Coil4, 0F, 0F, 0F); } - + public void render(float size) { MekanismRenderer.blendOn(); - + Centre.render(size); Base.render(size); Base2.render(size); @@ -301,10 +301,10 @@ public class ModelChemicalDissolutionChamber extends ModelBase Coil2.render(size); Coil3.render(size); Coil4.render(size); - + MekanismRenderer.blendOff(); } - + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; diff --git a/common/mekanism/client/model/ModelChemicalInfuser.java b/common/mekanism/client/model/ModelChemicalInfuser.java index fbaeadb21..b7e2b8329 100644 --- a/common/mekanism/client/model/ModelChemicalInfuser.java +++ b/common/mekanism/client/model/ModelChemicalInfuser.java @@ -49,12 +49,12 @@ public class ModelChemicalInfuser extends ModelBase ModelRenderer RGlassR; ModelRenderer RGlassL; ModelRenderer LGlassR; - + public ModelChemicalInfuser() { textureWidth = 128; textureHeight = 128; - + Base = new ModelRenderer(this, 0, 0); Base.addBox(0F, 0F, 0F, 16, 1, 16); Base.setRotationPoint(-8F, 23F, -8F); @@ -278,7 +278,7 @@ public class ModelChemicalInfuser extends ModelBase LGlassR.mirror = true; setRotation(LGlassR, 0F, 0F, 0F); } - + public void render(float size) { Base.render(size); @@ -306,20 +306,20 @@ public class ModelChemicalInfuser extends ModelBase LTopW.render(size); FrontPanel.render(size); FrontConnection.render(size); - + GL11.glPushMatrix(); GL11.glScalef(0.999F, 0.999F, 0.999F); RightConnection.render(size); LeftConnection.render(size); GL11.glPopMatrix(); } - + public void renderGlass(float size) { GL11.glPushMatrix(); MekanismRenderer.blendOn(); GL11.glColor4f(1, 1, 1, 0.2F); - + LGlassT.render(size); RGlassT.render(size); LGlassS.render(size); @@ -330,12 +330,12 @@ public class ModelChemicalInfuser extends ModelBase RGlassR.render(size); RGlassL.render(size); LGlassR.render(size); - + MekanismRenderer.blendOff(); GL11.glColor4f(1, 1, 1, 1); GL11.glPopMatrix(); } - + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; diff --git a/common/mekanism/client/model/ModelChemicalOxidizer.java b/common/mekanism/client/model/ModelChemicalOxidizer.java index 9754aae29..b941e47ef 100644 --- a/common/mekanism/client/model/ModelChemicalOxidizer.java +++ b/common/mekanism/client/model/ModelChemicalOxidizer.java @@ -31,12 +31,12 @@ public class ModelChemicalOxidizer extends ModelBase ModelRenderer GlassW; ModelRenderer GlassE; ModelRenderer GlassU; - + public ModelChemicalOxidizer() { textureWidth = 128; textureHeight = 128; - + Base = new ModelRenderer(this, 0, 0); Base.addBox(0F, 0F, 0F, 16, 1, 16); Base.setRotationPoint(-8F, 23F, -8F); @@ -158,7 +158,7 @@ public class ModelChemicalOxidizer extends ModelBase GlassU.mirror = true; setRotation(GlassU, 0F, 0F, 0F); } - + public void render(float size) { Base.render(size); @@ -177,24 +177,24 @@ public class ModelChemicalOxidizer extends ModelBase Machine.render(size); Post.render(size); } - + public void renderGlass(float size) { GL11.glPushMatrix(); MekanismRenderer.blendOn(); GL11.glColor4f(1, 1, 1, 0.2F); - + GlassN.render(size); GlassS.render(size); GlassW.render(size); GlassE.render(size); GlassU.render(size); - + MekanismRenderer.blendOff(); GL11.glColor4f(1, 1, 1, 1); GL11.glPopMatrix(); } - + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; diff --git a/common/mekanism/client/model/ModelChemicalWasher.java b/common/mekanism/client/model/ModelChemicalWasher.java index a8950cbe9..36470106e 100644 --- a/common/mekanism/client/model/ModelChemicalWasher.java +++ b/common/mekanism/client/model/ModelChemicalWasher.java @@ -43,12 +43,12 @@ public class ModelChemicalWasher extends ModelBase ModelRenderer Can2T; ModelRenderer Can3T; ModelRenderer Can3B; - + public ModelChemicalWasher() { textureWidth = 128; textureHeight = 64; - + Base = new ModelRenderer(this, 16, 0); Base.addBox(0F, 0F, 0F, 14, 1, 14); Base.setRotationPoint(-7F, 23F, -7F); @@ -249,11 +249,11 @@ public class ModelChemicalWasher extends ModelBase Can3B.mirror = true; setRotation(Can3B, 0F, 0F, 0F); } - + public void render(float size) { MekanismRenderer.blendOn(); - + Base.render(size); Base2.render(size); IO1.render(size); @@ -287,10 +287,10 @@ public class ModelChemicalWasher extends ModelBase Can2T.render(size); Can3T.render(size); Can3B.render(size); - + MekanismRenderer.blendOff(); } - + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; diff --git a/common/mekanism/client/model/ModelDigitalMiner.java b/common/mekanism/client/model/ModelDigitalMiner.java index e423cb200..b54698b10 100644 --- a/common/mekanism/client/model/ModelDigitalMiner.java +++ b/common/mekanism/client/model/ModelDigitalMiner.java @@ -51,7 +51,7 @@ public class ModelDigitalMiner extends ModelBase { textureWidth = 256; textureHeight = 256; - + Base = new ModelRenderer(this, 0, 0); Base.addBox(0F, 0F, 0F, 18, 22, 20); Base.setRotationPoint(-8F, -8F, -10F); @@ -280,19 +280,19 @@ public class ModelDigitalMiner extends ModelBase { Base.render(size); Back.render(size); - + if(on) { MekanismRenderer.glowOn(); } - + Panel.render(size); - + if(on) { MekanismRenderer.glowOff(); } - + PanelStem.render(size); KeyboardStem.render(size); Keyboard.render(size); @@ -329,7 +329,7 @@ public class ModelDigitalMiner extends ModelBase Laser4.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/client/model/ModelElectricPump.java b/common/mekanism/client/model/ModelElectricPump.java index bd75d0bb9..8310cd79d 100644 --- a/common/mekanism/client/model/ModelElectricPump.java +++ b/common/mekanism/client/model/ModelElectricPump.java @@ -21,12 +21,12 @@ public class ModelElectricPump extends ModelBase ModelRenderer Ring2; ModelRenderer Plug; ModelRenderer Ring3; - + public ModelElectricPump() { textureWidth = 64; textureHeight = 64; - + PumpHead = new ModelRenderer(this, 33, 0); PumpHead.addBox(0F, 0F, 0F, 6, 3, 6); PumpHead.setRotationPoint(-3F, 19F, -3F); @@ -100,7 +100,7 @@ public class ModelElectricPump extends ModelBase Ring3.mirror = true; setRotation(Ring3, 0F, 0F, 0F); } - + public void render(float size) { PumpHead.render(size); @@ -116,7 +116,7 @@ public class ModelElectricPump extends ModelBase Plug.render(size); Ring3.render(size); } - + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; diff --git a/common/mekanism/client/model/ModelElectrolyticSeparator.java b/common/mekanism/client/model/ModelElectrolyticSeparator.java index a8256fa19..5eb466223 100644 --- a/common/mekanism/client/model/ModelElectrolyticSeparator.java +++ b/common/mekanism/client/model/ModelElectrolyticSeparator.java @@ -8,198 +8,198 @@ import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) public class ModelElectrolyticSeparator extends ModelBase { - ModelRenderer A; - ModelRenderer B; - ModelRenderer C; - ModelRenderer D; - ModelRenderer E; - ModelRenderer F; - ModelRenderer G; - ModelRenderer H; - ModelRenderer I; - ModelRenderer J; - ModelRenderer K; - ModelRenderer L; - ModelRenderer M; - ModelRenderer N; - ModelRenderer OUTPUT; - ModelRenderer P; - ModelRenderer Q; - ModelRenderer R; - ModelRenderer S; - ModelRenderer T; - ModelRenderer U; - ModelRenderer V; - - public ModelElectrolyticSeparator() - { - textureWidth = 128; - textureHeight = 128; - - A = new ModelRenderer(this, 0, 0); - A.addBox(-8F, 0F, -8F, 16, 1, 16); - A.setRotationPoint(0F, 23F, 0F); - A.setTextureSize(128, 128); - A.mirror = true; - setRotation(A, 0F, 0F, 0F); - B = new ModelRenderer(this, 85, 0); - B.addBox(-2F, 0F, -2F, 4, 10, 4); - B.setRotationPoint(4F, 12F, -4F); - B.setTextureSize(128, 128); - B.mirror = true; - setRotation(B, 0F, 1.570796F, 0F); - C = new ModelRenderer(this, 66, 0); - C.addBox(-2F, 0F, -2F, 4, 10, 4); - C.setRotationPoint(-4F, 12F, -4F); - C.setTextureSize(128, 128); - C.mirror = true; - setRotation(C, 0F, 1.570796F, 0F); - D = new ModelRenderer(this, 48, 19); - D.addBox(-1F, -1F, 0F, 2, 2, 6); - D.setRotationPoint(-2F, 18F, -4F); - D.setTextureSize(128, 128); - D.mirror = true; - setRotation(D, 0F, 1.570796F, 0F); - E = new ModelRenderer(this, 0, 19); - E.addBox(0F, 0F, -6F, 4, 15, 14); - E.setRotationPoint(0F, 8F, 8F); - E.setTextureSize(128, 128); - E.mirror = true; - setRotation(E, 0F, 1.570796F, 0F); - F = new ModelRenderer(this, 103, 0); - F.addBox(-3F, -1F, -1F, 6, 2, 2); - F.setRotationPoint(4F, 20F, 1F); - F.setTextureSize(128, 128); - F.mirror = true; - setRotation(F, 0F, 1.570796F, 0F); - G = new ModelRenderer(this, 103, 0); - G.addBox(-3F, 0F, 0F, 6, 2, 2); - G.setRotationPoint(-5F, 20F, 1F); - G.setTextureSize(128, 128); - G.mirror = true; - setRotation(G, 0F, 1.570796F, 0F); - H = new ModelRenderer(this, 0, 50); - H.addBox(-2F, 0F, 0F, 4, 12, 2); - H.setRotationPoint(-8F, 11F, 6F); - H.setTextureSize(128, 128); - H.mirror = true; - setRotation(H, 0F, 1.570796F, 0F); - I = new ModelRenderer(this, 41, 28); - I.addBox(0F, 0F, 0F, 6, 1, 6); - I.setRotationPoint(-7F, 22F, -7F); - I.setTextureSize(128, 128); - I.mirror = true; - setRotation(I, 0F, 0F, 0F); - J = new ModelRenderer(this, 41, 28); - J.addBox(0F, 0F, 0F, 6, 1, 6); - J.setRotationPoint(1F, 22F, -7F); - J.setTextureSize(128, 128); - J.mirror = true; - setRotation(J, 0F, 0F, 0F); - K = new ModelRenderer(this, 66, 16); - K.addBox(0F, 0F, 0F, 2, 1, 2); - K.setRotationPoint(-5F, 11F, -5F); - K.setTextureSize(128, 128); - K.mirror = true; - setRotation(K, 0F, 0F, 0F); - L = new ModelRenderer(this, 85, 15); - L.addBox(0F, 0F, 0F, 2, 2, 2); - L.setRotationPoint(3F, 10F, -5F); - L.setTextureSize(128, 128); - L.mirror = true; - setRotation(L, 0F, 0F, 0F); - M = new ModelRenderer(this, 66, 22); - M.addBox(-1F, 0F, -1F, 2, 2, 6); - M.setRotationPoint(-4F, 9F, -4F); - M.setTextureSize(128, 128); - M.mirror = true; - setRotation(M, 0F, 1.570796F, 0F); - N = new ModelRenderer(this, 66, 32); - N.addBox(-1F, -1F, -1F, 2, 6, 2); - N.setRotationPoint(0F, 12F, -4F); - N.setTextureSize(128, 128); - N.mirror = true; - setRotation(N, 0F, 0F, 0F); - OUTPUT = new ModelRenderer(this, 66, 42); - OUTPUT.addBox(-1F, -1F, -1F, 4, 2, 2); - OUTPUT.setRotationPoint(0F, 16F, -5F); - OUTPUT.setTextureSize(128, 128); - OUTPUT.mirror = true; - setRotation(OUTPUT, 0F, 1.570796F, 0F); - P = new ModelRenderer(this, 85, 21); - P.addBox(-1F, -1F, -1F, 2, 3, 2); - P.setRotationPoint(5F, 9F, -4F); - P.setTextureSize(128, 128); - P.mirror = true; - setRotation(P, 0F, 0F, 0.6457718F); - Q = new ModelRenderer(this, 0, 65); - Q.addBox(0F, 0F, -2F, 3, 11, 6); - Q.setRotationPoint(-8F, 12F, 0F); - Q.setTextureSize(128, 128); - Q.mirror = true; - setRotation(Q, 0F, 0F, 0F); - R = new ModelRenderer(this, 0, 65); - R.addBox(0F, 0F, -3F, 3, 11, 6); - R.setRotationPoint(8F, 12F, 1F); - R.setTextureSize(128, 128); - R.mirror = true; - setRotation(R, 0F, 3.141593F, 0F); - S = new ModelRenderer(this, 0, 84); - S.addBox(0F, 0F, 0F, 4, 1, 1); - S.setRotationPoint(2F, 16F, 3F); - S.setTextureSize(128, 128); - S.mirror = true; - setRotation(S, 0F, 0F, 0F); - T = new ModelRenderer(this, 0, 84); - T.addBox(0F, 0F, 0F, 4, 1, 1); - T.setRotationPoint(-6F, 16F, 3F); - T.setTextureSize(128, 128); - T.mirror = true; - setRotation(T, 0F, 0F, 0F); - U = new ModelRenderer(this, 0, 87); - U.addBox(0F, 0F, 0F, 4, 1, 1); - U.setRotationPoint(-6F, 18F, 3F); - U.setTextureSize(128, 128); - U.mirror = true; - setRotation(U, 0F, 0F, 0F); - V = new ModelRenderer(this, 0, 87); - V.addBox(0F, 0F, 0F, 4, 1, 1); - V.setRotationPoint(2F, 18F, 3F); - V.setTextureSize(128, 128); - V.mirror = true; - setRotation(V, 0F, 0F, 0F); - } - - public void render(float size) - { - A.render(size); - B.render(size); - C.render(size); - D.render(size); - E.render(size); - F.render(size); - G.render(size); - H.render(size); - I.render(size); - J.render(size); - K.render(size); - L.render(size); - M.render(size); - N.render(size); - OUTPUT.render(size); - P.render(size); - Q.render(size); - R.render(size); - S.render(size); - T.render(size); - U.render(size); - V.render(size); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + ModelRenderer A; + ModelRenderer B; + ModelRenderer C; + ModelRenderer D; + ModelRenderer E; + ModelRenderer F; + ModelRenderer G; + ModelRenderer H; + ModelRenderer I; + ModelRenderer J; + ModelRenderer K; + ModelRenderer L; + ModelRenderer M; + ModelRenderer N; + ModelRenderer OUTPUT; + ModelRenderer P; + ModelRenderer Q; + ModelRenderer R; + ModelRenderer S; + ModelRenderer T; + ModelRenderer U; + ModelRenderer V; + + public ModelElectrolyticSeparator() + { + textureWidth = 128; + textureHeight = 128; + + A = new ModelRenderer(this, 0, 0); + A.addBox(-8F, 0F, -8F, 16, 1, 16); + A.setRotationPoint(0F, 23F, 0F); + A.setTextureSize(128, 128); + A.mirror = true; + setRotation(A, 0F, 0F, 0F); + B = new ModelRenderer(this, 85, 0); + B.addBox(-2F, 0F, -2F, 4, 10, 4); + B.setRotationPoint(4F, 12F, -4F); + B.setTextureSize(128, 128); + B.mirror = true; + setRotation(B, 0F, 1.570796F, 0F); + C = new ModelRenderer(this, 66, 0); + C.addBox(-2F, 0F, -2F, 4, 10, 4); + C.setRotationPoint(-4F, 12F, -4F); + C.setTextureSize(128, 128); + C.mirror = true; + setRotation(C, 0F, 1.570796F, 0F); + D = new ModelRenderer(this, 48, 19); + D.addBox(-1F, -1F, 0F, 2, 2, 6); + D.setRotationPoint(-2F, 18F, -4F); + D.setTextureSize(128, 128); + D.mirror = true; + setRotation(D, 0F, 1.570796F, 0F); + E = new ModelRenderer(this, 0, 19); + E.addBox(0F, 0F, -6F, 4, 15, 14); + E.setRotationPoint(0F, 8F, 8F); + E.setTextureSize(128, 128); + E.mirror = true; + setRotation(E, 0F, 1.570796F, 0F); + F = new ModelRenderer(this, 103, 0); + F.addBox(-3F, -1F, -1F, 6, 2, 2); + F.setRotationPoint(4F, 20F, 1F); + F.setTextureSize(128, 128); + F.mirror = true; + setRotation(F, 0F, 1.570796F, 0F); + G = new ModelRenderer(this, 103, 0); + G.addBox(-3F, 0F, 0F, 6, 2, 2); + G.setRotationPoint(-5F, 20F, 1F); + G.setTextureSize(128, 128); + G.mirror = true; + setRotation(G, 0F, 1.570796F, 0F); + H = new ModelRenderer(this, 0, 50); + H.addBox(-2F, 0F, 0F, 4, 12, 2); + H.setRotationPoint(-8F, 11F, 6F); + H.setTextureSize(128, 128); + H.mirror = true; + setRotation(H, 0F, 1.570796F, 0F); + I = new ModelRenderer(this, 41, 28); + I.addBox(0F, 0F, 0F, 6, 1, 6); + I.setRotationPoint(-7F, 22F, -7F); + I.setTextureSize(128, 128); + I.mirror = true; + setRotation(I, 0F, 0F, 0F); + J = new ModelRenderer(this, 41, 28); + J.addBox(0F, 0F, 0F, 6, 1, 6); + J.setRotationPoint(1F, 22F, -7F); + J.setTextureSize(128, 128); + J.mirror = true; + setRotation(J, 0F, 0F, 0F); + K = new ModelRenderer(this, 66, 16); + K.addBox(0F, 0F, 0F, 2, 1, 2); + K.setRotationPoint(-5F, 11F, -5F); + K.setTextureSize(128, 128); + K.mirror = true; + setRotation(K, 0F, 0F, 0F); + L = new ModelRenderer(this, 85, 15); + L.addBox(0F, 0F, 0F, 2, 2, 2); + L.setRotationPoint(3F, 10F, -5F); + L.setTextureSize(128, 128); + L.mirror = true; + setRotation(L, 0F, 0F, 0F); + M = new ModelRenderer(this, 66, 22); + M.addBox(-1F, 0F, -1F, 2, 2, 6); + M.setRotationPoint(-4F, 9F, -4F); + M.setTextureSize(128, 128); + M.mirror = true; + setRotation(M, 0F, 1.570796F, 0F); + N = new ModelRenderer(this, 66, 32); + N.addBox(-1F, -1F, -1F, 2, 6, 2); + N.setRotationPoint(0F, 12F, -4F); + N.setTextureSize(128, 128); + N.mirror = true; + setRotation(N, 0F, 0F, 0F); + OUTPUT = new ModelRenderer(this, 66, 42); + OUTPUT.addBox(-1F, -1F, -1F, 4, 2, 2); + OUTPUT.setRotationPoint(0F, 16F, -5F); + OUTPUT.setTextureSize(128, 128); + OUTPUT.mirror = true; + setRotation(OUTPUT, 0F, 1.570796F, 0F); + P = new ModelRenderer(this, 85, 21); + P.addBox(-1F, -1F, -1F, 2, 3, 2); + P.setRotationPoint(5F, 9F, -4F); + P.setTextureSize(128, 128); + P.mirror = true; + setRotation(P, 0F, 0F, 0.6457718F); + Q = new ModelRenderer(this, 0, 65); + Q.addBox(0F, 0F, -2F, 3, 11, 6); + Q.setRotationPoint(-8F, 12F, 0F); + Q.setTextureSize(128, 128); + Q.mirror = true; + setRotation(Q, 0F, 0F, 0F); + R = new ModelRenderer(this, 0, 65); + R.addBox(0F, 0F, -3F, 3, 11, 6); + R.setRotationPoint(8F, 12F, 1F); + R.setTextureSize(128, 128); + R.mirror = true; + setRotation(R, 0F, 3.141593F, 0F); + S = new ModelRenderer(this, 0, 84); + S.addBox(0F, 0F, 0F, 4, 1, 1); + S.setRotationPoint(2F, 16F, 3F); + S.setTextureSize(128, 128); + S.mirror = true; + setRotation(S, 0F, 0F, 0F); + T = new ModelRenderer(this, 0, 84); + T.addBox(0F, 0F, 0F, 4, 1, 1); + T.setRotationPoint(-6F, 16F, 3F); + T.setTextureSize(128, 128); + T.mirror = true; + setRotation(T, 0F, 0F, 0F); + U = new ModelRenderer(this, 0, 87); + U.addBox(0F, 0F, 0F, 4, 1, 1); + U.setRotationPoint(-6F, 18F, 3F); + U.setTextureSize(128, 128); + U.mirror = true; + setRotation(U, 0F, 0F, 0F); + V = new ModelRenderer(this, 0, 87); + V.addBox(0F, 0F, 0F, 4, 1, 1); + V.setRotationPoint(2F, 18F, 3F); + V.setTextureSize(128, 128); + V.mirror = true; + setRotation(V, 0F, 0F, 0F); + } + + public void render(float size) + { + A.render(size); + B.render(size); + C.render(size); + D.render(size); + E.render(size); + F.render(size); + G.render(size); + H.render(size); + I.render(size); + J.render(size); + K.render(size); + L.render(size); + M.render(size); + N.render(size); + OUTPUT.render(size); + P.render(size); + Q.render(size); + R.render(size); + S.render(size); + T.render(size); + U.render(size); + V.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/common/mekanism/client/model/ModelEnergyCube.java b/common/mekanism/client/model/ModelEnergyCube.java index b095ada0a..aa7c9b343 100644 --- a/common/mekanism/client/model/ModelEnergyCube.java +++ b/common/mekanism/client/model/ModelEnergyCube.java @@ -7,7 +7,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelEnergyCube extends ModelBase +public class ModelEnergyCube extends ModelBase { ModelRenderer Corner1; ModelRenderer Corner2; @@ -176,7 +176,7 @@ public class ModelEnergyCube extends ModelBase Corner7.render(size); Corner8.render(size); MekanismRenderer.glowOff(); - + Frame4.render(size); Frame3.render(size); Frame2.render(size); @@ -192,22 +192,22 @@ public class ModelEnergyCube extends ModelBase HoriPole8.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } - + public static class ModelEnergyCore extends ModelBase { private ModelRenderer cube; - public ModelEnergyCore() + public ModelEnergyCore() { textureWidth = 32; textureHeight = 32; - + cube = new ModelRenderer(this, 0, 0); cube.addBox(-8, -8, -8, 16, 16, 16); cube.setTextureSize(32, 32); diff --git a/common/mekanism/client/model/ModelFreeRunners.java b/common/mekanism/client/model/ModelFreeRunners.java index 2a3bdc320..4fff69ecc 100644 --- a/common/mekanism/client/model/ModelFreeRunners.java +++ b/common/mekanism/client/model/ModelFreeRunners.java @@ -67,14 +67,14 @@ public class ModelFreeRunners extends ModelBase SupportL.render(size); SupportR.render(size); } - + public void renderLeft(float size) { SpringL.render(size); BraceL.render(size); SupportL.render(size); } - + public void renderRight(float size) { SpringR.render(size); diff --git a/common/mekanism/client/model/ModelGasMask.java b/common/mekanism/client/model/ModelGasMask.java index 4d0dd9aca..469a43070 100644 --- a/common/mekanism/client/model/ModelGasMask.java +++ b/common/mekanism/client/model/ModelGasMask.java @@ -12,40 +12,40 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelGasMask extends ModelBase { - ModelRenderer helmetfeed; - ModelRenderer tubeback; - ModelRenderer tubeL; - ModelRenderer tubeR; - ModelRenderer tubefront; - ModelRenderer mouthintake; - ModelRenderer finupperR; - ModelRenderer finupperL; - ModelRenderer finmidR; - ModelRenderer finmidL; - ModelRenderer finback; - ModelRenderer topplate; - ModelRenderer filterL; - ModelRenderer filterR; - ModelRenderer filterpipelower; - ModelRenderer filterpipeupper; - ModelRenderer glasstop; - ModelRenderer glassfront; - ModelRenderer glassR; - ModelRenderer glassL; - ModelRenderer glassbackR; - ModelRenderer glassbackL; - ModelRenderer pipecornerFL; - ModelRenderer pipecornerFR; - ModelRenderer pipecornerBR; - ModelRenderer pipecornerBL; - ModelRenderer lightL; - ModelRenderer lightR; + ModelRenderer helmetfeed; + ModelRenderer tubeback; + ModelRenderer tubeL; + ModelRenderer tubeR; + ModelRenderer tubefront; + ModelRenderer mouthintake; + ModelRenderer finupperR; + ModelRenderer finupperL; + ModelRenderer finmidR; + ModelRenderer finmidL; + ModelRenderer finback; + ModelRenderer topplate; + ModelRenderer filterL; + ModelRenderer filterR; + ModelRenderer filterpipelower; + ModelRenderer filterpipeupper; + ModelRenderer glasstop; + ModelRenderer glassfront; + ModelRenderer glassR; + ModelRenderer glassL; + ModelRenderer glassbackR; + ModelRenderer glassbackL; + ModelRenderer pipecornerFL; + ModelRenderer pipecornerFR; + ModelRenderer pipecornerBR; + ModelRenderer pipecornerBL; + ModelRenderer lightL; + ModelRenderer lightR; public ModelGasMask() { - textureWidth = 128; - textureHeight = 64; - + textureWidth = 128; + textureHeight = 64; + helmetfeed = new ModelRenderer(this, 88, 43); helmetfeed.addBox(-2F, -2F, 2F, 4, 3, 4); helmetfeed.setRotationPoint(0F, 0F, 0F); @@ -221,44 +221,44 @@ public class ModelGasMask extends ModelBase public void render(float size) { - helmetfeed.render(size); - tubeback.render(size); - tubeL.render(size); - tubeR.render(size); - tubefront.render(size); - mouthintake.render(size); - finupperR.render(size); - finupperL.render(size); - finmidR.render(size); - finmidL.render(size); - finback.render(size); - topplate.render(size); - filterL.render(size); - filterR.render(size); - filterpipelower.render(size); - filterpipeupper.render(size); - + helmetfeed.render(size); + tubeback.render(size); + tubeL.render(size); + tubeR.render(size); + tubefront.render(size); + mouthintake.render(size); + finupperR.render(size); + finupperL.render(size); + finmidR.render(size); + finmidL.render(size); + finback.render(size); + topplate.render(size); + filterL.render(size); + filterR.render(size); + filterpipelower.render(size); + filterpipeupper.render(size); + MekanismRenderer.blendOn(); MekanismRenderer.glowOn(); GL11.glColor4f(1, 1, 1, 0.3F); GL11.glEnable(GL11.GL_CULL_FACE); - - glasstop.render(size); - glassfront.render(size); - glassR.render(size); - glassL.render(size); - glassbackR.render(size); - glassbackL.render(size); - - GL11.glDisable(GL11.GL_CULL_FACE); + + glasstop.render(size); + glassfront.render(size); + glassR.render(size); + glassL.render(size); + glassbackR.render(size); + glassbackL.render(size); + + GL11.glDisable(GL11.GL_CULL_FACE); GL11.glColor4f(1, 1, 1, 1); MekanismRenderer.glowOff(); MekanismRenderer.blendOff(); - - pipecornerFL.render(size); - pipecornerFR.render(size); - pipecornerBR.render(size); - pipecornerBL.render(size); + + pipecornerFL.render(size); + pipecornerFR.render(size); + pipecornerBR.render(size); + pipecornerBL.render(size); MekanismRenderer.glowOn(); lightL.render(size); diff --git a/common/mekanism/client/model/ModelGasTank.java b/common/mekanism/client/model/ModelGasTank.java index cdd2280d4..3ba2dd4fc 100644 --- a/common/mekanism/client/model/ModelGasTank.java +++ b/common/mekanism/client/model/ModelGasTank.java @@ -7,7 +7,7 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; @SideOnly(Side.CLIENT) -public class ModelGasTank extends ModelBase +public class ModelGasTank extends ModelBase { ModelRenderer Panel1; ModelRenderer Panel2; @@ -77,7 +77,7 @@ public class ModelGasTank extends ModelBase Exit.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/client/model/ModelJetpack.java b/common/mekanism/client/model/ModelJetpack.java index e74bd91ba..19d31a719 100644 --- a/common/mekanism/client/model/ModelJetpack.java +++ b/common/mekanism/client/model/ModelJetpack.java @@ -30,9 +30,9 @@ public class ModelJetpack extends ModelBase ModelRenderer Packdoodad2; ModelRenderer Packdoodad3; ModelRenderer Bottomthruster; - ModelRenderer light1; - ModelRenderer light2; - ModelRenderer light3; + ModelRenderer light1; + ModelRenderer light2; + ModelRenderer light3; public ModelJetpack() { @@ -176,36 +176,36 @@ public class ModelJetpack extends ModelBase Fueltuberight.render(size); Fueltubeleft.render(size); Packmid.render(size); - + MekanismRenderer.glowOn(); Packcore.render(size); MekanismRenderer.glowOff(); - + WingsupportL.render(size); WingsupportR.render(size); Packtoprear.render(size); ExtendosupportL.render(size); ExtendosupportR.render(size); - + GL11.glPushMatrix(); MekanismRenderer.blendOn(); MekanismRenderer.glowOn(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glColor4f(1, 1, 1, 0.2F); - + WingbladeL.render(size); WingbladeR.render(size); - + GL11.glColor4f(1, 1, 1, 1); GL11.glDisable(GL11.GL_CULL_FACE); MekanismRenderer.glowOff(); MekanismRenderer.blendOff(); GL11.glPopMatrix(); - + Packdoodad2.render(size); Packdoodad3.render(size); Bottomthruster.render(size); - + MekanismRenderer.glowOn(); light1.render(size); light2.render(size); diff --git a/common/mekanism/client/model/ModelLogisticalSorter.java b/common/mekanism/client/model/ModelLogisticalSorter.java index d1ee06ce0..59d332279 100644 --- a/common/mekanism/client/model/ModelLogisticalSorter.java +++ b/common/mekanism/client/model/ModelLogisticalSorter.java @@ -8,7 +8,7 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; @SideOnly(Side.CLIENT) -public class ModelLogisticalSorter extends ModelBase +public class ModelLogisticalSorter extends ModelBase { ModelRenderer LeftThing; ModelRenderer RightThing; @@ -164,7 +164,7 @@ public class ModelLogisticalSorter extends ModelBase DecorPlate.mirror = true; setRotation(DecorPlate, 0F, 0F, 0F); } - + public void render(float size, boolean active) { LeftThing.render(size); @@ -173,12 +173,12 @@ public class ModelLogisticalSorter extends ModelBase TopPlate.render(size); LeftPlate.render(size); RightPlate.render(size); - + if(active) { MekanismRenderer.glowOn(); } - + BR1Block1.render(size); BL1Block1.render(size); TL1Block1.render(size); @@ -187,12 +187,12 @@ public class ModelLogisticalSorter extends ModelBase BL1Block2.render(size); TL1Block2.render(size); TR1Block2.render(size); - + if(active) { MekanismRenderer.glowOff(); } - + PoleBR.render(size); PoleTL.render(size); PoleTR.render(size); @@ -202,7 +202,7 @@ public class ModelLogisticalSorter extends ModelBase DecorPlate.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/client/model/ModelMetallurgicInfuser.java b/common/mekanism/client/model/ModelMetallurgicInfuser.java index 2ed8d2a0f..058015dda 100644 --- a/common/mekanism/client/model/ModelMetallurgicInfuser.java +++ b/common/mekanism/client/model/ModelMetallurgicInfuser.java @@ -6,7 +6,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelMetallurgicInfuser extends ModelBase +public class ModelMetallurgicInfuser extends ModelBase { ModelRenderer Base; ModelRenderer RightChamber; @@ -34,7 +34,7 @@ public class ModelMetallurgicInfuser extends ModelBase ModelRenderer ConnectorWireLeft; ModelRenderer ConnectorWireTop; - public ModelMetallurgicInfuser() + public ModelMetallurgicInfuser() { textureWidth = 128; textureHeight = 64; @@ -220,7 +220,7 @@ public class ModelMetallurgicInfuser extends ModelBase ConnectorWireTop.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/client/model/ModelObsidianTNT.java b/common/mekanism/client/model/ModelObsidianTNT.java index 9ae809592..a244091f9 100644 --- a/common/mekanism/client/model/ModelObsidianTNT.java +++ b/common/mekanism/client/model/ModelObsidianTNT.java @@ -181,7 +181,7 @@ public class ModelObsidianTNT extends ModelBase Rod9.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/client/model/ModelRendererSelectiveFace.java b/common/mekanism/client/model/ModelRendererSelectiveFace.java index 84eb57f7c..95ad8325e 100644 --- a/common/mekanism/client/model/ModelRendererSelectiveFace.java +++ b/common/mekanism/client/model/ModelRendererSelectiveFace.java @@ -18,152 +18,152 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class ModelRendererSelectiveFace { - public float textureWidth; - public float textureHeight; - - public float offsetX; - public float offsetY; - public float offsetZ; - - public float rotationPointX; - public float rotationPointY; - public float rotationPointZ; - - public float rotateAngleX; - public float rotateAngleY; - public float rotateAngleZ; - - public boolean mirror; - public boolean showModel; - public boolean isHidden; - - public List cubeList = new ArrayList(); - - private int textureOffsetX; - private int textureOffsetY; - - private ModelBase baseModel; - - private Map displayLists = new HashMap(); - + public float textureWidth; + public float textureHeight; - public ModelRendererSelectiveFace(ModelBase modelBase) - { - textureWidth = 64.0F; - textureHeight = 32.0F; - showModel = true; - baseModel = modelBase; - - setTextureSize(modelBase.textureWidth, modelBase.textureHeight); - } + public float offsetX; + public float offsetY; + public float offsetZ; - public ModelRendererSelectiveFace(ModelBase modelBase, int offsetX, int offsetY) - { - this(modelBase); - setTextureOffset(offsetX, offsetY); - } + public float rotationPointX; + public float rotationPointY; + public float rotationPointZ; - public ModelRendererSelectiveFace setTextureOffset(int offsetX, int offsetY) - { - textureOffsetX = offsetX; - textureOffsetY = offsetY; - - return this; - } + public float rotateAngleX; + public float rotateAngleY; + public float rotateAngleZ; - public ModelRendererSelectiveFace addBox(float minX, float minY, float minZ, int sizeX, int sizeY, int sizeZ) - { - cubeList.add(new ModelBoxSelectiveFace(this, textureOffsetX, textureOffsetY, minX, minY, minZ, sizeX, sizeY, sizeZ, 0.0F)); - return this; - } + public boolean mirror; + public boolean showModel; + public boolean isHidden; - public void setRotationPoint(float pointX, float pointY, float pointZ) - { - rotationPointX = pointX; - rotationPointY = pointY; - rotationPointZ = pointZ; - } - - @SideOnly(Side.CLIENT) - public void render(boolean[] dontRender, float scaleFactor) - { - if(!isHidden) - { - if(showModel) - { - DisplayInteger currentDisplayList = displayLists.get(new BooleanArray(dontRender)); - - if(currentDisplayList == null) - { - currentDisplayList = compileDisplayList(dontRender, scaleFactor); - } + public List cubeList = new ArrayList(); - GL11.glTranslatef(offsetX, offsetY, offsetZ); - - int i; + private int textureOffsetX; + private int textureOffsetY; - if(rotateAngleX == 0.0F && rotateAngleY == 0.0F && rotateAngleZ == 0.0F) - { - if(rotationPointX == 0.0F && rotationPointY == 0.0F && rotationPointZ == 0.0F) - { - currentDisplayList.render(); - } - else { - GL11.glTranslatef(rotationPointX * scaleFactor, rotationPointY * scaleFactor, rotationPointZ * scaleFactor); - currentDisplayList.render(); - GL11.glTranslatef(-rotationPointX * scaleFactor, -rotationPointY * scaleFactor, -rotationPointZ * scaleFactor); - } - } - else { - GL11.glPushMatrix(); - GL11.glTranslatef(rotationPointX * scaleFactor, rotationPointY * scaleFactor, rotationPointZ * scaleFactor); + private ModelBase baseModel; - if(rotateAngleZ != 0.0F) - { - GL11.glRotatef(rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); - } + private Map displayLists = new HashMap(); - if(rotateAngleY != 0.0F) - { - GL11.glRotatef(rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); - } - if(rotateAngleX != 0.0F) - { - GL11.glRotatef(rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); - } + public ModelRendererSelectiveFace(ModelBase modelBase) + { + textureWidth = 64.0F; + textureHeight = 32.0F; + showModel = true; + baseModel = modelBase; - currentDisplayList.render(); - GL11.glPopMatrix(); - } + setTextureSize(modelBase.textureWidth, modelBase.textureHeight); + } - GL11.glTranslatef(-offsetX, -offsetY, -offsetZ); - } - } - } + public ModelRendererSelectiveFace(ModelBase modelBase, int offsetX, int offsetY) + { + this(modelBase); + setTextureOffset(offsetX, offsetY); + } - @SideOnly(Side.CLIENT) - private DisplayInteger compileDisplayList(boolean[] dontRender, float scaleFactor) - { - DisplayInteger displayList = DisplayInteger.createAndStart(); - Tessellator tessellator = Tessellator.instance; + public ModelRendererSelectiveFace setTextureOffset(int offsetX, int offsetY) + { + textureOffsetX = offsetX; + textureOffsetY = offsetY; - for(int i = 0; i < cubeList.size(); ++i) - { - cubeList.get(i).render(tessellator, dontRender, scaleFactor); - } + return this; + } - displayList.endList(); - displayLists.put(new BooleanArray(dontRender), displayList); - - return displayList; - } + public ModelRendererSelectiveFace addBox(float minX, float minY, float minZ, int sizeX, int sizeY, int sizeZ) + { + cubeList.add(new ModelBoxSelectiveFace(this, textureOffsetX, textureOffsetY, minX, minY, minZ, sizeX, sizeY, sizeZ, 0.0F)); + return this; + } - public ModelRendererSelectiveFace setTextureSize(int sizeX, int sizeY) - { - textureWidth = sizeX; - textureHeight = sizeY; - - return this; - } + public void setRotationPoint(float pointX, float pointY, float pointZ) + { + rotationPointX = pointX; + rotationPointY = pointY; + rotationPointZ = pointZ; + } + + @SideOnly(Side.CLIENT) + public void render(boolean[] dontRender, float scaleFactor) + { + if(!isHidden) + { + if(showModel) + { + DisplayInteger currentDisplayList = displayLists.get(new BooleanArray(dontRender)); + + if(currentDisplayList == null) + { + currentDisplayList = compileDisplayList(dontRender, scaleFactor); + } + + GL11.glTranslatef(offsetX, offsetY, offsetZ); + + int i; + + if(rotateAngleX == 0.0F && rotateAngleY == 0.0F && rotateAngleZ == 0.0F) + { + if(rotationPointX == 0.0F && rotationPointY == 0.0F && rotationPointZ == 0.0F) + { + currentDisplayList.render(); + } + else { + GL11.glTranslatef(rotationPointX * scaleFactor, rotationPointY * scaleFactor, rotationPointZ * scaleFactor); + currentDisplayList.render(); + GL11.glTranslatef(-rotationPointX * scaleFactor, -rotationPointY * scaleFactor, -rotationPointZ * scaleFactor); + } + } + else { + GL11.glPushMatrix(); + GL11.glTranslatef(rotationPointX * scaleFactor, rotationPointY * scaleFactor, rotationPointZ * scaleFactor); + + if(rotateAngleZ != 0.0F) + { + GL11.glRotatef(rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + } + + if(rotateAngleY != 0.0F) + { + GL11.glRotatef(rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + if(rotateAngleX != 0.0F) + { + GL11.glRotatef(rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + + currentDisplayList.render(); + GL11.glPopMatrix(); + } + + GL11.glTranslatef(-offsetX, -offsetY, -offsetZ); + } + } + } + + @SideOnly(Side.CLIENT) + private DisplayInteger compileDisplayList(boolean[] dontRender, float scaleFactor) + { + DisplayInteger displayList = DisplayInteger.createAndStart(); + Tessellator tessellator = Tessellator.instance; + + for(int i = 0; i < cubeList.size(); ++i) + { + cubeList.get(i).render(tessellator, dontRender, scaleFactor); + } + + displayList.endList(); + displayLists.put(new BooleanArray(dontRender), displayList); + + return displayList; + } + + public ModelRendererSelectiveFace setTextureSize(int sizeX, int sizeY) + { + textureWidth = sizeX; + textureHeight = sizeY; + + return this; + } } diff --git a/common/mekanism/client/model/ModelRobit.java b/common/mekanism/client/model/ModelRobit.java index d694fb6d4..69cb9dd11 100644 --- a/common/mekanism/client/model/ModelRobit.java +++ b/common/mekanism/client/model/ModelRobit.java @@ -10,7 +10,7 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; @SideOnly(Side.CLIENT) -public class ModelRobit extends ModelBase +public class ModelRobit extends ModelBase { public ModelRenderer Body; public ModelRenderer Bottom; @@ -24,11 +24,11 @@ public class ModelRobit extends ModelBase public ModelRenderer leftarm; public ModelRenderer righthand; public ModelRenderer lefthand; - public ModelRenderer backLight; - public ModelRenderer eyeRight; - public ModelRenderer eyeLeft; + public ModelRenderer backLight; + public ModelRenderer eyeRight; + public ModelRenderer eyeLeft; - public ModelRobit() + public ModelRobit() { textureWidth = 64; textureHeight = 64; @@ -121,61 +121,61 @@ public class ModelRobit extends ModelBase eyeLeft.addBox(0F, 0F, 0F, 1, 1, 1); eyeLeft.setRotationPoint(-2.5F, 14.5F, 1.50001F); eyeLeft.setTextureSize(64, 64); - eyeLeft.mirror = true; - setRotation(eyeLeft, 0F, 0F, 0F); + eyeLeft.mirror = true; + setRotation(eyeLeft, 0F, 0F, 0F); } - - @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); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); - - GL11.glPushMatrix(); - GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); - - Body.render(f5); - Bottom.render(f5); - RightTrack.render(f5); - LeftTrack.render(f5); - Neck.render(f5); - Head.render(f5); - Backpack.render(f5); - headback.render(f5); - rightarn.render(f5); - leftarm.render(f5); - righthand.render(f5); - lefthand.render(f5); - - MekanismRenderer.glowOn(); - backLight.render(f5); - eyeRight.render(f5); - eyeLeft.render(f5); - MekanismRenderer.glowOff(); - - GL11.glPopMatrix(); - } - - public void render(float size) - { - Body.render(size); - Bottom.render(size); - RightTrack.render(size); - LeftTrack.render(size); - Neck.render(size); - Head.render(size); - Backpack.render(size); - headback.render(size); - rightarn.render(size); - leftarm.render(size); - righthand.render(size); - lefthand.render(size); - backLight.render(size); - eyeRight.render(size); - eyeLeft.render(size); - } - private void setRotation(ModelRenderer model, float x, float y, float z) + @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); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); + + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + + Body.render(f5); + Bottom.render(f5); + RightTrack.render(f5); + LeftTrack.render(f5); + Neck.render(f5); + Head.render(f5); + Backpack.render(f5); + headback.render(f5); + rightarn.render(f5); + leftarm.render(f5); + righthand.render(f5); + lefthand.render(f5); + + MekanismRenderer.glowOn(); + backLight.render(f5); + eyeRight.render(f5); + eyeLeft.render(f5); + MekanismRenderer.glowOff(); + + GL11.glPopMatrix(); + } + + public void render(float size) + { + Body.render(size); + Bottom.render(size); + RightTrack.render(size); + LeftTrack.render(size); + Neck.render(size); + Head.render(size); + Backpack.render(size); + headback.render(size); + rightarn.render(size); + leftarm.render(size); + righthand.render(size); + lefthand.render(size); + backLight.render(size); + eyeRight.render(size); + eyeLeft.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/client/model/ModelTransporterBox.java b/common/mekanism/client/model/ModelTransporterBox.java index 91c7d8402..9d756e558 100644 --- a/common/mekanism/client/model/ModelTransporterBox.java +++ b/common/mekanism/client/model/ModelTransporterBox.java @@ -9,12 +9,12 @@ import cpw.mods.fml.relauncher.SideOnly; public class ModelTransporterBox extends ModelBase { ModelRenderer box; - + public ModelTransporterBox() { textureWidth = 64; textureHeight = 64; - + box = new ModelRenderer(this, 0, 0); box.addBox(0F, 0F, 0F, 7, 7, 7); box.setRotationPoint(-3.5F, 0, -3.5F); @@ -22,13 +22,13 @@ public class ModelTransporterBox extends ModelBase box.mirror = true; setRotation(box, 0F, 0F, 0F); } - + public void render(float size) { box.render(size); } - - private void setRotation(ModelRenderer model, float x, float y, float z) + + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/client/nei/AdvancedMachineRecipeHandler.java b/common/mekanism/client/nei/AdvancedMachineRecipeHandler.java index 5446e1756..a610f640b 100644 --- a/common/mekanism/client/nei/AdvancedMachineRecipeHandler.java +++ b/common/mekanism/client/nei/AdvancedMachineRecipeHandler.java @@ -34,7 +34,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler public abstract String getRecipeId(); public abstract Set> getRecipes(); - + public abstract List getFuelStacks(Gas gasType); @Override @@ -49,10 +49,10 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - + float f = ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0; drawProgressBar(63, 34, 176, 0, 24, 7, f, 0); - + if(recipe.input.gasType != null) { int displayInt = ticksPassed < 20 ? ticksPassed*12 / 20 : 12; @@ -99,7 +99,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler } } } - + @Override public void loadUsageRecipes(String inputId, Object... ingredients) { @@ -129,21 +129,21 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler } } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); Point offset = gui.getRecipePosition(recipe); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; - + if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).input.gasType.getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } @@ -152,17 +152,17 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { Point point = GuiDraw.getMousePosition(); Point offset = gui.getRecipePosition(recipe); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; - + GasStack stack = null; - + if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) { stack = new GasStack(((CachedIORecipe)arecipes.get(recipe)).input.gasType, 1); } - + if(stack != null) { if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) @@ -180,26 +180,26 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); Point offset = gui.getRecipePosition(recipe); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; - + GasStack stack = null; - + if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) { stack = new GasStack(((CachedIORecipe)arecipes.get(recipe)).input.gasType, 1); } - + if(stack != null) { if(button == 0) @@ -217,16 +217,16 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { public List fuelStacks; - + public AdvancedInput input; - + public PositionedStack outputStack; @Override @@ -240,7 +240,7 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { return outputStack; } - + @Override public PositionedStack getOtherStack() { diff --git a/common/mekanism/client/nei/BaseRecipeHandler.java b/common/mekanism/client/nei/BaseRecipeHandler.java index 8c291b983..0fe6c06d3 100644 --- a/common/mekanism/client/nei/BaseRecipeHandler.java +++ b/common/mekanism/client/nei/BaseRecipeHandler.java @@ -14,29 +14,29 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler { public void displayGauge(int length, int xPos, int yPos, int overlayX, int overlayY, int scale, FluidStack fluid, GasStack gas) { - if(fluid == null && gas == null) - { - return; - } - + if(fluid == null && gas == null) + { + return; + } + int start = 0; while(true) { int renderRemaining = 0; - if(scale > 16) + if(scale > 16) { renderRemaining = 16; scale -= 16; - } + } else { renderRemaining = scale; scale = 0; } changeTexture(MekanismRenderer.getBlocksTexture()); - + if(fluid != null) { gui.drawTexturedModelRectFromIcon(xPos, yPos + length - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); @@ -45,7 +45,7 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler { gui.drawTexturedModelRectFromIcon(xPos, yPos + length - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); } - + start+=16; if(renderRemaining == 0 || scale == 0) @@ -57,7 +57,7 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler changeTexture(getGuiTexture()); drawTexturedModalRect(xPos, yPos, overlayX, overlayY, 16, length+1); } - + /* * true = usage, false = recipe */ @@ -78,24 +78,24 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler return false; } } - + return true; } - + return false; } - + public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) { - if(gas == null) - { - return; - } - + if(gas == null) + { + return; + } + changeTexture(MekanismRenderer.getBlocksTexture()); gui.drawTexturedModelRectFromIcon(xPos, yPos, gas.getGas().getIcon(), sizeX, sizeY); } - + /* * true = usage, false = recipe */ @@ -116,10 +116,10 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler return false; } } - + return true; } - + return false; } } diff --git a/common/mekanism/client/nei/ChanceMachineRecipeHandler.java b/common/mekanism/client/nei/ChanceMachineRecipeHandler.java index cba646af0..d6303f3e3 100644 --- a/common/mekanism/client/nei/ChanceMachineRecipeHandler.java +++ b/common/mekanism/client/nei/ChanceMachineRecipeHandler.java @@ -25,7 +25,7 @@ public abstract class ChanceMachineRecipeHandler extends TemplateRecipeHandler public abstract String getRecipeId(); public abstract Set> getRecipes(); - + @Override public void drawBackground(int i) { @@ -38,12 +38,12 @@ public abstract class ChanceMachineRecipeHandler extends TemplateRecipeHandler public void drawExtras(int i) { CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - + float f = ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; drawProgressBar(63, 34, 176, 0, 24, 7, f, 0); f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; drawProgressBar(149, 12, 176, 7, 4, 52, f, 3); - + if(recipe.output.hasSecondary()) { drawString(Math.round(recipe.output.secondaryChance*100) + "%", 116, 52, 0x404040, false); @@ -124,10 +124,10 @@ public abstract class ChanceMachineRecipeHandler extends TemplateRecipeHandler { return new PositionedStack(output.primaryOutput, 100, 30); } - + return null; } - + @Override public PositionedStack getOtherStack() { @@ -135,7 +135,7 @@ public abstract class ChanceMachineRecipeHandler extends TemplateRecipeHandler { return new PositionedStack(output.secondaryOutput, 116, 30); } - + return null; } diff --git a/common/mekanism/client/nei/ChemicalCrystalizerRecipeHandler.java b/common/mekanism/client/nei/ChemicalCrystalizerRecipeHandler.java index 764b3b0b2..9261183a3 100644 --- a/common/mekanism/client/nei/ChemicalCrystalizerRecipeHandler.java +++ b/common/mekanism/client/nei/ChemicalCrystalizerRecipeHandler.java @@ -34,28 +34,28 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class ChemicalCrystalizerRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + public static int xOffset = 5; public static int yOffset = 3; - + @Override public String getRecipeName() { return MekanismUtils.localize("tile.MachineBlock2.ChemicalCrystalizer.name"); } - + @Override public String getOverlayIdentifier() { return "chemicalcrystalizer"; } - + @Override public String getGuiTexture() { return "mekanism:gui/nei/GuiChemicalCrystalizer.png"; } - + @Override public Class getGuiClass() { @@ -84,13 +84,13 @@ public class ChemicalCrystalizerRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { GasStack gas = ((CachedIORecipe)arecipes.get(i)).inputStack; - + float f = ticksPassed % 20 / 20.0F; drawProgressBar(53-xOffset, 61-yOffset, 176, 63, 48, 8, f, 0); - + if(gas != null) { - displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, gas); + displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, gas); } } @@ -98,7 +98,7 @@ public class ChemicalCrystalizerRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -134,38 +134,38 @@ public class ChemicalCrystalizerRecipeHandler extends BaseRecipeHandler } } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).inputStack.getGas().getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } - + @Override public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack stack = null; - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { stack = ((CachedIORecipe)arecipes.get(recipe)).inputStack; } - + if(stack != null) { if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) @@ -183,25 +183,25 @@ public class ChemicalCrystalizerRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack stack = null; - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { stack = ((CachedIORecipe)arecipes.get(recipe)).inputStack; } - + if(stack != null) { if(button == 0) @@ -219,7 +219,7 @@ public class ChemicalCrystalizerRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } diff --git a/common/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java b/common/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java index 4dc744b41..c240b974a 100644 --- a/common/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java +++ b/common/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java @@ -33,28 +33,28 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + public static int xOffset = 5; public static int yOffset = 3; - + @Override public String getRecipeName() { return MekanismUtils.localize("gui.chemicalDissolutionChamber.short"); } - + @Override public String getOverlayIdentifier() { return "chemicaldissolutionchamber"; } - + @Override public String getGuiTexture() { return "mekanism:gui/nei/GuiChemicalDissolutionChamber.png"; } - + @Override public Class getGuiClass() { @@ -83,15 +83,15 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { GasStack gas = ((CachedIORecipe)arecipes.get(i)).outputStack; - + float f = ticksPassed % 20 / 20.0F; drawProgressBar(64-xOffset, 40-yOffset, 176, 63, 48, 8, f, 0); - + displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, new GasStack(GasRegistry.getGas("sulfuricAcid"), 1)); - + if(gas != null) { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, gas); + displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, gas); } } @@ -99,7 +99,7 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -133,15 +133,15 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { currenttip.add(GasRegistry.getGas("sulfuricAcid").getLocalizedName()); @@ -150,20 +150,20 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputStack.getGas().getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } - + @Override public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack stack = null; - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { stack = new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); @@ -172,7 +172,7 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler { stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; } - + if(stack != null) { if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) @@ -190,20 +190,20 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack stack = null; - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { stack = new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); @@ -212,7 +212,7 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler { stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; } - + if(stack != null) { if(button == 0) @@ -230,7 +230,7 @@ public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } diff --git a/common/mekanism/client/nei/ChemicalInfuserRecipeHandler.java b/common/mekanism/client/nei/ChemicalInfuserRecipeHandler.java index c42d627f1..93dea2ed8 100644 --- a/common/mekanism/client/nei/ChemicalInfuserRecipeHandler.java +++ b/common/mekanism/client/nei/ChemicalInfuserRecipeHandler.java @@ -30,28 +30,28 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + public static int xOffset = 5; public static int yOffset = 3; - + @Override public String getRecipeName() { return MekanismUtils.localize("tile.MachineBlock2.ChemicalInfuser.name"); } - + @Override public String getOverlayIdentifier() { return "chemicalinfuser"; } - + @Override public String getGuiTexture() { return "mekanism:gui/nei/GuiChemicalInfuser.png"; } - + @Override public Class getGuiClass() { @@ -80,23 +80,23 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - + drawTexturedModalRect(47-xOffset, 39-yOffset, 176, 71, 28, 8); drawTexturedModalRect(101-xOffset, 39-yOffset, 176, 63, 28, 8); - + if(recipe.chemicalInput.leftGas != null) { - displayGauge(58, 26-xOffset, 14-yOffset, 176, 4, 58, null, recipe.chemicalInput.leftGas); + displayGauge(58, 26-xOffset, 14-yOffset, 176, 4, 58, null, recipe.chemicalInput.leftGas); } - + if(recipe.outputStack != null) { - displayGauge(58, 80-xOffset, 5-yOffset, 176, 4, 58, null, recipe.outputStack); + displayGauge(58, 80-xOffset, 5-yOffset, 176, 4, 58, null, recipe.outputStack); } - + if(recipe.chemicalInput.rightGas != null) { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, recipe.chemicalInput.rightGas); + displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, recipe.chemicalInput.rightGas); } } @@ -104,7 +104,7 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -139,7 +139,7 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public void loadUsageRecipes(String inputId, Object... ingredients) { @@ -157,15 +157,15 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler super.loadUsageRecipes(inputId, ingredients); } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13) { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas.getGas().getLocalizedName()); @@ -178,7 +178,7 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas.getGas().getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } @@ -186,12 +186,12 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack stack = null; - + if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13) { stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas; @@ -204,7 +204,7 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler { stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas; } - + if(stack != null) { if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) @@ -222,20 +222,20 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack stack = null; - + if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13) { stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas; @@ -248,7 +248,7 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler { stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas; } - + if(stack != null) { if(button == 0) @@ -266,10 +266,10 @@ public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } - + @Override public int recipiesPerPage() { diff --git a/common/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java b/common/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java index 1cee3020e..1b2589500 100644 --- a/common/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java +++ b/common/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java @@ -26,7 +26,7 @@ public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipe { return "mekanism.chemicalinjectionchamber"; } - + @Override public String getOverlayIdentifier() { @@ -44,7 +44,7 @@ public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipe { return "mekanism:gui/GuiChemicalInjectionChamber.png"; } - + @Override public List getFuelStacks(Gas gasType) { @@ -64,10 +64,10 @@ public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipe fuels.add(MekanismUtils.getFullGasTank(GasRegistry.getGas("hydrogenChloride"))); return fuels; } - + return new ArrayList(); } - + @Override public Class getGuiClass() { diff --git a/common/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java b/common/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java index d24875d4c..9bb6181ff 100644 --- a/common/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java +++ b/common/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java @@ -30,28 +30,28 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + public static int xOffset = 5; public static int yOffset = 12; - + @Override public String getRecipeName() { return MekanismUtils.localize("tile.MachineBlock2.ChemicalOxidizer.name"); } - + @Override public String getOverlayIdentifier() { return "chemicaloxidizer"; } - + @Override public String getGuiTexture() { return "mekanism:gui/GuiChemicalOxidizer.png"; } - + @Override public Class getGuiClass() { @@ -80,13 +80,13 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { GasStack gas = ((CachedIORecipe)arecipes.get(i)).outputStack; - + float f = ticksPassed % 20 / 20.0F; drawProgressBar(64-xOffset, 40-yOffset, 176, 63, 48, 8, f, 0); - + if(gas != null) { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, gas); + displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, gas); } } @@ -94,7 +94,7 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -128,35 +128,35 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputStack.getGas().getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } - + @Override public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) { GasStack stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - + if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { if(doGasLookup(stack, false)) @@ -172,22 +172,22 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) { GasStack stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - + if(button == 0) { if(doGasLookup(stack, false)) @@ -203,7 +203,7 @@ public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } diff --git a/common/mekanism/client/nei/ChemicalWasherRecipeHandler.java b/common/mekanism/client/nei/ChemicalWasherRecipeHandler.java index 7d2c1b7d8..db860e10f 100644 --- a/common/mekanism/client/nei/ChemicalWasherRecipeHandler.java +++ b/common/mekanism/client/nei/ChemicalWasherRecipeHandler.java @@ -31,28 +31,28 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class ChemicalWasherRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + public static int xOffset = 5; public static int yOffset = 3; - + @Override public String getRecipeName() { return MekanismUtils.localize("tile.MachineBlock2.ChemicalWasher.name"); } - + @Override public String getOverlayIdentifier() { return "chemicalwasher"; } - + @Override public String getGuiTexture() { return "mekanism:gui/nei/GuiChemicalWasher.png"; } - + @Override public Class getGuiClass() { @@ -81,19 +81,19 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - + drawTexturedModalRect(61-xOffset, 39-yOffset, 176, 63, 55, 8); - - displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, new FluidStack(FluidRegistry.WATER, 1), null); - + + displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, new FluidStack(FluidRegistry.WATER, 1), null); + if(recipe.outputStack != null) { - displayGauge(58, 27-xOffset, 14-yOffset, 176, 4, 58, null, recipe.inputStack); + displayGauge(58, 27-xOffset, 14-yOffset, 176, 4, 58, null, recipe.inputStack); } - + if(recipe.inputStack != null) { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, recipe.outputStack); + displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, recipe.outputStack); } } @@ -101,7 +101,7 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -135,7 +135,7 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public void loadUsageRecipes(String inputId, Object... ingredients) { @@ -163,15 +163,15 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler super.loadUsageRecipes(inputId, ingredients); } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { currenttip.add(FluidRegistry.WATER.getLocalizedName()); @@ -184,7 +184,7 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputStack.getGas().getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } @@ -192,13 +192,13 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack gas = null; FluidStack fluid = null; - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { fluid = new FluidStack(FluidRegistry.WATER, 1); @@ -211,7 +211,7 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler { gas = ((CachedIORecipe)arecipes.get(recipe)).outputStack; } - + if(gas != null) { if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) @@ -246,21 +246,21 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack gas = null; FluidStack fluid = null; - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) { fluid = new FluidStack(FluidRegistry.WATER, 1); @@ -273,7 +273,7 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler { gas = ((CachedIORecipe)arecipes.get(recipe)).outputStack; } - + if(gas != null) { if(button == 0) @@ -308,10 +308,10 @@ public class ChemicalWasherRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } - + @Override public int recipiesPerPage() { diff --git a/common/mekanism/client/nei/CombinerRecipeHandler.java b/common/mekanism/client/nei/CombinerRecipeHandler.java index 6026751a3..6659dac1d 100644 --- a/common/mekanism/client/nei/CombinerRecipeHandler.java +++ b/common/mekanism/client/nei/CombinerRecipeHandler.java @@ -24,7 +24,7 @@ public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler { return "mekanism.combiner"; } - + @Override public String getOverlayIdentifier() { @@ -42,13 +42,13 @@ public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler { return "mekanism:gui/GuiCombiner.png"; } - + @Override public List getFuelStacks(Gas gasType) { return ListUtils.asList(new ItemStack(Block.cobblestone)); } - + @Override public Class getGuiClass() { diff --git a/common/mekanism/client/nei/CrusherRecipeHandler.java b/common/mekanism/client/nei/CrusherRecipeHandler.java index 8484af0ef..e344088a9 100644 --- a/common/mekanism/client/nei/CrusherRecipeHandler.java +++ b/common/mekanism/client/nei/CrusherRecipeHandler.java @@ -19,7 +19,7 @@ public class CrusherRecipeHandler extends MachineRecipeHandler { return "mekanism.crusher"; } - + @Override public String getOverlayIdentifier() { @@ -37,7 +37,7 @@ public class CrusherRecipeHandler extends MachineRecipeHandler { return "mekanism:gui/GuiCrusher.png"; } - + @Override public Class getGuiClass() { diff --git a/common/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java b/common/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java index 130618afe..895f0866a 100644 --- a/common/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java +++ b/common/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java @@ -30,28 +30,28 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + public static int xOffset = 5; public static int yOffset = 9; - + @Override public String getRecipeName() { return MekanismUtils.localize("tile.MachineBlock2.ElectrolyticSeparator.name"); } - + @Override public String getOverlayIdentifier() { return "electrolyticseparator"; } - + @Override public String getGuiTexture() { return "mekanism:gui/GuiElectrolyticSeparator.png"; } - + @Override public Class getGuiClass() { @@ -80,23 +80,23 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - + float f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; drawProgressBar(165-xOffset, 17-yOffset, 176, 0, 4, 52, f, 3); - + if(recipe.fluidInput != null) { - displayGauge(58, 6-xOffset, 11-yOffset, 176, 68, 58, recipe.fluidInput, null); + displayGauge(58, 6-xOffset, 11-yOffset, 176, 68, 58, recipe.fluidInput, null); } - + if(recipe.outputPair.leftGas != null) { - displayGauge(28, 59-xOffset, 19-yOffset, 176, 68, 28, null, recipe.outputPair.leftGas); + displayGauge(28, 59-xOffset, 19-yOffset, 176, 68, 28, null, recipe.outputPair.leftGas); } - + if(recipe.outputPair.rightGas != null) { - displayGauge(28, 101-xOffset, 19-yOffset, 176, 68, 28, null, recipe.outputPair.rightGas); + displayGauge(28, 101-xOffset, 19-yOffset, 176, 68, 28, null, recipe.outputPair.rightGas); } } @@ -104,7 +104,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -138,7 +138,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public void loadUsageRecipes(String inputId, Object... ingredients) { @@ -156,15 +156,15 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler super.loadUsageRecipes(inputId, ingredients); } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7) { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidInput.getFluid().getLocalizedName()); @@ -177,7 +177,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas.getGas().getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } @@ -185,13 +185,13 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack gas = null; FluidStack fluid = null; - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7) { fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidInput; @@ -204,7 +204,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler { gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas; } - + if(gas != null) { if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) @@ -239,21 +239,21 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack gas = null; FluidStack fluid = null; - + if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7) { fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidInput; @@ -266,7 +266,7 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler { gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas; } - + if(gas != null) { if(button == 0) @@ -301,10 +301,10 @@ public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } - + @Override public int recipiesPerPage() { diff --git a/common/mekanism/client/nei/EnrichmentChamberRecipeHandler.java b/common/mekanism/client/nei/EnrichmentChamberRecipeHandler.java index 359a1b0f7..d90d5edf0 100644 --- a/common/mekanism/client/nei/EnrichmentChamberRecipeHandler.java +++ b/common/mekanism/client/nei/EnrichmentChamberRecipeHandler.java @@ -19,7 +19,7 @@ public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler { return "mekanism.chamber"; } - + @Override public String getOverlayIdentifier() { @@ -37,7 +37,7 @@ public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler { return "mekanism:gui/GuiChamber.png"; } - + @Override public Class getGuiClass() { diff --git a/common/mekanism/client/nei/MachineRecipeHandler.java b/common/mekanism/client/nei/MachineRecipeHandler.java index 2b85ab8ac..9a851f80c 100644 --- a/common/mekanism/client/nei/MachineRecipeHandler.java +++ b/common/mekanism/client/nei/MachineRecipeHandler.java @@ -23,7 +23,7 @@ public abstract class MachineRecipeHandler extends BaseRecipeHandler public abstract String getRecipeId(); public abstract Set> getRecipes(); - + @Override public void drawBackground(int i) { diff --git a/common/mekanism/client/nei/MekanismRecipeHandler.java b/common/mekanism/client/nei/MekanismRecipeHandler.java index c52052a9a..e7feb7525 100644 --- a/common/mekanism/client/nei/MekanismRecipeHandler.java +++ b/common/mekanism/client/nei/MekanismRecipeHandler.java @@ -22,14 +22,14 @@ public class MekanismRecipeHandler extends ShapedRecipeHandler { return "Shaped Mekanism Crafting"; } - + @Override public void loadCraftingRecipes(String outputId, Object... results) { if(outputId.equals("crafting") && getClass() == MekanismRecipeHandler.class) { List allrecipes = CraftingManager.getInstance().getRecipeList(); - + for(IRecipe irecipe : allrecipes) { if(irecipe instanceof MekanismRecipe) @@ -44,12 +44,12 @@ public class MekanismRecipeHandler extends ShapedRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public void loadCraftingRecipes(ItemStack result) { List allrecipes = CraftingManager.getInstance().getRecipeList(); - + for(IRecipe irecipe : allrecipes) { if(irecipe instanceof MekanismRecipe && areItemsEqual(irecipe.getRecipeOutput(), result)) @@ -60,19 +60,19 @@ public class MekanismRecipeHandler extends ShapedRecipeHandler } } } - + @Override public void loadUsageRecipes(ItemStack ingredient) { List allrecipes = CraftingManager.getInstance().getRecipeList(); - + for(IRecipe irecipe : allrecipes) { if(irecipe instanceof MekanismRecipe) { MekanismRecipe energyRecipe = (MekanismRecipe)irecipe; CachedEnergyRecipe recipe = new CachedEnergyRecipe(energyRecipe.width, energyRecipe.height, energyRecipe.getInput(), energyRecipe.getRecipeOutput()); - + if(recipe.contains(recipe.ingredients, ingredient)) { recipe.setIngredientPermutation(recipe.ingredients, ingredient); @@ -81,78 +81,78 @@ public class MekanismRecipeHandler extends ShapedRecipeHandler } } } - - public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2) - { - if(stack1 == null && stack2 != null || stack1 != null && stack2 == null) - { - return false; - } - else if(stack1 == null && stack2 == null) - { - return true; - } - - if(stack1.itemID != stack2.itemID) - { - return false; - } - - if(!(stack1.getItem() instanceof IEnergizedItem) && !(stack2.getItem() instanceof IEnergizedItem)) - { - if(stack1.getItemDamage() != stack2.getItemDamage()) - { - return false; - } - } - else { - if(((IEnergizedItem)stack1.getItem()).isMetadataSpecific() && ((IEnergizedItem)stack2.getItem()).isMetadataSpecific()) - { - if(stack1.getItemDamage() != stack2.getItemDamage()) - { - return false; - } - } - - if(stack1.getItem() instanceof IEnergyCube && stack2.getItem() instanceof IEnergyCube) - { - if(((IEnergyCube)stack1.getItem()).getEnergyCubeTier(stack1) != ((IEnergyCube)stack2.getItem()).getEnergyCubeTier(stack2)) - { - return false; - } - } - else if(stack1.getItem() instanceof IFactory && stack2.getItem() instanceof IFactory) - { - if(isFactory(stack1) && isFactory(stack2)) - { - if(((IFactory)stack1.getItem()).getRecipeType(stack1) != ((IFactory)stack2.getItem()).getRecipeType(stack2)) - { - return false; - } - } - } - } - - return true; - } - - private static boolean isFactory(ItemStack stack) - { - return MachineType.get(stack) == MachineType.BASIC_FACTORY || MachineType.get(stack) == MachineType.ADVANCED_FACTORY || MachineType.get(stack) == MachineType.ELITE_FACTORY; - } - + + public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2) + { + if(stack1 == null && stack2 != null || stack1 != null && stack2 == null) + { + return false; + } + else if(stack1 == null && stack2 == null) + { + return true; + } + + if(stack1.itemID != stack2.itemID) + { + return false; + } + + if(!(stack1.getItem() instanceof IEnergizedItem) && !(stack2.getItem() instanceof IEnergizedItem)) + { + if(stack1.getItemDamage() != stack2.getItemDamage()) + { + return false; + } + } + else { + if(((IEnergizedItem)stack1.getItem()).isMetadataSpecific() && ((IEnergizedItem)stack2.getItem()).isMetadataSpecific()) + { + if(stack1.getItemDamage() != stack2.getItemDamage()) + { + return false; + } + } + + if(stack1.getItem() instanceof IEnergyCube && stack2.getItem() instanceof IEnergyCube) + { + if(((IEnergyCube)stack1.getItem()).getEnergyCubeTier(stack1) != ((IEnergyCube)stack2.getItem()).getEnergyCubeTier(stack2)) + { + return false; + } + } + else if(stack1.getItem() instanceof IFactory && stack2.getItem() instanceof IFactory) + { + if(isFactory(stack1) && isFactory(stack2)) + { + if(((IFactory)stack1.getItem()).getRecipeType(stack1) != ((IFactory)stack2.getItem()).getRecipeType(stack2)) + { + return false; + } + } + } + } + + return true; + } + + private static boolean isFactory(ItemStack stack) + { + return MachineType.get(stack) == MachineType.BASIC_FACTORY || MachineType.get(stack) == MachineType.ADVANCED_FACTORY || MachineType.get(stack) == MachineType.ELITE_FACTORY; + } + public class CachedEnergyRecipe extends CachedRecipe { public ArrayList ingredients; public PositionedStack result; - + public CachedEnergyRecipe(int width, int height, Object[] items, ItemStack out) { result = new PositionedStack(out, 119, 24); ingredients = new ArrayList(); setIngredients(width, height, items); } - + public void setIngredients(int width, int height, Object[] items) { for(int x = 0; x < width; x++) @@ -163,26 +163,26 @@ public class MekanismRecipeHandler extends ShapedRecipeHandler { continue; } - + PositionedStack stack = new PositionedStack(items[y*width+x], 25+x*18, 6+y*18); stack.setMaxSize(1); ingredients.add(stack); } } } - + @Override public ArrayList getIngredients() { return (ArrayList)getCycledIngredients(MekanismRecipeHandler.this.cycleticks / 20, ingredients); } - + @Override public PositionedStack getResult() { return result; } - + @Override public boolean contains(Collection ingredients, ItemStack ingredient) { @@ -196,7 +196,7 @@ public class MekanismRecipeHandler extends ShapedRecipeHandler } } } - + return false; } } diff --git a/common/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java b/common/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java index e84596de0..dc9c8b1c6 100644 --- a/common/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java +++ b/common/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java @@ -29,25 +29,25 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + @Override public String getRecipeName() { return MekanismUtils.localize("tile.MachineBlock.MetallurgicInfuser.name"); } - + @Override public String getOverlayIdentifier() { return "infuser"; } - + @Override public String getGuiTexture() { return "mekanism:gui/GuiMetallurgicInfuser.png"; } - + @Override public Class getGuiClass() { @@ -58,11 +58,11 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler { return "mekanism.infuser"; } - + public List getInfuseStacks(InfuseType type) { List ret = new ArrayList(); - + for(Map.Entry obj : InfuseRegistry.getObjectMap().entrySet()) { if(obj.getValue().type == type) @@ -70,7 +70,7 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler ret.add(obj.getKey()); } } - + return ret; } @@ -91,16 +91,16 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { InfuseType type = ((CachedIORecipe)arecipes.get(i)).infusionType; - + float f = ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F; drawProgressBar(67, 32, 176, 52, 32, 8, f, 0); - + f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F; if(ticksPassed < 20) f = 0.0F; - + f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; drawProgressBar(160, 2, 176, 0, 4, 52, f, 3); - + changeTexture(type.texture); drawProgressBar(2, 2, type.texX, type.texY, 4, 52, f, 3); } @@ -109,7 +109,7 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -133,7 +133,7 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public int recipiesPerPage() { @@ -167,10 +167,10 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { public List infuseStacks; - + public PositionedStack inputStack; public PositionedStack outputStack; - + public InfuseType infusionType; @Override @@ -184,7 +184,7 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler { return outputStack; } - + @Override public PositionedStack getOtherStack() { @@ -194,12 +194,12 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler public CachedIORecipe(ItemStack input, ItemStack output, List infuses, InfuseType type) { super(); - + inputStack = new PositionedStack(input, 46, 28); outputStack = new PositionedStack(output, 104, 28); - + infuseStacks = infuses; - + infusionType = type; } diff --git a/common/mekanism/client/nei/NEIMekanismConfig.java b/common/mekanism/client/nei/NEIMekanismConfig.java index 4b6158779..24fab88e0 100644 --- a/common/mekanism/client/nei/NEIMekanismConfig.java +++ b/common/mekanism/client/nei/NEIMekanismConfig.java @@ -27,55 +27,55 @@ public class NEIMekanismConfig implements IConfigureNEI { API.registerRecipeHandler(new EnrichmentChamberRecipeHandler()); API.registerUsageHandler(new EnrichmentChamberRecipeHandler()); - + API.registerRecipeHandler(new OsmiumCompressorRecipeHandler()); API.registerUsageHandler(new OsmiumCompressorRecipeHandler()); - + API.registerRecipeHandler(new CrusherRecipeHandler()); API.registerUsageHandler(new CrusherRecipeHandler()); - + API.registerRecipeHandler(new CombinerRecipeHandler()); API.registerUsageHandler(new CombinerRecipeHandler()); - + API.registerRecipeHandler(new MetallurgicInfuserRecipeHandler()); API.registerUsageHandler(new MetallurgicInfuserRecipeHandler()); - + API.registerRecipeHandler(new PurificationChamberRecipeHandler()); API.registerUsageHandler(new PurificationChamberRecipeHandler()); - + API.registerRecipeHandler(new ChemicalInjectionChamberRecipeHandler()); API.registerUsageHandler(new ChemicalInjectionChamberRecipeHandler()); - + API.registerRecipeHandler(new MekanismRecipeHandler()); API.registerUsageHandler(new MekanismRecipeHandler()); - + API.registerRecipeHandler(new ChemicalOxidizerRecipeHandler()); API.registerUsageHandler(new ChemicalOxidizerRecipeHandler()); - + API.registerRecipeHandler(new ChemicalInfuserRecipeHandler()); API.registerUsageHandler(new ChemicalInfuserRecipeHandler()); - + API.registerRecipeHandler(new RotaryCondensentratorRecipeHandler()); API.registerUsageHandler(new RotaryCondensentratorRecipeHandler()); - + API.registerRecipeHandler(new ElectrolyticSeparatorRecipeHandler()); API.registerUsageHandler(new ElectrolyticSeparatorRecipeHandler()); - + API.registerRecipeHandler(new PrecisionSawmillRecipeHandler()); API.registerUsageHandler(new PrecisionSawmillRecipeHandler()); - + API.registerRecipeHandler(new SalinationControllerRecipeHandler()); API.registerUsageHandler(new SalinationControllerRecipeHandler()); - + API.registerRecipeHandler(new ChemicalDissolutionChamberRecipeHandler()); API.registerUsageHandler(new ChemicalDissolutionChamberRecipeHandler()); - + API.registerRecipeHandler(new ChemicalWasherRecipeHandler()); API.registerUsageHandler(new ChemicalWasherRecipeHandler()); - + API.registerRecipeHandler(new ChemicalCrystalizerRecipeHandler()); API.registerUsageHandler(new ChemicalCrystalizerRecipeHandler()); - + API.setGuiOffset(GuiEnrichmentChamber.class, 16, 6); API.setGuiOffset(GuiOsmiumCompressor.class, 16, 6); API.setGuiOffset(GuiCrusher.class, 16, 6); @@ -92,7 +92,7 @@ public class NEIMekanismConfig implements IConfigureNEI API.setGuiOffset(GuiChemicalDissolutionChamber.class, ChemicalDissolutionChamberRecipeHandler.xOffset, ChemicalDissolutionChamberRecipeHandler.yOffset); API.setGuiOffset(GuiChemicalWasher.class, ChemicalWasherRecipeHandler.xOffset, ChemicalWasherRecipeHandler.yOffset); API.setGuiOffset(GuiChemicalCrystalizer.class, ChemicalCrystalizerRecipeHandler.xOffset, ChemicalCrystalizerRecipeHandler.yOffset); - + API.hideItem(Mekanism.boundingBlockID); API.hideItem(Mekanism.ItemProxy.itemID); } diff --git a/common/mekanism/client/nei/OsmiumCompressorRecipeHandler.java b/common/mekanism/client/nei/OsmiumCompressorRecipeHandler.java index a40c97932..b29e2d3be 100644 --- a/common/mekanism/client/nei/OsmiumCompressorRecipeHandler.java +++ b/common/mekanism/client/nei/OsmiumCompressorRecipeHandler.java @@ -24,7 +24,7 @@ public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler { return "mekanism.compressor"; } - + @Override public String getOverlayIdentifier() { @@ -42,13 +42,13 @@ public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler { return "mekanism:gui/GuiCompressor.png"; } - + @Override public List getFuelStacks(Gas gasType) { return ListUtils.asList(new ItemStack(Mekanism.Ingot, 1, 1)); } - + @Override public Class getGuiClass() { diff --git a/common/mekanism/client/nei/PrecisionSawmillRecipeHandler.java b/common/mekanism/client/nei/PrecisionSawmillRecipeHandler.java index f54654325..a78529f75 100644 --- a/common/mekanism/client/nei/PrecisionSawmillRecipeHandler.java +++ b/common/mekanism/client/nei/PrecisionSawmillRecipeHandler.java @@ -19,7 +19,7 @@ public class PrecisionSawmillRecipeHandler extends ChanceMachineRecipeHandler { return "mekanism.precisionsawmill"; } - + @Override public String getOverlayIdentifier() { @@ -37,7 +37,7 @@ public class PrecisionSawmillRecipeHandler extends ChanceMachineRecipeHandler { return "mekanism:gui/GuiPrecisionSawmill.png"; } - + @Override public Class getGuiClass() { diff --git a/common/mekanism/client/nei/PurificationChamberRecipeHandler.java b/common/mekanism/client/nei/PurificationChamberRecipeHandler.java index 225a1412d..126da20a8 100644 --- a/common/mekanism/client/nei/PurificationChamberRecipeHandler.java +++ b/common/mekanism/client/nei/PurificationChamberRecipeHandler.java @@ -26,7 +26,7 @@ public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandl { return "mekanism.purificationchamber"; } - + @Override public String getOverlayIdentifier() { @@ -44,7 +44,7 @@ public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandl { return "mekanism:gui/GuiPurificationChamber.png"; } - + @Override public List getFuelStacks(Gas gasType) { @@ -52,10 +52,10 @@ public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandl { return ListUtils.asList(new ItemStack(Item.flint), MekanismUtils.getFullGasTank(GasRegistry.getGas("oxygen"))); } - + return new ArrayList(); } - + @Override public Class getGuiClass() { diff --git a/common/mekanism/client/nei/RotaryCondensentratorRecipeHandler.java b/common/mekanism/client/nei/RotaryCondensentratorRecipeHandler.java index c93b61844..655bd5781 100644 --- a/common/mekanism/client/nei/RotaryCondensentratorRecipeHandler.java +++ b/common/mekanism/client/nei/RotaryCondensentratorRecipeHandler.java @@ -28,28 +28,28 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + public static int xOffset = 5; public static int yOffset = 12; - + @Override public String getRecipeName() { return MekanismUtils.localize("nei.rotaryCondensentrator"); } - + @Override public String getOverlayIdentifier() { return "rotarycondensentrator"; } - + @Override public String getGuiTexture() { return "mekanism:gui/nei/GuiRotaryCondensentrator.png"; } - + @Override public Class getGuiClass() { @@ -73,7 +73,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - + if(recipe.type) { drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 123, 48, 8); @@ -81,17 +81,17 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler else { drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 115, 48, 8); } - + if(recipe.gasStack != null) { - displayGauge(58, 26-xOffset, 14-yOffset, 176, 40, 58, null, recipe.gasStack); + displayGauge(58, 26-xOffset, 14-yOffset, 176, 40, 58, null, recipe.gasStack); } - + if(recipe.fluidStack != null) { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 40, 58, recipe.fluidStack, null); + displayGauge(58, 134-xOffset, 14-yOffset, 176, 40, 58, recipe.fluidStack, null); } - + drawString(recipe.type ? MekanismUtils.localize("gui.condensentrating") : MekanismUtils.localize("gui.decondensentrating"), 6-xOffset, 74-yOffset, 0x404040, false); } @@ -99,7 +99,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -126,7 +126,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { GasStack gas = (GasStack)results[0]; - + if(gas.getGas().hasFluid()) { arecipes.add(new CachedIORecipe(new GasStack(gas.getGas(), 1), new FluidStack(gas.getGas().getFluid(), 1), false)); @@ -136,7 +136,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler { FluidStack fluid = (FluidStack)results[0]; Gas gas = GasRegistry.getGas(fluid.getFluid()); - + if(gas != null) { arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), true)); @@ -146,14 +146,14 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public void loadUsageRecipes(String inputId, Object... ingredients) { if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) { GasStack gas = (GasStack)ingredients[0]; - + if(gas.getGas().hasFluid()) { arecipes.add(new CachedIORecipe(new GasStack(gas.getGas(), 1), new FluidStack(gas.getGas().getFluid(), 1), true)); @@ -163,7 +163,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler { FluidStack fluid = (FluidStack)ingredients[0]; Gas gas = GasRegistry.getGas(fluid.getFluid()); - + if(gas != null) { arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), false)); @@ -173,15 +173,15 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler super.loadUsageRecipes(inputId, ingredients); } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4) { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).gasStack.getGas().getLocalizedName()); @@ -190,7 +190,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidStack.getFluid().getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } @@ -198,13 +198,13 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack gas = null; FluidStack fluid = null; - + if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4) { gas = ((CachedIORecipe)arecipes.get(recipe)).gasStack; @@ -213,7 +213,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler { fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidStack; } - + if(gas != null) { if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) @@ -248,21 +248,21 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + GasStack gas = null; FluidStack fluid = null; - + if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+18 && yAxis <= 72+18) { gas = ((CachedIORecipe)arecipes.get(recipe)).gasStack; @@ -271,7 +271,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler { fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidStack; } - + if(gas != null) { if(button == 0) @@ -306,10 +306,10 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } - + @Override public int recipiesPerPage() { @@ -320,7 +320,7 @@ public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler { public GasStack gasStack; public FluidStack fluidStack; - + /* true = condensentrating, false = decondensentrating */ public boolean type; diff --git a/common/mekanism/client/nei/SalinationControllerRecipeHandler.java b/common/mekanism/client/nei/SalinationControllerRecipeHandler.java index 407c24212..4b09f295a 100644 --- a/common/mekanism/client/nei/SalinationControllerRecipeHandler.java +++ b/common/mekanism/client/nei/SalinationControllerRecipeHandler.java @@ -29,38 +29,38 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class SalinationControllerRecipeHandler extends BaseRecipeHandler { private int ticksPassed; - + private static Map recipes = new HashMap(); - + public static int xOffset = 5; public static int yOffset = 12; - - static + + static { if(recipes.isEmpty()) { recipes.put(new FluidStack(FluidRegistry.WATER, 1), new FluidStack(FluidRegistry.getFluid("brine"), 1)); } } - + @Override public String getRecipeName() { return MekanismUtils.localize("tile.BasicBlock.SalinationController.name"); } - + @Override public String getOverlayIdentifier() { return "salinationcontroller"; } - + @Override public String getGuiTexture() { return "mekanism:gui/nei/GuiSalinationController.png"; } - + @Override public Class getGuiClass() { @@ -89,17 +89,17 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler public void drawExtras(int i) { CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - + drawProgressBar(49-xOffset, 64-yOffset, 176, 59, 78, 8, ticksPassed < 20 ? ticksPassed % 20 / 20.0F : 1.0F, 0); - + if(recipe.fluidInput != null) { - displayGauge(58, 7-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidInput, null); + displayGauge(58, 7-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidInput, null); } - + if(recipe.fluidOutput != null) { - displayGauge(58, 153-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidOutput, null); + displayGauge(58, 153-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidOutput, null); } } @@ -107,7 +107,7 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler public void onUpdate() { super.onUpdate(); - + ticksPassed++; } @@ -135,7 +135,7 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler super.loadCraftingRecipes(outputId, results); } } - + @Override public void loadUsageRecipes(String inputId, Object... ingredients) { @@ -153,15 +153,15 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler super.loadUsageRecipes(inputId, ingredients); } } - + @Override public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidInput.getFluid().getLocalizedName()); @@ -170,7 +170,7 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler { currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidOutput.getFluid().getLocalizedName()); } - + return super.handleTooltip(gui, currenttip, recipe); } @@ -178,12 +178,12 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + FluidStack stack = null; - + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) { stack = ((CachedIORecipe)arecipes.get(recipe)).fluidInput; @@ -192,7 +192,7 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler { stack = ((CachedIORecipe)arecipes.get(recipe)).fluidOutput; } - + if(stack != null) { if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) @@ -210,20 +210,20 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler } } } - + return super.keyTyped(gui, keyChar, keyCode, recipe); } - + @Override public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { Point point = GuiDraw.getMousePosition(); - + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - + FluidStack stack = null; - + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) { stack = ((CachedIORecipe)arecipes.get(recipe)).fluidInput; @@ -232,7 +232,7 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler { stack = ((CachedIORecipe)arecipes.get(recipe)).fluidOutput; } - + if(stack != null) { if(button == 0) @@ -250,10 +250,10 @@ public class SalinationControllerRecipeHandler extends BaseRecipeHandler } } } - + return super.mouseClicked(gui, button, recipe); } - + @Override public int recipiesPerPage() { diff --git a/common/mekanism/client/render/MekanismRenderer.java b/common/mekanism/client/render/MekanismRenderer.java index c49dd12e3..52bef891b 100644 --- a/common/mekanism/client/render/MekanismRenderer.java +++ b/common/mekanism/client/render/MekanismRenderer.java @@ -39,25 +39,25 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class MekanismRenderer +public class MekanismRenderer { private static RenderBlocks renderBlocks = new RenderBlocks(); - + public static Icon[] colors = new Icon[256]; - + public static Icon energyIcon; - + private static float lightmapLastX; - private static float lightmapLastY; + private static float lightmapLastY; private static boolean optifineBreak = false; - + public static RenderConfigurableMachine machineRenderer = new RenderConfigurableMachine(); - + public static void init() { MinecraftForge.EVENT_BUS.register(new MekanismRenderer()); } - + @ForgeSubscribe public void onStitch(TextureStitchEvent.Pre event) { @@ -67,9 +67,9 @@ public class MekanismRenderer { colors[color.ordinal()] = event.map.registerIcon("mekanism:overlay/Overlay" + color.getLocalizedName().replace(" ", "")); } - + energyIcon = event.map.registerIcon("mekanism:LiquidEnergy"); - + GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:LiquidHydrogen")); GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:LiquidOxygen")); GasRegistry.getGas("water").setIcon(event.map.registerIcon("mekanism:WaterVapor")); @@ -80,7 +80,7 @@ public class MekanismRenderer GasRegistry.getGas("hydrogenChloride").setIcon(event.map.registerIcon("mekanism:LiquidHydrogenChloride")); GasRegistry.getGas("liquidOsmium").setIcon(event.map.registerIcon("mekanism:LiquidOsmium")); GasRegistry.getGas("liquidStone").setIcon(event.map.registerIcon("mekanism:LiquidStone")); - + for(Gas gas : GasRegistry.getRegisteredGasses()) { if(gas instanceof OreGas) @@ -98,7 +98,7 @@ public class MekanismRenderer FluidRegistry.getFluid("brine").setIcons(event.map.registerIcon("mekanism:LiquidBrine")); } } - + public static class Model3D { public double minX; @@ -107,43 +107,43 @@ public class MekanismRenderer public double maxX; public double maxY; public double maxZ; - + public Icon[] textures = new Icon[6]; - + public boolean[] renderSides = new boolean[] {true, true, true, true, true, true, false}; public Block baseBlock = Block.sand; - - public final void setBlockBounds(float xNeg, float yNeg, float zNeg, float xPos, float yPos, float zPos) - { - minX = xNeg; - minY = yNeg; - minZ = zNeg; - maxX = xPos; - maxY = yPos; - maxZ = zPos; - } - + + public final void setBlockBounds(float xNeg, float yNeg, float zNeg, float xPos, float yPos, float zPos) + { + minX = xNeg; + minY = yNeg; + minZ = zNeg; + maxX = xPos; + maxY = yPos; + maxZ = zPos; + } + public void setSideRender(ForgeDirection side, boolean value) { renderSides[side.ordinal()] = value; } - + public boolean shouldSideRender(ForgeDirection side) { return renderSides[side.ordinal()]; } - public Icon getBlockTextureFromSide(int i) + public Icon getBlockTextureFromSide(int i) { return textures[i]; } - + public void setTexture(Icon tex) { Arrays.fill(textures, tex); } - + public void setTextures(Icon down, Icon up, Icon north, Icon south, Icon west, Icon east) { textures[0] = down; @@ -154,22 +154,22 @@ public class MekanismRenderer textures[5] = east; } } - + public static void renderObject(Model3D object) { if(object == null) { return; } - - renderBlocks.renderMaxX = object.maxX; - renderBlocks.renderMinX = object.minX; - renderBlocks.renderMaxY = object.maxY; - renderBlocks.renderMinY = object.minY; - renderBlocks.renderMaxZ = object.maxZ; - renderBlocks.renderMinZ = object.minZ; - - renderBlocks.enableAO = false; + + renderBlocks.renderMaxX = object.maxX; + renderBlocks.renderMinX = object.minX; + renderBlocks.renderMaxY = object.maxY; + renderBlocks.renderMinY = object.minY; + renderBlocks.renderMaxZ = object.maxZ; + renderBlocks.renderMinZ = object.minZ; + + renderBlocks.enableAO = false; Tessellator.instance.startDrawingQuads(); @@ -202,68 +202,68 @@ public class MekanismRenderer { renderBlocks.renderFaceXPos(null, 0, 0, 0, object.getBlockTextureFromSide(5)); } - + if(Tessellator.instance.isDrawing) { Tessellator.instance.draw(); } } - + public static Icon getColorIcon(EnumColor color) { return colors[color.ordinal()]; } - - public static void glowOn() - { - glowOn(15); - } - - public static void glowOn(int glow) - { - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - - try { - lightmapLastX = OpenGlHelper.lastBrightnessX; - lightmapLastY = OpenGlHelper.lastBrightnessY; - } catch(NoSuchFieldError e) { - optifineBreak = true; - } - - RenderHelper.disableStandardItemLighting(); - - float glowRatioX = Math.min((glow/15F)*240F + lightmapLastX, 240); - float glowRatioY = Math.min((glow/15F)*240F + lightmapLastY, 240); - - if(!optifineBreak) - { - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, glowRatioX, glowRatioY); - } - } - public static void glowOff() - { - if(!optifineBreak) - { - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapLastX, lightmapLastY); - } - - GL11.glPopAttrib(); - } - - public static void blendOn() - { + public static void glowOn() + { + glowOn(15); + } + + public static void glowOn(int glow) + { + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + + try { + lightmapLastX = OpenGlHelper.lastBrightnessX; + lightmapLastY = OpenGlHelper.lastBrightnessY; + } catch(NoSuchFieldError e) { + optifineBreak = true; + } + + RenderHelper.disableStandardItemLighting(); + + float glowRatioX = Math.min((glow/15F)*240F + lightmapLastX, 240); + float glowRatioY = Math.min((glow/15F)*240F + lightmapLastY, 240); + + if(!optifineBreak) + { + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, glowRatioX, glowRatioY); + } + } + + public static void glowOff() + { + if(!optifineBreak) + { + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapLastX, lightmapLastY); + } + + GL11.glPopAttrib(); + } + + public static void blendOn() + { GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - public static void blendOff() - { - GL11.glPopAttrib(); - } + } + + public static void blendOff() + { + GL11.glPopAttrib(); + } /** * Blender .objs have a different handedness of coordinate system to MC, so faces are wound backwards. @@ -279,43 +279,43 @@ public class MekanismRenderer GL11.glCullFace(GL11.GL_BACK); GL11.glDisable(GL11.GL_CULL_FACE); } - - /** - * Cleaned-up snip of ItemRenderer.renderItem() -- meant to render 2D items as equipped. - * @param item - ItemStack to render - */ - public static void renderItem(ItemStack item) - { + + /** + * Cleaned-up snip of ItemRenderer.renderItem() -- meant to render 2D items as equipped. + * @param item - ItemStack to render + */ + public static void renderItem(ItemStack item) + { Icon icon = item.getItem().getIconIndex(item); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - if(icon == null) - { - GL11.glPopMatrix(); - return; - } + if(icon == null) + { + GL11.glPopMatrix(); + return; + } - texturemanager.bindTexture(texturemanager.getResourceLocation(item.getItemSpriteNumber())); - Tessellator tessellator = Tessellator.instance; - - float minU = icon.getMinU(); - float maxU = icon.getMaxU(); - float minV = icon.getMinV(); - float maxV = icon.getMaxV(); - - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glTranslatef(0.0F, -0.3F, 0.0F); - - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); - - RenderManager.instance.itemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + texturemanager.bindTexture(texturemanager.getResourceLocation(item.getItemSpriteNumber())); + Tessellator tessellator = Tessellator.instance; + + float minU = icon.getMinU(); + float maxU = icon.getMaxU(); + float minV = icon.getMinV(); + float maxV = icon.getMaxV(); + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef(0.0F, -0.3F, 0.0F); + + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); + + RenderManager.instance.itemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } - /** * Cleaned-up snip of RenderBlocks.renderBlockAsItem() -- used for rendering an item as an entity, * in a player's inventory, and in a player's hand. @@ -329,12 +329,12 @@ public class MekanismRenderer { block.setBlockBoundsForItemRender(); } - + if(block instanceof ISpecialBounds) { ((ISpecialBounds)block).setRenderBounds(block, metadata); } - + if(!(block instanceof ISpecialBounds) || ((ISpecialBounds)block).doDefaultBoundSetting(metadata)) { renderer.setRenderBoundsFromBlock(block); @@ -343,177 +343,177 @@ public class MekanismRenderer renderer.setRenderBounds(0, 0, 0, 1, 1, 1); } - if(renderer.useInventoryTint) - { - int renderColor = block.getRenderColor(metadata); - float red = (renderColor >> 16 & 255) / 255.0F; - float green = (renderColor >> 8 & 255) / 255.0F; - float blue = (renderColor & 255) / 255.0F; - GL11.glColor4f(red, green, blue, 1.0F); - } + if(renderer.useInventoryTint) + { + int renderColor = block.getRenderColor(metadata); + float red = (renderColor >> 16 & 255) / 255.0F; + float green = (renderColor >> 8 & 255) / 255.0F; + float blue = (renderColor & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); + } - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); - tessellator.draw(); - - GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); + tessellator.draw(); + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); } - + public static void colorFluid(Fluid fluid) { - int color = fluid.getColor(); - - float cR = (color >> 16 & 0xFF) / 255.0F; - float cG = (color >> 8 & 0xFF) / 255.0F; - float cB = (color & 0xFF) / 255.0F; - - GL11.glColor3f(cR, cG, cB); + int color = fluid.getColor(); + + float cR = (color >> 16 & 0xFF) / 255.0F; + float cG = (color >> 8 & 0xFF) / 255.0F; + float cB = (color & 0xFF) / 255.0F; + + GL11.glColor3f(cR, cG, cB); } - - public static class DisplayInteger - { - public int display; - - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + display; - return code; - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof DisplayInteger && ((DisplayInteger)obj).display == display; - } - - public static DisplayInteger createAndStart() - { - DisplayInteger newInteger = new DisplayInteger(); - newInteger.display = GLAllocation.generateDisplayLists(1); - GL11.glNewList(newInteger.display, GL11.GL_COMPILE); - return newInteger; - } - - public static void endList() - { - GL11.glEndList(); - } - - public void render() - { - GL11.glCallList(display); - } - } - - public static TextureMap getTextureMap(int type) - { - try { - List l = (List)MekanismUtils.getPrivateValue(Minecraft.getMinecraft().renderEngine, TextureManager.class, ObfuscatedNames.TextureManager_listTickables); - - for(Object obj : l) - { - if(obj instanceof TextureMap) - { - if(((TextureMap)obj).textureType == type) - { - return (TextureMap)obj; - } - } - } - } catch(Exception e) {} - - return null; - } - - public static class BooleanArray - { - private final boolean[] boolArray; - - public BooleanArray(boolean[] array) + + public static class DisplayInteger + { + public int display; + + @Override + public int hashCode() + { + int code = 1; + code = 31 * code + display; + return code; + } + + @Override + public boolean equals(Object obj) + { + return obj instanceof DisplayInteger && ((DisplayInteger)obj).display == display; + } + + public static DisplayInteger createAndStart() + { + DisplayInteger newInteger = new DisplayInteger(); + newInteger.display = GLAllocation.generateDisplayLists(1); + GL11.glNewList(newInteger.display, GL11.GL_COMPILE); + return newInteger; + } + + public static void endList() + { + GL11.glEndList(); + } + + public void render() + { + GL11.glCallList(display); + } + } + + public static TextureMap getTextureMap(int type) + { + try { + List l = (List)MekanismUtils.getPrivateValue(Minecraft.getMinecraft().renderEngine, TextureManager.class, ObfuscatedNames.TextureManager_listTickables); + + for(Object obj : l) + { + if(obj instanceof TextureMap) + { + if(((TextureMap)obj).textureType == type) + { + return (TextureMap)obj; + } + } + } + } catch(Exception e) {} + + return null; + } + + public static class BooleanArray + { + private final boolean[] boolArray; + + public BooleanArray(boolean[] array) { boolArray = array.clone(); } - - @Override - public boolean equals(Object o) - { - if(o instanceof BooleanArray) - { - return Arrays.equals(boolArray, ((BooleanArray)o).boolArray); - } - else if(o instanceof boolean[]) - { - return Arrays.equals(boolArray, (boolean[])o); - } - else { - return false; - } - } - - @Override - public int hashCode() - { - return Arrays.hashCode(boolArray); - } - } - - public static float getPartialTick() - { - try { - Timer t = (Timer)MekanismUtils.getPrivateValue(Minecraft.getMinecraft(), Minecraft.class, ObfuscatedNames.Minecraft_timer); - return t.renderPartialTicks; - } catch(Exception e) {} - - return 0; - } - - public void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6) - { - int zLevel = 0; - float f = 0.00390625F; - float f1 = 0.00390625F; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((par1 + 0), (par2 + par6), zLevel, ((par3 + 0) * f), ((par4 + par6) * f1)); - tessellator.addVertexWithUV((par1 + par5), (par2 + par6), zLevel, ((par3 + par5) * f), ((par4 + par6) * f1)); - tessellator.addVertexWithUV((par1 + par5), (par2 + 0), zLevel, ((par3 + par5) * f), ((par4 + 0) * f1)); - tessellator.addVertexWithUV((par1 + 0), (par2 + 0), zLevel, ((par3 + 0) * f), ((par4 + 0) * f1)); - tessellator.draw(); - } - - public static ResourceLocation getBlocksTexture() - { - return TextureMap.locationBlocksTexture; - } - - public static ResourceLocation getItemsTexture() - { - return TextureMap.locationItemsTexture; - } + + @Override + public boolean equals(Object o) + { + if(o instanceof BooleanArray) + { + return Arrays.equals(boolArray, ((BooleanArray)o).boolArray); + } + else if(o instanceof boolean[]) + { + return Arrays.equals(boolArray, (boolean[])o); + } + else { + return false; + } + } + + @Override + public int hashCode() + { + return Arrays.hashCode(boolArray); + } + } + + public static float getPartialTick() + { + try { + Timer t = (Timer)MekanismUtils.getPrivateValue(Minecraft.getMinecraft(), Minecraft.class, ObfuscatedNames.Minecraft_timer); + return t.renderPartialTicks; + } catch(Exception e) {} + + return 0; + } + + public void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6) + { + int zLevel = 0; + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((par1 + 0), (par2 + par6), zLevel, ((par3 + 0) * f), ((par4 + par6) * f1)); + tessellator.addVertexWithUV((par1 + par5), (par2 + par6), zLevel, ((par3 + par5) * f), ((par4 + par6) * f1)); + tessellator.addVertexWithUV((par1 + par5), (par2 + 0), zLevel, ((par3 + par5) * f), ((par4 + 0) * f1)); + tessellator.addVertexWithUV((par1 + 0), (par2 + 0), zLevel, ((par3 + 0) * f), ((par4 + 0) * f1)); + tessellator.draw(); + } + + public static ResourceLocation getBlocksTexture() + { + return TextureMap.locationBlocksTexture; + } + + public static ResourceLocation getItemsTexture() + { + return TextureMap.locationItemsTexture; + } } diff --git a/common/mekanism/client/render/ModelCustomArmor.java b/common/mekanism/client/render/ModelCustomArmor.java index 615870e39..071937055 100644 --- a/common/mekanism/client/render/ModelCustomArmor.java +++ b/common/mekanism/client/render/ModelCustomArmor.java @@ -23,14 +23,14 @@ import cpw.mods.fml.relauncher.SideOnly; public class ModelCustomArmor extends ModelBiped { public static ModelCustomArmor INSTANCE = new ModelCustomArmor(); - + public static GlowArmor GLOW_BIG = new GlowArmor(1.0F); public static GlowArmor GLOW_SMALL = new GlowArmor(0.5F); - + public static Minecraft mc = Minecraft.getMinecraft(); public ArmorModel modelType; - + public ModelCustomArmor() { resetPart(bipedHead, 0, 0, 0); @@ -48,7 +48,7 @@ public class ModelCustomArmor extends ModelBiped public void init(Entity entity, float f, float f1, float f2, float f3, float f4, float size) { reset(); - + if(entity instanceof EntityLivingBase) { isSneak = ((EntityLivingBase)entity).isSneaking(); @@ -57,7 +57,7 @@ public class ModelCustomArmor extends ModelBiped } if(modelType.armorSlot == 0) - { + { bipedHead.isHidden = false; bipedHead.showModel = true; } @@ -76,7 +76,7 @@ public class ModelCustomArmor extends ModelBiped setRotationAngles(f, f1, f2, f3, f4, size, entity); } - + public void reset() { bipedHead.isHidden = true; @@ -85,7 +85,7 @@ public class ModelCustomArmor extends ModelBiped bipedLeftArm.isHidden = true; bipedRightLeg.isHidden = true; bipedLeftLeg.isHidden = true; - + bipedHead.showModel = false; bipedBody.showModel = false; bipedRightArm.showModel = false; @@ -113,7 +113,7 @@ public class ModelCustomArmor extends ModelBiped { public ModelCustomArmor biped; public ModelRenderer partRender; - + public ModelCustom(ModelCustomArmor base, ModelRenderer renderer) { super(base); @@ -123,14 +123,14 @@ public class ModelCustomArmor extends ModelBiped @Override public void render(float size) - { + { if(ModelCustomArmor.this.modelType != null) { GL11.glPushMatrix(); GL11.glTranslatef(0, 0, 0.06F); - + mc.renderEngine.bindTexture(modelType.resource); - + if(useModel(biped.modelType, partRender, biped)) { if(biped.modelType == ArmorModel.JETPACK) @@ -153,7 +153,7 @@ public class ModelCustomArmor extends ModelBiped else if(biped.modelType == ArmorModel.FREERUNNERS) { GL11.glScalef(1.02F, 1.02F, 1.02F); - + if(partRender == biped.bipedLeftLeg) { GL11.glTranslatef(-0.1375F, -0.75F, -0.0625F); @@ -166,19 +166,19 @@ public class ModelCustomArmor extends ModelBiped } } } - + GL11.glPopMatrix(); } } } - + @Override public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) { init(entity, par2, par3, par4, par5, par6, par7); super.render(entity, par2, par3, par4, par5, par6, par7); } - + public static boolean useModel(ArmorModel type, ModelRenderer partRender, ModelCustomArmor biped) { if(type.armorSlot == 0) @@ -193,11 +193,11 @@ public class ModelCustomArmor extends ModelBiped { return partRender == biped.bipedLeftLeg || partRender == biped.bipedRightLeg; } - + return false; } - public static enum ArmorModel + public static enum ArmorModel { JETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")), ARMOREDJETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")), @@ -207,7 +207,7 @@ public class ModelCustomArmor extends ModelBiped public int armorSlot; public ResourceLocation resource; - + public static ModelJetpack jetpackModel = new ModelJetpack(); public static ModelArmoredJetpack armoredJetpackModel = new ModelArmoredJetpack(); public static ModelGasMask gasMaskModel = new ModelGasMask(); @@ -220,29 +220,29 @@ public class ModelCustomArmor extends ModelBiped resource = r; } } - + public static ModelBiped getGlow(int index) { ModelBiped biped = index != 2 ? GLOW_BIG : GLOW_SMALL; - - biped.bipedHead.showModel = index == 0; - biped.bipedHeadwear.showModel = index == 0; - biped.bipedBody.showModel = index == 1 || index == 2; - biped.bipedRightArm.showModel = index == 1; - biped.bipedLeftArm.showModel = index == 1; - biped.bipedRightLeg.showModel = index == 2 || index == 3; - biped.bipedLeftLeg.showModel = index == 2 || index == 3; - + + biped.bipedHead.showModel = index == 0; + biped.bipedHeadwear.showModel = index == 0; + biped.bipedBody.showModel = index == 1 || index == 2; + biped.bipedRightArm.showModel = index == 1; + biped.bipedLeftArm.showModel = index == 1; + biped.bipedRightLeg.showModel = index == 2 || index == 3; + biped.bipedLeftLeg.showModel = index == 2 || index == 3; + return biped; } - + public static class GlowArmor extends ModelBiped { public GlowArmor(float size) { super(size); } - + @Override public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) { @@ -252,9 +252,9 @@ public class ModelCustomArmor extends ModelBiped isRiding = ((EntityLivingBase)entity).isRiding(); isChild = ((EntityLivingBase)entity).isChild(); } - + setRotationAngles(par2, par3, par4, par5, par6, par7, entity); - + MekanismRenderer.glowOn(); super.render(entity, par2, par3, par4, par5, par6, par7); MekanismRenderer.glowOff(); diff --git a/common/mekanism/client/render/RenderPartTransmitter.java b/common/mekanism/client/render/RenderPartTransmitter.java index 391d53ac8..a9ff77d98 100644 --- a/common/mekanism/client/render/RenderPartTransmitter.java +++ b/common/mekanism/client/render/RenderPartTransmitter.java @@ -65,22 +65,22 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderPartTransmitter implements IIconRegister { public static RenderPartTransmitter INSTANCE; - + public static Map small_models; - public static Map large_models; + public static Map large_models; public static Map contents_models; - + private static final int stages = 100; private static final double height = 0.45; private static final double offset = 0.015; - + private ModelTransporterBox modelBox = new ModelTransporterBox(); - + private HashMap> cachedLiquids = new HashMap>(); private HashMap> cachedOverlays = new HashMap>(); - + private Minecraft mc = Minecraft.getMinecraft(); - + private EntityItem entityItem = new EntityItem(null); private RenderItem renderer = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class); @@ -88,31 +88,31 @@ public class RenderPartTransmitter implements IIconRegister { return INSTANCE; } - + public static void init() { INSTANCE = new RenderPartTransmitter(); TextureUtils.addIconRegistrar(INSTANCE); - - small_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_small.obj"), 7, null); - for(CCModel c : small_models.values()) - { - c.apply(new Translation(.5, .5, .5)); - c.computeLighting(LightModel.standardLightModel); - c.shrinkUVs(0.0005); - } + small_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_small.obj"), 7, null); - large_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_large.obj"), 7, null); + for(CCModel c : small_models.values()) + { + c.apply(new Translation(.5, .5, .5)); + c.computeLighting(LightModel.standardLightModel); + c.shrinkUVs(0.0005); + } - for(CCModel c : large_models.values()) - { - c.apply(new Translation(.5, .5, .5)); - c.computeLighting(LightModel.standardLightModel); - c.shrinkUVs(0.0005); - } + large_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_large.obj"), 7, null); - contents_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), 7, null); + for(CCModel c : large_models.values()) + { + c.apply(new Translation(.5, .5, .5)); + c.computeLighting(LightModel.standardLightModel); + c.shrinkUVs(0.0005); + } + + contents_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), 7, null); LightModel interiorLightModel = new LightModel() .setAmbient(new Vector3(0.6, 0.6, 0.6)) .addLight(new Light(new Vector3(0.3, 1, -0.7)) @@ -121,13 +121,13 @@ public class RenderPartTransmitter implements IIconRegister .setDiffuse(new Vector3(0.6, 0.6, 0.6))); for(CCModel c : contents_models.values()) - { - c.apply(new Translation(.5, .5, .5)); - c.computeLighting(interiorLightModel); - c.shrinkUVs(0.0005); - } + { + c.apply(new Translation(.5, .5, .5)); + c.computeLighting(interiorLightModel); + c.shrinkUVs(0.0005); + } } - + private void push() { GL11.glPushMatrix(); @@ -137,7 +137,7 @@ public class RenderPartTransmitter implements IIconRegister GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } - + private void pop() { GL11.glPopAttrib(); @@ -154,32 +154,32 @@ public class RenderPartTransmitter implements IIconRegister } CCRenderState.draw(); } - + public void renderContents(PartLogisticalTransporter transporter, float partialTick, Vector3 vec) { GL11.glPushMatrix(); - + entityItem.age = 0; entityItem.hoverStart = 0; - + entityItem.setPosition(transporter.x() + 0.5, transporter.y() + 0.5, transporter.z() + 0.5); entityItem.worldObj = transporter.world(); - + for(TransporterStack stack : transporter.transit) { if(stack != null) { GL11.glPushMatrix(); entityItem.setEntityItemStack(stack.itemStack); - + float[] pos = TransporterUtils.getStackPosition(transporter, stack, partialTick*PartLogisticalTransporter.SPEED); - + GL11.glTranslated(vec.x + pos[0], vec.y + pos[1] - entityItem.yOffset, vec.z + pos[2]); GL11.glScalef(0.75F, 0.75F, 0.75F); - + renderer.doRenderItem(entityItem, 0, 0, 0, 0, 0); GL11.glPopMatrix(); - + if(stack.color != null) { CCRenderState.changeTexture(MekanismUtils.getResource(ResourceType.RENDER, "TransporterBox.png")); @@ -194,66 +194,66 @@ public class RenderPartTransmitter implements IIconRegister } } } - + if(transporter instanceof PartDiversionTransporter) { EntityPlayer player = mc.thePlayer; World world = mc.thePlayer.worldObj; ItemStack itemStack = player.getCurrentEquippedItem(); MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F); - + if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator) { int xPos = MathHelper.floor_double(pos.blockX); int yPos = MathHelper.floor_double(pos.blockY); int zPos = MathHelper.floor_double(pos.blockZ); - + Coord4D obj = new Coord4D(xPos, yPos, zPos, transporter.world().provider.dimensionId); - + if(obj.equals(Coord4D.get(transporter.tile()))) { int mode = ((PartDiversionTransporter)transporter).modes[pos.sideHit]; ForgeDirection side = ForgeDirection.getOrientation(pos.sideHit); - + pushTransporter(); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F); - + CCRenderState.changeTexture(mode == 0 ? MekanismRenderer.getItemsTexture() : MekanismRenderer.getBlocksTexture()); GL11.glTranslatef((float)vec.x, (float)vec.y, (float)vec.z); GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); - + int display = getOverlayDisplay(world, side, mode).display; GL11.glCallList(display); - + popTransporter(); } } } - + GL11.glPopMatrix(); } - + public void renderContents(PartUniversalCable cable, Vector3 pos) { if(cable.currentPower == 0) { return; } - + GL11.glPushMatrix(); CCRenderState.reset(); CCRenderState.useNormals(true); CCRenderState.useModelColours(true); CCRenderState.startDrawing(7); GL11.glTranslated(pos.x, pos.y, pos.z); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { renderEnergySide(side, cable); } - + MekanismRenderer.glowOn(); MekanismRenderer.cullFrontFace(); @@ -261,14 +261,14 @@ public class RenderPartTransmitter implements IIconRegister MekanismRenderer.disableCullFace(); MekanismRenderer.glowOff(); - + GL11.glPopMatrix(); } - + public void renderContents(PartMechanicalPipe pipe, Vector3 pos) { float targetScale = pipe.getTransmitterNetwork().fluidScale; - + if(Math.abs(pipe.currentScale - targetScale) > 0.01) { pipe.currentScale = (12 * pipe.currentScale + targetScale) / 13; @@ -276,27 +276,27 @@ public class RenderPartTransmitter implements IIconRegister else { pipe.currentScale = targetScale; } - + Fluid fluid = pipe.getTransmitterNetwork().refFluid; float scale = pipe.currentScale; - + if(scale > 0.01 && fluid != null) - { + { push(); - + MekanismRenderer.glowOn(fluid.getLuminosity()); - + CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); GL11.glTranslated(pos.x, pos.y, pos.z); - + boolean gas = fluid.isGaseous(); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if(pipe.getConnectionType(side) == ConnectionType.NORMAL) { DisplayInteger[] displayLists = getListAndRender(side, fluid); - + if(displayLists != null) { if(!gas) @@ -317,9 +317,9 @@ public class RenderPartTransmitter implements IIconRegister GL11.glCullFace(GL11.GL_BACK); } } - + DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, fluid); - + if(displayLists != null) { if(!gas) @@ -331,35 +331,35 @@ public class RenderPartTransmitter implements IIconRegister displayLists[stages-1].render(); } } - + MekanismRenderer.glowOff(); - + pop(); } - + } - + private DisplayInteger[] getListAndRender(ForgeDirection side, Fluid fluid) { if(side == null || fluid == null || fluid.getIcon() == null) { return null; } - + if(cachedLiquids.containsKey(side) && cachedLiquids.get(side).containsKey(fluid)) { return cachedLiquids.get(side).get(fluid); } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.waterStill; toReturn.setTexture(fluid.getIcon()); - + toReturn.setSideRender(side, false); toReturn.setSideRender(side.getOpposite(), false); - + DisplayInteger[] displays = new DisplayInteger[stages]; - + if(cachedLiquids.containsKey(side)) { cachedLiquids.get(side).put(fluid, displays); @@ -369,13 +369,13 @@ public class RenderPartTransmitter implements IIconRegister map.put(fluid, displays); cachedLiquids.put(side, map); } - + MekanismRenderer.colorFluid(fluid); - + for(int i = 0; i < stages; i++) { displays[i] = DisplayInteger.createAndStart(); - + switch(side) { case UNKNOWN: @@ -383,7 +383,7 @@ public class RenderPartTransmitter implements IIconRegister toReturn.minX = 0.25 + offset; toReturn.minY = 0.25 + offset; toReturn.minZ = 0.25 + offset; - + toReturn.maxX = 0.75 - offset; toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; toReturn.maxZ = 0.75 - offset; @@ -394,7 +394,7 @@ public class RenderPartTransmitter implements IIconRegister toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2; toReturn.minY = 0.0; toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2; - + toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2; toReturn.maxY = 0.25 + offset; toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2; @@ -405,7 +405,7 @@ public class RenderPartTransmitter implements IIconRegister toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2; toReturn.minY = 0.25 - offset + ((float)i / (float)stages)*height; toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2; - + toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2; toReturn.maxY = 1.0; toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2; @@ -416,7 +416,7 @@ public class RenderPartTransmitter implements IIconRegister toReturn.minX = 0.25 + offset; toReturn.minY = 0.25 + offset; toReturn.minZ = 0.0; - + toReturn.maxX = 0.75 - offset; toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; toReturn.maxZ = 0.25 + offset; @@ -427,7 +427,7 @@ public class RenderPartTransmitter implements IIconRegister toReturn.minX = 0.25 + offset; toReturn.minY = 0.25 + offset; toReturn.minZ = 0.75 - offset; - + toReturn.maxX = 0.75 - offset; toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; toReturn.maxZ = 1.0; @@ -438,7 +438,7 @@ public class RenderPartTransmitter implements IIconRegister toReturn.minX = 0.0; toReturn.minY = 0.25 + offset; toReturn.minZ = 0.25 + offset; - + toReturn.maxX = 0.25 + offset; toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; toReturn.maxZ = 0.75 - offset; @@ -449,20 +449,20 @@ public class RenderPartTransmitter implements IIconRegister toReturn.minX = 0.75 - offset; toReturn.minY = 0.25 + offset; toReturn.minZ = 0.25 + offset; - + toReturn.maxX = 1.0; toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; toReturn.maxZ = 0.75 - offset; break; } } - + MekanismRenderer.renderObject(toReturn); displays[i].endList(); } - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - + return displays; } @@ -472,54 +472,54 @@ public class RenderPartTransmitter implements IIconRegister { return; } - + GL11.glPushMatrix(); CCRenderState.reset(); CCRenderState.useNormals(true); CCRenderState.useModelColours(true); CCRenderState.startDrawing(7); GL11.glTranslated(pos.x, pos.y, pos.z); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { renderGasSide(side, tube); } - + MekanismRenderer.glowOn(0); MekanismRenderer.cullFrontFace(); CCRenderState.draw(); - + MekanismRenderer.disableCullFace(); MekanismRenderer.glowOff(); GL11.glPopMatrix(); } - + public void renderStatic(PartSidedPipe transmitter, LazyLightMatrix olm) { TextureUtils.bindAtlas(0); CCRenderState.reset(); CCRenderState.useModelColours(true); CCRenderState.setBrightness(transmitter.world(), transmitter.x(), transmitter.y(), transmitter.z()); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { renderSide(side, transmitter, olm); } } - + public void renderSide(ForgeDirection side, PartSidedPipe transmitter, LazyLightMatrix olm) { boolean connected = PartTransmitter.connectionMapContainsSide(transmitter.getAllCurrentConnections(), side); Icon renderIcon = transmitter.getIconForSide(side); - + Colour c = null; - + if(transmitter.getRenderColor() != null) { c = new ColourRGBA(transmitter.getRenderColor().getColor(0), transmitter.getRenderColor().getColor(1), transmitter.getRenderColor().getColor(2), 1); } - + renderPart(renderIcon, transmitter.getModelForSide(side, false), transmitter.x(), transmitter.y(), transmitter.z(), c, olm); } @@ -537,7 +537,7 @@ public class RenderPartTransmitter implements IIconRegister CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); renderTransparency(MekanismRenderer.energyIcon, cable.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower)); } - + public void renderFluidInOut(ForgeDirection side, PartMechanicalPipe pipe) { CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); @@ -550,15 +550,15 @@ public class RenderPartTransmitter implements IIconRegister renderTransparency(tube.getTransmitterNetwork().refGas.getIcon(), tube.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale)); } - public void renderPart(Icon icon, CCModel cc, double x, double y, double z, Colour color, LazyLightMatrix olm) + public void renderPart(Icon icon, CCModel cc, double x, double y, double z, Colour color, LazyLightMatrix olm) { - cc.render(0, cc.verts.length, new Translation(x, y, z), new IconTransformation(icon), new TransmitterTransformation(color, null)); - } + cc.render(0, cc.verts.length, new Translation(x, y, z), new IconTransformation(icon), new TransmitterTransformation(color, null)); + } - public void renderTransparency(Icon icon, CCModel cc, Colour colour) - { - cc.render(0, cc.verts.length, new Translation(0, 0, 0), new IconTransformation(icon), new ColourMultiplier(colour)); - } + public void renderTransparency(Icon icon, CCModel cc, Colour colour) + { + cc.render(0, cc.verts.length, new Translation(0, 0, 0), new IconTransformation(icon), new ColourMultiplier(colour)); + } public CCModel getItemModel(ForgeDirection side, TransmitterType type) { @@ -589,7 +589,7 @@ public class RenderPartTransmitter implements IIconRegister { return 0; } - + private void popTransporter() { GL11.glPopAttrib(); @@ -597,7 +597,7 @@ public class RenderPartTransmitter implements IIconRegister MekanismRenderer.blendOff(); GL11.glPopMatrix(); } - + private void pushTransporter() { GL11.glPushMatrix(); @@ -607,16 +607,16 @@ public class RenderPartTransmitter implements IIconRegister MekanismRenderer.glowOn(); MekanismRenderer.blendOn(); } - + private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, int mode) { if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(mode)) { return cachedOverlays.get(side).get(mode); } - + Icon icon = null; - + switch(mode) { case 0: @@ -629,13 +629,13 @@ public class RenderPartTransmitter implements IIconRegister icon = Block.torchRedstoneIdle.getIcon(0, 0); break; } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.stone; toReturn.setTexture(icon); - + DisplayInteger display = DisplayInteger.createAndStart(); - + if(cachedOverlays.containsKey(side)) { cachedOverlays.get(side).put(mode, display); @@ -645,14 +645,14 @@ public class RenderPartTransmitter implements IIconRegister map.put(mode, display); cachedOverlays.put(side, map); } - + switch(side) { case DOWN: { toReturn.minY = -0.01; toReturn.maxY = 0; - + toReturn.minX = 0; toReturn.minZ = 0; toReturn.maxX = 1; @@ -663,7 +663,7 @@ public class RenderPartTransmitter implements IIconRegister { toReturn.minY = 1; toReturn.maxY = 1.01; - + toReturn.minX = 0; toReturn.minZ = 0; toReturn.maxX = 1; @@ -674,7 +674,7 @@ public class RenderPartTransmitter implements IIconRegister { toReturn.minZ = -0.01; toReturn.maxZ = 0; - + toReturn.minX = 0; toReturn.minY = 0; toReturn.maxX = 1; @@ -685,7 +685,7 @@ public class RenderPartTransmitter implements IIconRegister { toReturn.minZ = 1; toReturn.maxZ = 1.01; - + toReturn.minX = 0; toReturn.minY = 0; toReturn.maxX = 1; @@ -696,7 +696,7 @@ public class RenderPartTransmitter implements IIconRegister { toReturn.minX = -0.01; toReturn.maxX = 0; - + toReturn.minY = 0; toReturn.minZ = 0; toReturn.maxY = 1; @@ -707,7 +707,7 @@ public class RenderPartTransmitter implements IIconRegister { toReturn.minX = 1; toReturn.maxX = 1.01; - + toReturn.minY = 0; toReturn.minZ = 0; toReturn.maxY = 1; @@ -719,31 +719,31 @@ public class RenderPartTransmitter implements IIconRegister break; } } - + MekanismRenderer.renderObject(toReturn); display.endList(); - + return display; } - + public static class TransmitterTransformation implements IVertexModifier { public ColourMultiplier colour; public LightMatrix lightMatrix; - + public TransmitterTransformation(Colour color, LazyLightMatrix olm) { if(color != null) { colour = new ColourMultiplier(color); } - + if(olm != null) { lightMatrix = olm.lightMatrix(); } } - + @Override public void applyModifiers(CCModel m, Tessellator tess, Vector3 vec, UV uv, Vector3 normal, int i) { @@ -751,7 +751,7 @@ public class RenderPartTransmitter implements IIconRegister { colour.applyModifiers(m, tess, vec, uv, normal, i); } - + if(lightMatrix != null) { lightMatrix.applyModifiers(m, tess, vec, uv, normal, i); diff --git a/common/mekanism/client/render/RenderTickHandler.java b/common/mekanism/client/render/RenderTickHandler.java index 3d21d673b..33907603b 100644 --- a/common/mekanism/client/render/RenderTickHandler.java +++ b/common/mekanism/client/render/RenderTickHandler.java @@ -34,36 +34,36 @@ public class RenderTickHandler implements ITickHandler { public Random rand = new Random(); public Minecraft mc = Minecraft.getMinecraft(); - + @Override public void tickStart(EnumSet type, Object... tickData) {} @Override - public void tickEnd(EnumSet type, Object... tickData) + public void tickEnd(EnumSet type, Object... tickData) { float partialTick = (Float)tickData[0]; - + if(mc.thePlayer != null && mc.theWorld != null) { EntityPlayer player = mc.thePlayer; World world = mc.thePlayer.worldObj; - + FontRenderer font = mc.fontRenderer; - + MovingObjectPosition pos = player.rayTrace(40.0D, 1.0F); - + if(pos != null) { int x = MathHelper.floor_double(pos.blockX); int y = MathHelper.floor_double(pos.blockY); int z = MathHelper.floor_double(pos.blockZ); - + Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId); - + if(Mekanism.debug && mc.currentScreen == null && !mc.gameSettings.showDebugInfo) { String tileDisplay = ""; - + if(obj.getTileEntity(world) != null) { if(obj.getTileEntity(world).getClass() != null) @@ -71,7 +71,7 @@ public class RenderTickHandler implements ITickHandler tileDisplay = obj.getTileEntity(world).getClass().getSimpleName(); } } - + font.drawStringWithShadow("Block ID: " + obj.getBlockId(world), 1, 1, 0x404040); font.drawStringWithShadow("Metadata: " + obj.getMetadata(world), 1, 10, 0x404040); font.drawStringWithShadow("Location: " + MekanismUtils.getCoordDisplay(obj), 1, 19, 0x404040); @@ -79,20 +79,20 @@ public class RenderTickHandler implements ITickHandler font.drawStringWithShadow("Side: " + pos.sideHit, 1, 37, 0x404040); } } - + if(player != null && !(mc.currentScreen instanceof GuiChat) && player.getCurrentItemOrArmor(3) != null) { ItemStack stack = player.getCurrentItemOrArmor(3); - + ScaledResolution scaledresolution = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight); - + int x = scaledresolution.getScaledWidth(); int y = scaledresolution.getScaledHeight(); - + if(stack.getItem() instanceof ItemJetpack) { ItemJetpack jetpack = (ItemJetpack)stack.getItem(); - + font.drawStringWithShadow("Mode: " + jetpack.getMode(stack).getName(), 1, y - 20, 0x404040); font.drawStringWithShadow("Hydrogen: " + jetpack.getStored(stack), 1, y - 11, 0x404040); } @@ -100,79 +100,79 @@ public class RenderTickHandler implements ITickHandler { ItemScubaTank scubaTank = (ItemScubaTank)stack.getItem(); String state = (scubaTank.getFlowing(stack) ? EnumColor.DARK_GREEN + "On" : EnumColor.DARK_RED + "Off"); - + font.drawStringWithShadow("Mode: " + state, 1, y - 20, 0x404040); font.drawStringWithShadow("Oxygen: " + scubaTank.getStored(stack), 1, y - 11, 0x404040); } } - + Set copy = (Set)((HashSet)Mekanism.jetpackOn).clone(); - + for(String s : copy) { EntityPlayer p = mc.theWorld.getPlayerEntityByName(s); - + if(p == null) { continue; } - + Pos3D playerPos = new Pos3D(p); - + if(p != mc.thePlayer) { playerPos.translate(0, 1.7, 0); } - + float random = (rand.nextFloat()-0.5F)*0.1F; - + Pos3D vLeft = new Pos3D(); vLeft.xPos -= 0.43; vLeft.yPos -= 0.55; vLeft.zPos -= 0.54; vLeft.rotateYaw(p.renderYawOffset); - + Pos3D vRight = new Pos3D(); vRight.xPos += 0.43; vRight.yPos -= 0.55; vRight.zPos -= 0.54; vRight.rotateYaw(p.renderYawOffset); - + Pos3D vCenter = new Pos3D(); vCenter.xPos = (rand.nextFloat()-0.5F)*0.4F; vCenter.yPos -= 0.86; vCenter.zPos -= 0.30; vCenter.rotateYaw(p.renderYawOffset); - + Pos3D rLeft = vLeft.clone().scale(random); Pos3D rRight = vRight.clone().scale(random); - + Pos3D mLeft = vLeft.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); Pos3D mRight = vRight.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); Pos3D mCenter = vCenter.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); - + mLeft.translate(rLeft); mRight.translate(rRight); - + Pos3D v = playerPos.clone().translate(vLeft); spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mLeft.xPos, mLeft.yPos, mLeft.zPos); spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mLeft.xPos, mLeft.yPos, mLeft.zPos); - + v = playerPos.clone().translate(vRight); spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mRight.xPos, mRight.yPos, mRight.zPos); spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mRight.xPos, mRight.yPos, mRight.zPos); - + v = playerPos.clone().translate(vCenter); spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mCenter.xPos, mCenter.yPos, mCenter.zPos); spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mCenter.xPos, mCenter.yPos, mCenter.zPos); } } } - + public void spawnAndSetParticle(String s, World world, double x, double y, double z, double velX, double velY, double velZ) { EntityFX fx = null; - + if(s.equals("flame")) { fx = new EntityFlameFX(world, x, y, z, velX, velY, velZ); @@ -181,18 +181,18 @@ public class RenderTickHandler implements ITickHandler { fx = new EntitySmokeFX(world, x, y, z, velX, velY, velZ); } - + mc.effectRenderer.addEffect(fx); } @Override - public EnumSet ticks() + public EnumSet ticks() { return EnumSet.of(TickType.RENDER); } @Override - public String getLabel() + public String getLabel() { return "MekanismRender"; } diff --git a/common/mekanism/client/render/block/BasicRenderingHandler.java b/common/mekanism/client/render/block/BasicRenderingHandler.java index 64d6bdd83..5ab74d316 100644 --- a/common/mekanism/client/render/block/BasicRenderingHandler.java +++ b/common/mekanism/client/render/block/BasicRenderingHandler.java @@ -19,15 +19,15 @@ public class BasicRenderingHandler implements ISimpleBlockRenderingHandler @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - - if(block.blockID == Mekanism.basicBlockID || block.blockID == Mekanism.basicBlock2ID) - { - MekanismRenderer.renderItem(renderer, metadata, block); - } - - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + + if(block.blockID == Mekanism.basicBlockID || block.blockID == Mekanism.basicBlock2ID) + { + MekanismRenderer.renderItem(renderer, metadata, block); + } + + GL11.glPopMatrix(); } @Override @@ -36,24 +36,24 @@ public class BasicRenderingHandler implements ISimpleBlockRenderingHandler if(block.blockID == Mekanism.basicBlockID || block.blockID == Mekanism.basicBlock2ID) { int metadata = world.getBlockMetadata(x, y, z); - + renderer.renderStandardBlock(block, x, y, z); renderer.setRenderBoundsFromBlock(block); - + return true; } - + return false; } @Override - public boolean shouldRender3DInInventory() + public boolean shouldRender3DInInventory() { return true; } @Override - public int getRenderId() + public int getRenderId() { return ClientProxy.BASIC_RENDER_ID; } diff --git a/common/mekanism/client/render/block/MachineRenderingHandler.java b/common/mekanism/client/render/block/MachineRenderingHandler.java index 63b81aa3b..28d554904 100644 --- a/common/mekanism/client/render/block/MachineRenderingHandler.java +++ b/common/mekanism/client/render/block/MachineRenderingHandler.java @@ -51,27 +51,27 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler { return; } - - GL11.glPushMatrix(); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - - MachineType type = MachineType.get(block.blockID, metadata); - + + GL11.glPushMatrix(); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + + MachineType type = MachineType.get(block.blockID, metadata); + if(type == MachineType.ELECTRIC_PUMP) { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.85F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricPump.png")); - electricPump.render(0.0560F); + GL11.glTranslatef(0.0F, -0.85F, 0.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricPump.png")); + electricPump.render(0.0560F); } else if(type == MachineType.METALLURGIC_INFUSER) { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "MetallurgicInfuser.png")); - metallurgicInfuser.render(0.0625F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "MetallurgicInfuser.png")); + metallurgicInfuser.render(0.0625F); } else if(type == MachineType.CHARGEPAD) { @@ -84,32 +84,32 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.85F, -0.15F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter.png")); - logisticalSorter.render(0.0625F, false); + GL11.glTranslatef(0.0F, -0.85F, -0.15F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter.png")); + logisticalSorter.render(0.0625F, false); } else if(type == MachineType.DIGITAL_MINER) { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.2F, -0.3F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner.png")); - digitalMiner.render(0.03125F, false); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner.png")); + digitalMiner.render(0.03125F, false); } else if(type == MachineType.ROTARY_CONDENSENTRATOR) { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.06F, 0.05F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png")); + GL11.glTranslatef(0.0F, -1.06F, 0.05F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png")); rotaryCondensentrator.render(0.0625F); } else if(type == MachineType.CHEMICAL_OXIDIZER) { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.06F, 0.05F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalOxidizer.png")); + GL11.glTranslatef(0.0F, -1.06F, 0.05F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalOxidizer.png")); chemicalOxidizer.render(0.0625F); chemicalOxidizer.renderGlass(0.0625F); } @@ -117,8 +117,8 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.06F, 0.05F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalInfuser.png")); + GL11.glTranslatef(0.0F, -1.06F, 0.05F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalInfuser.png")); chemicalInfuser.render(0.0625F); chemicalInfuser.renderGlass(0.0625F); } @@ -133,38 +133,38 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.06F, 0.05F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalDissolutionChamber.png")); + GL11.glTranslatef(0.0F, -1.06F, 0.05F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalDissolutionChamber.png")); chemicalDissolutionChamber.render(0.0625F); } else if(type == MachineType.CHEMICAL_WASHER) { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.06F, 0.05F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalWasher.png")); + GL11.glTranslatef(0.0F, -1.06F, 0.05F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalWasher.png")); chemicalWasher.render(0.0625F); } else if(type == MachineType.CHEMICAL_CRYSTALIZER) { GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.06F, 0.05F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalCrystalizer.png")); + GL11.glTranslatef(0.0F, -1.06F, 0.05F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalCrystalizer.png")); chemicalCrystalizer.render(0.0625F); } else { - MekanismRenderer.renderItem(renderer, metadata, block); + MekanismRenderer.renderItem(renderer, metadata, block); } - - GL11.glPopMatrix(); + + GL11.glPopMatrix(); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { int metadata = world.getBlockMetadata(x, y, z); - + if(MachineType.get(block.blockID, metadata) != null) { if(!MachineType.get(block.blockID, metadata).hasModel) @@ -174,18 +174,18 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler return true; } } - + return false; } @Override - public boolean shouldRender3DInInventory() + public boolean shouldRender3DInInventory() { return true; } @Override - public int getRenderId() + public int getRenderId() { return ClientProxy.MACHINE_RENDER_ID; } diff --git a/common/mekanism/client/render/entity/RenderBalloon.java b/common/mekanism/client/render/entity/RenderBalloon.java index 7e00b6f88..880a3369f 100644 --- a/common/mekanism/client/render/entity/RenderBalloon.java +++ b/common/mekanism/client/render/entity/RenderBalloon.java @@ -20,11 +20,11 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderBalloon extends Render { private Minecraft mc = Minecraft.getMinecraft(); - + public ModelBalloon model = new ModelBalloon(); - + @Override - protected ResourceLocation getEntityTexture(Entity entity) + protected ResourceLocation getEntityTexture(Entity entity) { return MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png"); } @@ -33,34 +33,34 @@ public class RenderBalloon extends Render public void doRender(Entity entity, double x, double y, double z, float f, float partialTick) { EntityBalloon balloon = (EntityBalloon)entity; - + if(balloon.isLatchedToEntity()) { x = (balloon.latchedEntity.lastTickPosX + (balloon.latchedEntity.posX - balloon.latchedEntity.lastTickPosX)*partialTick); y = (balloon.latchedEntity.lastTickPosY + (balloon.latchedEntity.posY - balloon.latchedEntity.lastTickPosY)*partialTick); z = (balloon.latchedEntity.lastTickPosZ + (balloon.latchedEntity.posZ - balloon.latchedEntity.lastTickPosZ)*partialTick); - + x -= RenderManager.renderPosX; y -= RenderManager.renderPosY; z -= RenderManager.renderPosZ; - + y += balloon.latchedEntity.height + 1.7F; } - + render(((EntityBalloon)entity).color, x, y, z); } - + public void render(EnumColor color, double x, double y, double z) { GL11.glPushMatrix(); GL11.glTranslated(x, y, z); GL11.glRotatef(180, 1, 0, 0); GL11.glTranslatef(0, 0.9F, 0); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png")); - + model.render(0.0625F, color); - + GL11.glPopMatrix(); } } diff --git a/common/mekanism/client/render/entity/RenderObsidianTNTPrimed.java b/common/mekanism/client/render/entity/RenderObsidianTNTPrimed.java index 7eab21c85..5140ef515 100644 --- a/common/mekanism/client/render/entity/RenderObsidianTNTPrimed.java +++ b/common/mekanism/client/render/entity/RenderObsidianTNTPrimed.java @@ -20,70 +20,70 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderObsidianTNTPrimed extends Render { - private RenderBlocks blockRenderer = new RenderBlocks(); + private RenderBlocks blockRenderer = new RenderBlocks(); private ModelObsidianTNT model = new ModelObsidianTNT(); - public RenderObsidianTNTPrimed() - { - shadowSize = 0.5F; - } - - @Override - public void doRender(Entity entity, double x, double y, double z, float f, float f1) - { - renderObsidianTNT((EntityObsidianTNT)entity, x, y, z, f, f1); - } + public RenderObsidianTNTPrimed() + { + shadowSize = 0.5F; + } - public void renderObsidianTNT(EntityObsidianTNT entityobsidiantnt, double x, double y, double z, float f, float f1) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x, (float)y+1.2F, (float)z); - GL11.glScalef(0.8F, 0.8F, 0.8F); - GL11.glRotatef(180, 1, 0, 0); + @Override + public void doRender(Entity entity, double x, double y, double z, float f, float f1) + { + renderObsidianTNT((EntityObsidianTNT)entity, x, y, z, f, f1); + } - if((entityobsidiantnt.fuse - f1) + 1.0F < 10F) - { - float scale = 1.0F - ((entityobsidiantnt.fuse - f1) + 1.0F) / 10F; + public void renderObsidianTNT(EntityObsidianTNT entityobsidiantnt, double x, double y, double z, float f, float f1) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x, (float)y+1.2F, (float)z); + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glRotatef(180, 1, 0, 0); - if(scale < 0.0F) - { - scale = 0.0F; - } + if((entityobsidiantnt.fuse - f1) + 1.0F < 10F) + { + float scale = 1.0F - ((entityobsidiantnt.fuse - f1) + 1.0F) / 10F; - if(scale > 1.0F) - { - scale = 1.0F; - } + if(scale < 0.0F) + { + scale = 0.0F; + } - scale *= scale; - scale *= scale; - float renderScale = 1.0F + scale * 0.3F; - GL11.glScalef(renderScale, renderScale, renderScale); - } + if(scale > 1.0F) + { + scale = 1.0F; + } - float f3 = (1.0F - ((entityobsidiantnt.fuse - f1) + 1.0F) / 100F) * 0.8F; + scale *= scale; + scale *= scale; + float renderScale = 1.0F + scale * 0.3F; + GL11.glScalef(renderScale, renderScale, renderScale); + } + + float f3 = (1.0F - ((entityobsidiantnt.fuse - f1) + 1.0F) / 100F) * 0.8F; bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png")); model.render(0.0625F); - if(entityobsidiantnt.fuse / 5 % 2 == 0) - { - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f3); - model.render(0.0625F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } + if(entityobsidiantnt.fuse / 5 % 2 == 0) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f3); + model.render(0.0625F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } @Override - protected ResourceLocation getEntityTexture(Entity entity) + protected ResourceLocation getEntityTexture(Entity entity) { return TextureMap.locationBlocksTexture; } diff --git a/common/mekanism/client/render/entity/RenderRobit.java b/common/mekanism/client/render/entity/RenderRobit.java index 664221ad3..d585102a2 100644 --- a/common/mekanism/client/render/entity/RenderRobit.java +++ b/common/mekanism/client/render/entity/RenderRobit.java @@ -13,16 +13,16 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderRobit extends RenderLiving { - public RenderRobit() + public RenderRobit() { super(new ModelRobit(), 0.5F); } @Override - protected ResourceLocation getEntityTexture(Entity entity) + protected ResourceLocation getEntityTexture(Entity entity) { EntityRobit robit = (EntityRobit)entity; - + if((Math.abs(entity.posX-entity.prevPosX) + Math.abs(entity.posX-entity.prevPosX)) > 0.001) { if(robit.ticksExisted % 3 == 0) @@ -30,7 +30,7 @@ public class RenderRobit extends RenderLiving robit.texTick = !robit.texTick; } } - + return MekanismUtils.getResource(ResourceType.RENDER, "Robit" + (robit.texTick ? "2" : "") + ".png"); } } diff --git a/common/mekanism/client/render/item/ItemRenderingHandler.java b/common/mekanism/client/render/item/ItemRenderingHandler.java index bac909f2b..23d446834 100644 --- a/common/mekanism/client/render/item/ItemRenderingHandler.java +++ b/common/mekanism/client/render/item/ItemRenderingHandler.java @@ -76,11 +76,11 @@ public class ItemRenderingHandler implements IItemRenderer public ModelScubaTank scubaTank = new ModelScubaTank(); public ModelFreeRunners freeRunners = new ModelFreeRunners(); public ModelAtomicDisassembler atomicDisassembler = new ModelAtomicDisassembler(); - + private final RenderBalloon balloonRenderer = new RenderBalloon(); private final RenderBin binRenderer = (RenderBin)TileEntityRenderer.instance.specialRendererMap.get(TileEntityBin.class); - private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class); - + private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class); + @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { @@ -88,7 +88,7 @@ public class ItemRenderingHandler implements IItemRenderer { return type != ItemRenderType.INVENTORY; } - + return true; } @@ -99,182 +99,182 @@ public class ItemRenderingHandler implements IItemRenderer } @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { RenderBlocks renderBlocks = (RenderBlocks)data[0]; - - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) - { - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - + + if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) + { + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + if(item.getItem() instanceof IEnergyCube) { EnergyCubeTier tier = ((IEnergyCube)item.getItem()).getEnergyCubeTier(item); IEnergizedItem energized = (IEnergizedItem)item.getItem(); Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube" + tier.name + ".png")); - + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + energyCube.render(0.0625F); - - GL11.glPushMatrix(); - GL11.glTranslated(0.0, 1.0, 0.0); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png")); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glPushMatrix(); + GL11.glTranslated(0.0, 1.0, 0.0); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png")); - MekanismRenderer.glowOn(); - - EnumColor c = tier.color; + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glPushMatrix(); - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), (float)(energized.getEnergy(item)/energized.getMaxEnergy(item))); - GL11.glTranslatef(0, (float)Math.sin(Math.toRadians((MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 3)) / 7, 0); - GL11.glRotatef((MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 4, 0, 1, 0); - GL11.glRotatef(36F + (MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 4, 0, 1, 1); - energyCore.render(0.0625F); - GL11.glPopMatrix(); + MekanismRenderer.glowOn(); - MekanismRenderer.glowOff(); + EnumColor c = tier.color; - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glDisable(GL11.GL_LINE_SMOOTH); - GL11.glDisable(GL11.GL_POLYGON_SMOOTH); - GL11.glDisable(GL11.GL_BLEND); + GL11.glPushMatrix(); + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), (float)(energized.getEnergy(item)/energized.getMaxEnergy(item))); + GL11.glTranslatef(0, (float)Math.sin(Math.toRadians((MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 3)) / 7, 0); + GL11.glRotatef((MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 4, 0, 1, 0); + GL11.glRotatef(36F + (MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 4, 0, 1, 1); + energyCore.render(0.0625F); + GL11.glPopMatrix(); - GL11.glPopMatrix(); + MekanismRenderer.glowOff(); + + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_POLYGON_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + + GL11.glPopMatrix(); } else if(item.getItem() instanceof ItemBlockBasic && item.getItemDamage() == 6) { RenderingRegistry.instance().renderInventoryBlock((RenderBlocks)data[0], Block.blocksList[Mekanism.basicBlockID], item.getItemDamage(), ClientProxy.BASIC_RENDER_ID); - + if(binRenderer == null || binRenderer.getFontRenderer() == null) { return; } - + InventoryBin inv = new InventoryBin(item); ForgeDirection side = ForgeDirection.getOrientation(2); - - String amount = ""; - ItemStack itemStack = inv.getStack(); - if(itemStack != null) - { - amount = Integer.toString(inv.getItemCount()); - } + String amount = ""; + ItemStack itemStack = inv.getStack(); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + if(itemStack != null) + { + amount = Integer.toString(inv.getItemCount()); + } - if(itemStack != null) - { - GL11.glPushMatrix(); - - if(!(itemStack.getItem() instanceof ItemBlock) || Block.blocksList[itemStack.itemID].getRenderType() != 0) - { - GL11.glRotatef(180, 0, 0, 1); - GL11.glTranslatef(-1.02F, -0.2F, 0); - - if(type == ItemRenderType.INVENTORY) - { - GL11.glTranslatef(-0.45F, -0.4F, 0.0F); - } - } - - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.ENTITY) - { - GL11.glTranslatef(-0.22F, -0.2F, -0.22F); - } + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GL11.glTranslated(0.73, 0.08, 0.44); - GL11.glRotatef(90, 0, 1, 0); + if(itemStack != null) + { + GL11.glPushMatrix(); - float scale = 0.03125F; - float scaler = 0.9F; - - GL11.glScalef(scale*scaler, scale*scaler, 0); + if(!(itemStack.getItem() instanceof ItemBlock) || Block.blocksList[itemStack.itemID].getRenderType() != 0) + { + GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslatef(-1.02F, -0.2F, 0); - TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; + if(type == ItemRenderType.INVENTORY) + { + GL11.glTranslatef(-0.45F, -0.4F, 0.0F); + } + } - GL11.glDisable(GL11.GL_LIGHTING); - - renderItem.renderItemAndEffectIntoGUI(binRenderer.getFontRenderer(), renderEngine, itemStack, 0, 0); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(amount != "") - { - float maxScale = 0.02F; - - GL11.glPushMatrix(); - - GL11.glPolygonOffset(-10, -10); - GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); - - float displayWidth = 1 - (2 / 16); - float displayHeight = 1 - (2 / 16); - GL11.glTranslatef(0, -0.31F, 0); - - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.ENTITY) - { - GL11.glTranslated(-0.5, -0.4, -0.5); - } - - GL11.glTranslatef(0, 0.9F, 1); - GL11.glRotatef(90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - - GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); - GL11.glRotatef(-90, 1, 0, 0); - - FontRenderer fontRenderer = binRenderer.getFontRenderer(); - - int requiredWidth = Math.max(fontRenderer.getStringWidth(amount), 1); - int lineHeight = fontRenderer.FONT_HEIGHT + 2; - int requiredHeight = lineHeight * 1; - float scaler = 0.4F; - float scaleX = (displayWidth / requiredWidth); - float scale = scaleX * scaler; - - if(maxScale > 0) - { - scale = Math.min(scale, maxScale); - } - - GL11.glScalef(scale, -scale, scale); - GL11.glDepthMask(false); - - int offsetX; - int offsetY; - int realHeight = (int)Math.floor(displayHeight / scale); - int realWidth = (int)Math.floor(displayWidth / scale); - - offsetX = (realWidth - requiredWidth) / 2; - offsetY = (realHeight - requiredHeight) / 2; - - GL11.glDisable(GL11.GL_LIGHTING); - fontRenderer.drawString("\u00a7f" + amount, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); - - GL11.glPopMatrix(); - } + if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.ENTITY) + { + GL11.glTranslatef(-0.22F, -0.2F, -0.22F); + } + + GL11.glTranslated(0.73, 0.08, 0.44); + GL11.glRotatef(90, 0, 1, 0); + + float scale = 0.03125F; + float scaler = 0.9F; + + GL11.glScalef(scale*scaler, scale*scaler, 0); + + TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; + + GL11.glDisable(GL11.GL_LIGHTING); + + renderItem.renderItemAndEffectIntoGUI(binRenderer.getFontRenderer(), renderEngine, itemStack, 0, 0); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + if(amount != "") + { + float maxScale = 0.02F; + + GL11.glPushMatrix(); + + GL11.glPolygonOffset(-10, -10); + GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); + + float displayWidth = 1 - (2 / 16); + float displayHeight = 1 - (2 / 16); + GL11.glTranslatef(0, -0.31F, 0); + + if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.ENTITY) + { + GL11.glTranslated(-0.5, -0.4, -0.5); + } + + GL11.glTranslatef(0, 0.9F, 1); + GL11.glRotatef(90, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + + GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); + GL11.glRotatef(-90, 1, 0, 0); + + FontRenderer fontRenderer = binRenderer.getFontRenderer(); + + int requiredWidth = Math.max(fontRenderer.getStringWidth(amount), 1); + int lineHeight = fontRenderer.FONT_HEIGHT + 2; + int requiredHeight = lineHeight * 1; + float scaler = 0.4F; + float scaleX = (displayWidth / requiredWidth); + float scale = scaleX * scaler; + + if(maxScale > 0) + { + scale = Math.min(scale, maxScale); + } + + GL11.glScalef(scale, -scale, scale); + GL11.glDepthMask(false); + + int offsetX; + int offsetY; + int realHeight = (int)Math.floor(displayHeight / scale); + int realWidth = (int)Math.floor(displayWidth / scale); + + offsetX = (realWidth - requiredWidth) / 2; + offsetY = (realHeight - requiredHeight) / 2; + + GL11.glDisable(GL11.GL_LIGHTING); + fontRenderer.drawString("\u00a7f" + amount, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + + GL11.glPopMatrix(); + } } else if(item.itemID == Mekanism.gasTankID) { Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasTank.png")); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); gasTank.render(0.0625F); } else if(item.itemID == Mekanism.obsidianTNTID) @@ -282,7 +282,7 @@ public class ItemRenderingHandler implements IItemRenderer Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png")); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); obsidianTNT.render(0.0625F); } else if(item.getItem() instanceof ItemWalkieTalkie) @@ -291,9 +291,9 @@ public class ItemRenderingHandler implements IItemRenderer { MekanismRenderer.glowOn(); } - + MekanismRenderer.renderItem(item); - + if(((ItemWalkieTalkie)item.getItem()).getOn(item)) { MekanismRenderer.glowOff(); @@ -302,20 +302,20 @@ public class ItemRenderingHandler implements IItemRenderer else if(MachineType.get(item) == MachineType.ELECTRIC_CHEST) { IElectricChest chest = (IElectricChest)item.getItem(); - + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glTranslatef(0, 1.0F, 1.0F); - GL11.glScalef(1.0F, -1F, -1F); - - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricChest.png")); - + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glTranslatef(0, 1.0F, 1.0F); + GL11.glScalef(1.0F, -1F, -1F); + + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricChest.png")); + float lidangle = chest.getPrevLidAngle(item) + (chest.getLidAngle(item) - chest.getPrevLidAngle(item)) * MekanismRenderer.getPartialTick(); - lidangle = 1.0F - lidangle; - lidangle = 1.0F - lidangle * lidangle * lidangle; - electricChest.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); - - electricChest.renderAll(); + lidangle = 1.0F - lidangle; + lidangle = 1.0F - lidangle * lidangle * lidangle; + electricChest.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); + + electricChest.renderAll(); } else if(item.getItem() instanceof ItemRobit) { @@ -384,7 +384,7 @@ public class ItemRenderingHandler implements IItemRenderer { GL11.glScalef(1.4F, 1.4F, 1.4F); GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); - + if(type == ItemRenderType.EQUIPPED) { GL11.glRotatef(-45, 0.0F, 1.0F, 0.0F); @@ -396,14 +396,14 @@ public class ItemRenderingHandler implements IItemRenderer { GL11.glRotatef(225, 0.0F, 1.0F, 0.0F); GL11.glRotatef(45, -1.0F, 0.0F, -1.0F); - GL11.glScalef(0.6F, 0.6F, 0.6F); + GL11.glScalef(0.6F, 0.6F, 0.6F); GL11.glTranslatef(0.0F, -0.2F, 0.0F); } else { GL11.glRotatef(45, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, -0.7F, 0.0F); } - + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AtomicDisassembler.png")); atomicDisassembler.render(0.0625F); } @@ -412,7 +412,7 @@ public class ItemRenderingHandler implements IItemRenderer GL11.glTranslated(-0.5, -0.5, -0.5); GL11.glDisable(GL11.GL_CULL_FACE); RenderPartTransmitter.getInstance().renderItem(TransmitterType.values()[item.getItemDamage()]); - GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_CULL_FACE); } else { if(item.getItem() instanceof ItemBlockMachine) diff --git a/common/mekanism/client/render/tileentity/RenderBin.java b/common/mekanism/client/render/tileentity/RenderBin.java index 56afbe63a..e2b05600e 100644 --- a/common/mekanism/client/render/tileentity/RenderBin.java +++ b/common/mekanism/client/render/tileentity/RenderBin.java @@ -24,169 +24,169 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderBin extends TileEntitySpecialRenderer { - private final RenderBlocks renderBlocks = new RenderBlocks(); - private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class); - + private final RenderBlocks renderBlocks = new RenderBlocks(); + private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class); + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityBin)tileEntity, x, y, z, partialTick); } - @SuppressWarnings("incomplete-switch") + @SuppressWarnings("incomplete-switch") private void renderAModelAt(TileEntityBin tileEntity, double x, double y, double z, float partialTick) { - if(tileEntity instanceof TileEntityBin) - { - String amount = ""; - ItemStack itemStack = tileEntity.itemType; + if(tileEntity instanceof TileEntityBin) + { + String amount = ""; + ItemStack itemStack = tileEntity.itemType; - if(itemStack != null) - { - amount = Integer.toString(tileEntity.clientAmount); - } + if(itemStack != null) + { + amount = Integer.toString(tileEntity.clientAmount); + } - Coord4D obj = Coord4D.get(tileEntity).getFromSide(ForgeDirection.getOrientation(tileEntity.facing)); - - if(tileEntity.worldObj.isBlockSolidOnSide(obj.xCoord, obj.yCoord, obj.zCoord, ForgeDirection.getOrientation(tileEntity.facing).getOpposite())) - { - return; - } - - doLight(tileEntity.worldObj, obj); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + Coord4D obj = Coord4D.get(tileEntity).getFromSide(ForgeDirection.getOrientation(tileEntity.facing)); - if(itemStack != null) - { - GL11.glPushMatrix(); + if(tileEntity.worldObj.isBlockSolidOnSide(obj.xCoord, obj.yCoord, obj.zCoord, ForgeDirection.getOrientation(tileEntity.facing).getOpposite())) + { + return; + } - switch(ForgeDirection.getOrientation(tileEntity.facing)) - { - case NORTH: - GL11.glTranslated(x + 0.73, y + 0.83, z - 0.01); - break; - case SOUTH: - GL11.glTranslated(x + 0.27, y + 0.83, z + 1.01); - GL11.glRotatef(180, 0, 1, 0); - break; - case WEST: - GL11.glTranslated(x - 0.01, y + 0.83, z + 0.27); - GL11.glRotatef(90, 0, 1, 0); - break; - case EAST: - GL11.glTranslated(x + 1.01, y + 0.83, z + 0.73); - GL11.glRotatef(-90, 0, 1, 0); - break; - } + doLight(tileEntity.worldObj, obj); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - float scale = 0.03125F; - float scaler = 0.9F; - - GL11.glScalef(scale*scaler, scale*scaler, 0); - GL11.glRotatef(180, 0, 0, 1); + if(itemStack != null) + { + GL11.glPushMatrix(); - TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; + switch(ForgeDirection.getOrientation(tileEntity.facing)) + { + case NORTH: + GL11.glTranslated(x + 0.73, y + 0.83, z - 0.01); + break; + case SOUTH: + GL11.glTranslated(x + 0.27, y + 0.83, z + 1.01); + GL11.glRotatef(180, 0, 1, 0); + break; + case WEST: + GL11.glTranslated(x - 0.01, y + 0.83, z + 0.27); + GL11.glRotatef(90, 0, 1, 0); + break; + case EAST: + GL11.glTranslated(x + 1.01, y + 0.83, z + 0.73); + GL11.glRotatef(-90, 0, 1, 0); + break; + } - GL11.glDisable(GL11.GL_LIGHTING); - - renderItem.renderItemAndEffectIntoGUI(getFontRenderer(), renderEngine, itemStack, 0, 0); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + float scale = 0.03125F; + float scaler = 0.9F; - if(amount != "") - { - renderText(amount, ForgeDirection.getOrientation(tileEntity.facing), 0.02F, x, y - 0.31F, z); - } - } - } + GL11.glScalef(scale*scaler, scale*scaler, 0); + GL11.glRotatef(180, 0, 0, 1); - private void doLight(World world, Coord4D obj) - { - if(world.isBlockOpaqueCube(obj.xCoord, obj.yCoord, obj.zCoord)) - { - return; - } - - int brightness = world.getLightBrightnessForSkyBlocks(obj.xCoord, obj.yCoord, obj.zCoord, 0); - int lightX = brightness % 65536; - int lightY = brightness / 65536; - float scale = 0.6F; - - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightX * scale, lightY * scale); - } + TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; - @SuppressWarnings("incomplete-switch") - private void renderText(String text, ForgeDirection side, float maxScale, double x, double y, double z) - { - GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPolygonOffset(-10, -10); - GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); + renderItem.renderItemAndEffectIntoGUI(getFontRenderer(), renderEngine, itemStack, 0, 0); - float displayWidth = 1 - (2 / 16); - float displayHeight = 1 - (2 / 16); - GL11.glTranslated(x, y, z); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - switch(side) - { - case SOUTH: - GL11.glTranslatef(0, 1, 0); - GL11.glRotatef(0, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - case NORTH: - GL11.glTranslatef(1, 1, 1); - GL11.glRotatef(180, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - case EAST: - GL11.glTranslatef(0, 1, 1); - GL11.glRotatef(90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - case WEST: - GL11.glTranslatef(1, 1, 0); - GL11.glRotatef(-90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - } + if(amount != "") + { + renderText(amount, ForgeDirection.getOrientation(tileEntity.facing), 0.02F, x, y - 0.31F, z); + } + } + } - GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); - GL11.glRotatef(-90, 1, 0, 0); + private void doLight(World world, Coord4D obj) + { + if(world.isBlockOpaqueCube(obj.xCoord, obj.yCoord, obj.zCoord)) + { + return; + } - FontRenderer fontRenderer = getFontRenderer(); + int brightness = world.getLightBrightnessForSkyBlocks(obj.xCoord, obj.yCoord, obj.zCoord, 0); + int lightX = brightness % 65536; + int lightY = brightness / 65536; + float scale = 0.6F; - int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1); - int lineHeight = fontRenderer.FONT_HEIGHT + 2; - int requiredHeight = lineHeight * 1; - float scaler = 0.4F; - float scaleX = (displayWidth / requiredWidth); - float scale = scaleX * scaler; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightX * scale, lightY * scale); + } - if(maxScale > 0) - { - scale = Math.min(scale, maxScale); - } + @SuppressWarnings("incomplete-switch") + private void renderText(String text, ForgeDirection side, float maxScale, double x, double y, double z) + { + GL11.glPushMatrix(); - GL11.glScalef(scale, -scale, scale); - GL11.glDepthMask(false); + GL11.glPolygonOffset(-10, -10); + GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); - int offsetX; - int offsetY; - int realHeight = (int)Math.floor(displayHeight / scale); - int realWidth = (int)Math.floor(displayWidth / scale); + float displayWidth = 1 - (2 / 16); + float displayHeight = 1 - (2 / 16); + GL11.glTranslated(x, y, z); - offsetX = (realWidth - requiredWidth) / 2; - offsetY = (realHeight - requiredHeight) / 2; + switch(side) + { + case SOUTH: + GL11.glTranslatef(0, 1, 0); + GL11.glRotatef(0, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + break; + case NORTH: + GL11.glTranslatef(1, 1, 1); + GL11.glRotatef(180, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + break; + case EAST: + GL11.glTranslatef(0, 1, 1); + GL11.glRotatef(90, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + break; + case WEST: + GL11.glTranslatef(1, 1, 0); + GL11.glRotatef(-90, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + break; + } - GL11.glDisable(GL11.GL_LIGHTING); - fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); + GL11.glRotatef(-90, 1, 0, 0); - GL11.glPopMatrix(); - } + FontRenderer fontRenderer = getFontRenderer(); + + int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1); + int lineHeight = fontRenderer.FONT_HEIGHT + 2; + int requiredHeight = lineHeight * 1; + float scaler = 0.4F; + float scaleX = (displayWidth / requiredWidth); + float scale = scaleX * scaler; + + if(maxScale > 0) + { + scale = Math.min(scale, maxScale); + } + + GL11.glScalef(scale, -scale, scale); + GL11.glDepthMask(false); + + int offsetX; + int offsetY; + int realHeight = (int)Math.floor(displayHeight / scale); + int realWidth = (int)Math.floor(displayWidth / scale); + + offsetX = (realWidth - requiredWidth) / 2; + offsetY = (realHeight - requiredHeight) / 2; + + GL11.glDisable(GL11.GL_LIGHTING); + fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + + GL11.glPopMatrix(); + } } diff --git a/common/mekanism/client/render/tileentity/RenderChargepad.java b/common/mekanism/client/render/tileentity/RenderChargepad.java index 37830883b..05a1bd62f 100644 --- a/common/mekanism/client/render/tileentity/RenderChargepad.java +++ b/common/mekanism/client/render/tileentity/RenderChargepad.java @@ -15,27 +15,27 @@ import net.minecraft.tileentity.TileEntity; public class RenderChargepad extends TileEntitySpecialRenderer { private ModelChargepad model = new ModelChargepad(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityChargepad)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityChargepad tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Chargepad.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderChemicalCrystalizer.java b/common/mekanism/client/render/tileentity/RenderChemicalCrystalizer.java index 3cdfb4601..07754f23d 100644 --- a/common/mekanism/client/render/tileentity/RenderChemicalCrystalizer.java +++ b/common/mekanism/client/render/tileentity/RenderChemicalCrystalizer.java @@ -17,26 +17,26 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderChemicalCrystalizer extends TileEntitySpecialRenderer { private ModelChemicalCrystalizer model = new ModelChemicalCrystalizer(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityChemicalCrystalizer)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityChemicalCrystalizer tileEntity, double x, double y, double z, float partialTick) - { + { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalCrystalizer.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + } if(tileEntity.isActive) { @@ -45,13 +45,13 @@ public class RenderChemicalCrystalizer extends TileEntitySpecialRenderer else { tileEntity.spinSpeed = Math.max(0, tileEntity.spinSpeed-0.02F); } - + tileEntity.spin = (tileEntity.spin + (tileEntity.spinSpeed*0.1F)) % 1; - + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.renderWithRotation(0.0625F, tileEntity.spin); GL11.glPopMatrix(); - + MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); } } diff --git a/common/mekanism/client/render/tileentity/RenderChemicalDissolutionChamber.java b/common/mekanism/client/render/tileentity/RenderChemicalDissolutionChamber.java index 9d9ceb2ae..2fee0e8d1 100644 --- a/common/mekanism/client/render/tileentity/RenderChemicalDissolutionChamber.java +++ b/common/mekanism/client/render/tileentity/RenderChemicalDissolutionChamber.java @@ -16,27 +16,27 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderChemicalDissolutionChamber extends TileEntitySpecialRenderer { private ModelChemicalDissolutionChamber model = new ModelChemicalDissolutionChamber(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityChemicalDissolutionChamber)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityChemicalDissolutionChamber tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalDissolutionChamber.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderChemicalInfuser.java b/common/mekanism/client/render/tileentity/RenderChemicalInfuser.java index c074f70bd..2503d7970 100644 --- a/common/mekanism/client/render/tileentity/RenderChemicalInfuser.java +++ b/common/mekanism/client/render/tileentity/RenderChemicalInfuser.java @@ -22,39 +22,39 @@ import org.lwjgl.opengl.GL11; public class RenderChemicalInfuser extends TileEntitySpecialRenderer { private ModelChemicalInfuser model = new ModelChemicalInfuser(); - + private static final double offset = 0.001; - + private Map> cachedGasses = new HashMap>(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityChemicalInfuser)tileEntity, x, y, z, partialTick); } - + @SuppressWarnings("incomplete-switch") private void renderAModelAt(TileEntityChemicalInfuser tileEntity, double x, double y, double z, float partialTick) { render(false, x, y, z, tileEntity); - + if(tileEntity.leftTank.getGas() != null) { push(); - + GL11.glTranslatef((float)x, (float)y, (float)z); GL11.glColor4f(1.0F, 1.0F, 1.0F, (float)tileEntity.leftTank.getStored()/tileEntity.leftTank.getMaxGas()); bindTexture(MekanismRenderer.getBlocksTexture()); getListAndRender(ForgeDirection.getOrientation(tileEntity.facing), tileEntity.leftTank.getGas().getGas()).render(); GL11.glColor4f(1, 1, 1, 1); - + pop(); } - + if(tileEntity.rightTank.getGas() != null) { push(); - + switch(ForgeDirection.getOrientation(tileEntity.facing)) { case NORTH: @@ -70,19 +70,19 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer GL11.glTranslatef(0, 0, 0.4375F); break; } - + GL11.glTranslatef((float)x, (float)y, (float)z); GL11.glColor4f(1.0F, 1.0F, 1.0F, (float)tileEntity.rightTank.getStored()/tileEntity.rightTank.getMaxGas()); bindTexture(MekanismRenderer.getBlocksTexture()); getListAndRender(ForgeDirection.getOrientation(tileEntity.facing), tileEntity.rightTank.getGas().getGas()).render(); GL11.glColor4f(1, 1, 1, 1); - + pop(); } - + render(true, x, y, z, tileEntity); } - + /* * 0: casing, 1: glass */ @@ -90,19 +90,19 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalInfuser.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - + if(!glass) { model.render(0.0625F); @@ -110,10 +110,10 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer else { model.renderGlass(0.0625F); } - + GL11.glPopMatrix(); } - + @SuppressWarnings("incomplete-switch") private DisplayInteger getListAndRender(ForgeDirection side, Gas gas) { @@ -121,18 +121,18 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer { return null; } - + if(cachedGasses.containsKey(side) && cachedGasses.get(side).containsKey(gas)) { return cachedGasses.get(side).get(gas); } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.waterStill; toReturn.setTexture(gas.getIcon()); - + DisplayInteger display = DisplayInteger.createAndStart(); - + if(cachedGasses.containsKey(side)) { cachedGasses.get(side).put(gas, display); @@ -142,7 +142,7 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer map.put(gas, display); cachedGasses.put(side, map); } - + switch(side) { case NORTH: @@ -150,7 +150,7 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer toReturn.minX = 0.625 + offset; toReturn.minY = 0.0625 + offset; toReturn.minZ = 0.625 + offset; - + toReturn.maxX = 0.8125 - offset; toReturn.maxY = 0.9375 - offset; toReturn.maxZ = 0.8125 - offset; @@ -161,7 +161,7 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer toReturn.minX = 0.1875 + offset; toReturn.minY = 0.0625 + offset; toReturn.minZ = 0.1875 + offset; - + toReturn.maxX = 0.375 - offset; toReturn.maxY = 0.9375 - offset; toReturn.maxZ = 0.375 - offset; @@ -172,7 +172,7 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer toReturn.minX = 0.625 + offset; toReturn.minY = 0.0625 + offset; toReturn.minZ = 0.1875 + offset; - + toReturn.maxX = 0.8125 - offset; toReturn.maxY = 0.9375 - offset; toReturn.maxZ = 0.375 - offset; @@ -183,28 +183,28 @@ public class RenderChemicalInfuser extends TileEntitySpecialRenderer toReturn.minX = 0.1875 + offset; toReturn.minY = 0.0625 + offset; toReturn.minZ = 0.625 + offset; - + toReturn.maxX = 0.375 - offset; toReturn.maxY = 0.9375 - offset; toReturn.maxZ = 0.8125 - offset; break; } } - + MekanismRenderer.renderObject(toReturn); display.endList(); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - + return display; } - + private void pop() { GL11.glPopAttrib(); GL11.glPopMatrix(); } - + private void push() { GL11.glPushMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderChemicalOxidizer.java b/common/mekanism/client/render/tileentity/RenderChemicalOxidizer.java index 13571d131..28aa1a4b3 100644 --- a/common/mekanism/client/render/tileentity/RenderChemicalOxidizer.java +++ b/common/mekanism/client/render/tileentity/RenderChemicalOxidizer.java @@ -21,37 +21,37 @@ import org.lwjgl.opengl.GL11; public class RenderChemicalOxidizer extends TileEntitySpecialRenderer { private ModelChemicalOxidizer model = new ModelChemicalOxidizer(); - + private static final double offset = 0.001; - + private Map> cachedGasses = new HashMap>(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityChemicalOxidizer)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityChemicalOxidizer tileEntity, double x, double y, double z, float partialTick) { render(false, x, y, z, tileEntity); - + if(tileEntity.gasTank.getGas() != null) { push(); - + GL11.glTranslatef((float)x, (float)y, (float)z); GL11.glColor4f(1.0F, 1.0F, 1.0F, (float)tileEntity.gasTank.getStored()/tileEntity.gasTank.getMaxGas()); bindTexture(MekanismRenderer.getBlocksTexture()); getListAndRender(ForgeDirection.getOrientation(tileEntity.facing), tileEntity.gasTank.getGas().getGas()).render(); GL11.glColor4f(1, 1, 1, 1); - + pop(); } - + render(true, x, y, z, tileEntity); } - + /* * 0: casing, 1: glass */ @@ -59,19 +59,19 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalOxidizer.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - + if(!glass) { model.render(0.0625F); @@ -79,10 +79,10 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer else { model.renderGlass(0.0625F); } - + GL11.glPopMatrix(); } - + @SuppressWarnings("incomplete-switch") private DisplayInteger getListAndRender(ForgeDirection side, Gas gas) { @@ -90,18 +90,18 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer { return null; } - + if(cachedGasses.containsKey(side) && cachedGasses.get(side).containsKey(gas)) { return cachedGasses.get(side).get(gas); } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.waterStill; toReturn.setTexture(gas.getIcon()); - + DisplayInteger display = DisplayInteger.createAndStart(); - + if(cachedGasses.containsKey(side)) { cachedGasses.get(side).put(gas, display); @@ -111,7 +111,7 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer map.put(gas, display); cachedGasses.put(side, map); } - + switch(side) { case NORTH: @@ -119,7 +119,7 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer toReturn.minX = 0.125 + offset; toReturn.minY = 0.0625 + offset; toReturn.minZ = 0.3125 + offset; - + toReturn.maxX = 0.5 - offset; toReturn.maxY = 0.9375 - offset; toReturn.maxZ = 0.6875 - offset; @@ -130,7 +130,7 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer toReturn.minX = 0.5 + offset; toReturn.minY = 0.0625 + offset; toReturn.minZ = 0.3125 + offset; - + toReturn.maxX = 0.875 - offset; toReturn.maxY = 0.9375 - offset; toReturn.maxZ = 0.6875 - offset; @@ -141,7 +141,7 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer toReturn.minX = 0.3125 + offset; toReturn.minY = 0.0625 + offset; toReturn.minZ = 0.5 + offset; - + toReturn.maxX = 0.6875 - offset; toReturn.maxY = 0.9375 - offset; toReturn.maxZ = 0.875 - offset; @@ -152,28 +152,28 @@ public class RenderChemicalOxidizer extends TileEntitySpecialRenderer toReturn.minX = 0.3125 + offset; toReturn.minY = 0.0625 + offset; toReturn.minZ = 0.125 + offset; - + toReturn.maxX = 0.6875 - offset; toReturn.maxY = 0.9375 - offset; toReturn.maxZ = 0.5 - offset; break; } } - + MekanismRenderer.renderObject(toReturn); display.endList(); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - + return display; } - + private void pop() { GL11.glPopAttrib(); GL11.glPopMatrix(); } - + private void push() { GL11.glPushMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderChemicalWasher.java b/common/mekanism/client/render/tileentity/RenderChemicalWasher.java index 89a16cf9f..04c8f889d 100644 --- a/common/mekanism/client/render/tileentity/RenderChemicalWasher.java +++ b/common/mekanism/client/render/tileentity/RenderChemicalWasher.java @@ -12,27 +12,27 @@ import org.lwjgl.opengl.GL11; public class RenderChemicalWasher extends TileEntitySpecialRenderer { private ModelChemicalWasher model = new ModelChemicalWasher(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityChemicalWasher)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityChemicalWasher tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalWasher.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderConfigurableMachine.java b/common/mekanism/client/render/tileentity/RenderConfigurableMachine.java index 5325fdfb3..11860dbe3 100644 --- a/common/mekanism/client/render/tileentity/RenderConfigurableMachine.java +++ b/common/mekanism/client/render/tileentity/RenderConfigurableMachine.java @@ -32,14 +32,14 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderConfigurableMachine extends TileEntitySpecialRenderer { private Minecraft mc = FMLClientHandler.instance().getClient(); - + private HashMap> cachedOverlays = new HashMap>(); - + public RenderConfigurableMachine() { tileEntityRenderer = TileEntityRenderer.instance; } - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { @@ -49,42 +49,42 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer public void renderAModelAt(IInvConfiguration configurable, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); - - TileEntity tileEntity = (TileEntity)configurable; + + TileEntity tileEntity = (TileEntity)configurable; EntityPlayer player = mc.thePlayer; World world = mc.thePlayer.worldObj; ItemStack itemStack = player.getCurrentEquippedItem(); MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F); - + if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator && ((ItemConfigurator)itemStack.getItem()).getState(itemStack) == 0) { int xPos = MathHelper.floor_double(pos.blockX); int yPos = MathHelper.floor_double(pos.blockY); int zPos = MathHelper.floor_double(pos.blockZ); - + Coord4D obj = new Coord4D(xPos, yPos, zPos, tileEntity.worldObj.provider.dimensionId); - + if(xPos == tileEntity.xCoord && yPos == tileEntity.yCoord && zPos == tileEntity.zCoord) { EnumColor color = configurable.getSideData().get(configurable.getConfiguration()[MekanismUtils.getBaseOrientation(pos.sideHit, configurable.getOrientation())]).color; - + push(); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); - + bindTexture(MekanismRenderer.getBlocksTexture()); GL11.glTranslatef((float)x, (float)y, (float)z); - + int display = getOverlayDisplay(world, ForgeDirection.getOrientation(pos.sideHit), color).display; GL11.glCallList(display); - + pop(); } } - + GL11.glPopMatrix(); } - + private void pop() { GL11.glPopAttrib(); @@ -92,7 +92,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer MekanismRenderer.blendOff(); GL11.glPopMatrix(); } - + private void push() { GL11.glPushMatrix(); @@ -102,20 +102,20 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer MekanismRenderer.glowOn(); MekanismRenderer.blendOn(); } - + private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, EnumColor color) { if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(color)) { return cachedOverlays.get(side).get(color); } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.stone; toReturn.setTexture(MekanismRenderer.getColorIcon(color)); - + DisplayInteger display = DisplayInteger.createAndStart(); - + if(cachedOverlays.containsKey(side)) { cachedOverlays.get(side).put(color, display); @@ -125,14 +125,14 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer map.put(color, display); cachedOverlays.put(side, map); } - + switch(side) { case DOWN: { toReturn.minY = -.01; toReturn.maxY = 0; - + toReturn.minX = 0; toReturn.minZ = 0; toReturn.maxX = 1; @@ -143,7 +143,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer { toReturn.minY = 1; toReturn.maxY = 1.01; - + toReturn.minX = 0; toReturn.minZ = 0; toReturn.maxX = 1; @@ -154,7 +154,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer { toReturn.minZ = -.01; toReturn.maxZ = 0; - + toReturn.minX = 0; toReturn.minY = 0; toReturn.maxX = 1; @@ -165,7 +165,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer { toReturn.minZ = 1; toReturn.maxZ = 1.01; - + toReturn.minX = 0; toReturn.minY = 0; toReturn.maxX = 1; @@ -176,7 +176,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer { toReturn.minX = -.01; toReturn.maxX = 0; - + toReturn.minY = 0; toReturn.minZ = 0; toReturn.maxY = 1; @@ -187,7 +187,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer { toReturn.minX = 1; toReturn.maxX = 1.01; - + toReturn.minY = 0; toReturn.minZ = 0; toReturn.maxY = 1; @@ -199,10 +199,10 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer break; } } - + MekanismRenderer.renderObject(toReturn); display.endList(); - + return display; } } \ No newline at end of file diff --git a/common/mekanism/client/render/tileentity/RenderDigitalMiner.java b/common/mekanism/client/render/tileentity/RenderDigitalMiner.java index 95ce6e320..ccd8f8fef 100644 --- a/common/mekanism/client/render/tileentity/RenderDigitalMiner.java +++ b/common/mekanism/client/render/tileentity/RenderDigitalMiner.java @@ -16,28 +16,28 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderDigitalMiner extends TileEntitySpecialRenderer { private ModelDigitalMiner model = new ModelDigitalMiner(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityDigitalMiner)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityDigitalMiner tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner" + (tileEntity.isActive ? "On" : "") + ".png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F, tileEntity.isActive); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderDynamicTank.java b/common/mekanism/client/render/tileentity/RenderDynamicTank.java index f9a00ae34..4395ea059 100644 --- a/common/mekanism/client/render/tileentity/RenderDynamicTank.java +++ b/common/mekanism/client/render/tileentity/RenderDynamicTank.java @@ -29,36 +29,36 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer { private static Map> cachedCenterFluids = new HashMap>(); private static Map> cachedValveFluids = new HashMap>(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityDynamicTank)tileEntity, x, y, z, partialTick); } - + public void renderAModelAt(TileEntityDynamicTank tileEntity, double x, double y, double z, float partialTick) - { + { if(tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null && tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0) { RenderData data = new RenderData(); - + data.location = tileEntity.structure.renderLocation; data.height = tileEntity.structure.volHeight; data.length = tileEntity.structure.volLength; data.width = tileEntity.structure.volWidth; - + bindTexture(MekanismRenderer.getBlocksTexture()); - + if(data.location != null && data.height > 0 && tileEntity.structure.fluidStored.getFluid() != null) { push(); - + GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord)); - + MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity()); - + DisplayInteger[] displayList = getListAndRender(data, tileEntity.structure.fluidStored.getFluid(), tileEntity.worldObj); - + if(tileEntity.structure.fluidStored.getFluid().isGaseous()) { GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.fluidStored.amount / (float)tileEntity.clientCapacity)+0.3F)); @@ -67,38 +67,38 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer else { displayList[(int)(tileEntity.prevScale*((float)getStages(data.height)-1))].render(); } - + MekanismRenderer.glowOff(); - + pop(); - + for(ValveData valveData : tileEntity.valveViewing.keySet()) { if(tileEntity.valveViewing.get(valveData) > 0) { push(); - + GL11.glTranslated(getX(valveData.location.xCoord), getY(valveData.location.yCoord), getZ(valveData.location.zCoord)); - + MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity()); - + getValveDisplay(ValveRenderData.get(data, valveData), tileEntity.structure.fluidStored.getFluid(), tileEntity.worldObj).render(); - + MekanismRenderer.glowOff(); - + pop(); } } } } } - + private void pop() { GL11.glPopAttrib(); GL11.glPopMatrix(); } - + private void push() { GL11.glPushMatrix(); @@ -108,21 +108,21 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } - + private DisplayInteger[] getListAndRender(RenderData data, Fluid fluid, World world) { if(cachedCenterFluids.containsKey(data) && cachedCenterFluids.get(data).containsKey(fluid)) { return cachedCenterFluids.get(data).get(fluid); } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.waterStill; toReturn.setTexture(fluid.getIcon()); - + final int stages = getStages(data.height); DisplayInteger[] displays = new DisplayInteger[stages]; - + if(cachedCenterFluids.containsKey(data)) { cachedCenterFluids.get(data).put(fluid, displays); @@ -132,47 +132,47 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer map.put(fluid, displays); cachedCenterFluids.put(data, map); } - + MekanismRenderer.colorFluid(fluid); - + for(int i = 0; i < stages; i++) { displays[i] = DisplayInteger.createAndStart(); - + if(fluid.getIcon() != null) { toReturn.minX = 0 + .01; toReturn.minY = 0 + .01; toReturn.minZ = 0 + .01; - + toReturn.maxX = data.length - .01; toReturn.maxY = ((float)i/(float)stages)*(data.height-2) - .01; toReturn.maxZ = data.width - .01; - + MekanismRenderer.renderObject(toReturn); } - + GL11.glEndList(); } - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - + return displays; } - + private DisplayInteger getValveDisplay(ValveRenderData data, Fluid fluid, World world) { if(cachedValveFluids.containsKey(data) && cachedValveFluids.get(data).containsKey(fluid)) { return cachedValveFluids.get(data).get(fluid); } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.waterStill; toReturn.setTexture(fluid.getFlowingIcon()); - + DisplayInteger display = DisplayInteger.createAndStart(); - + if(cachedValveFluids.containsKey(data)) { cachedValveFluids.get(data).put(fluid, display); @@ -182,9 +182,9 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer map.put(fluid, display); cachedValveFluids.put(data, map); } - + MekanismRenderer.colorFluid(fluid); - + switch(data.side) { case DOWN: @@ -192,7 +192,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer toReturn.minX = .3; toReturn.minY = 1 + .01; toReturn.minZ = .3; - + toReturn.maxX = .7; toReturn.maxY = 1.4 + .1; toReturn.maxZ = .7; @@ -203,7 +203,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer toReturn.minX = .3; toReturn.minY = -(data.height-2) - .01; toReturn.minZ = .3; - + toReturn.maxX = .7; toReturn.maxY = -.01; toReturn.maxZ = .7; @@ -214,7 +214,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer toReturn.minX = .3; toReturn.minY = -(getValveFluidHeight(data)) + .01; toReturn.minZ = 1 + .02; - + toReturn.maxX = .7; toReturn.maxY = .7; toReturn.maxZ = 1.4; @@ -225,7 +225,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer toReturn.minX = .3; toReturn.minY = -(getValveFluidHeight(data)) + .01; toReturn.minZ = -.4; - + toReturn.maxX = .7; toReturn.maxY = .7; toReturn.maxZ = -.02; @@ -236,7 +236,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer toReturn.minX = 1 + .02; toReturn.minY = -(getValveFluidHeight(data)) + .01; toReturn.minZ = .3; - + toReturn.maxX = 1.4; toReturn.maxY = .7; toReturn.maxZ = .7; @@ -247,7 +247,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer toReturn.minX = -.4; toReturn.minY = -(getValveFluidHeight(data)) + .01; toReturn.minZ = .3; - + toReturn.maxX = -.02; toReturn.maxY = .7; toReturn.maxZ = .7; @@ -258,50 +258,50 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer break; } } - + MekanismRenderer.renderObject(toReturn); display.endList(); - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - + return display; } - + private int getValveFluidHeight(ValveRenderData data) { return data.valveLocation.yCoord - data.location.yCoord; } - + private int getStages(int height) { return (height-2)*(TankUpdateProtocol.FLUID_PER_TANK/10); } - + private double getX(int x) { return x - TileEntityRenderer.staticPlayerX; } - + private double getY(int y) { return y - TileEntityRenderer.staticPlayerY; } - + private double getZ(int z) { return z - TileEntityRenderer.staticPlayerZ; } - + public static class RenderData { public Coord4D location; - + public int height; public int length; public int width; - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + location.hashCode(); @@ -310,41 +310,41 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer code = 31 * code + width; return code; } - + @Override public boolean equals(Object data) { - return data instanceof RenderData && ((RenderData)data).location.equals(location) && ((RenderData)data).height == height && + return data instanceof RenderData && ((RenderData)data).location.equals(location) && ((RenderData)data).height == height && ((RenderData)data).length == length && ((RenderData)data).width == width; } } - + public static class ValveRenderData extends RenderData { public ForgeDirection side; public Coord4D valveLocation; - + public static ValveRenderData get(RenderData renderData, ValveData valveData) { ValveRenderData data = new ValveRenderData(); - + data.location = renderData.location; data.height = renderData.height; data.length = renderData.length; data.width = renderData.width; - + data.side = valveData.side; data.valveLocation = valveData.location; - + return data; } - + @Override public boolean equals(Object data) { return data instanceof ValveRenderData && super.equals(data) && ((ValveRenderData)data).side.equals(side); } - + @Override public int hashCode() { diff --git a/common/mekanism/client/render/tileentity/RenderElectricChest.java b/common/mekanism/client/render/tileentity/RenderElectricChest.java index 36d5a8c4d..6cc21badb 100644 --- a/common/mekanism/client/render/tileentity/RenderElectricChest.java +++ b/common/mekanism/client/render/tileentity/RenderElectricChest.java @@ -16,44 +16,44 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderElectricChest extends TileEntitySpecialRenderer { private ModelChest model = new ModelChest(); - + @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityElectricChest)tileEntity, x, y, z, partialTick); - } - + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) + { + renderAModelAt((TileEntityElectricChest)tileEntity, x, y, z, partialTick); + } + private void renderAModelAt(TileEntityElectricChest tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x, (float)y + 1.0F, (float)z); GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricChest.png")); - - switch(tileEntity.facing) - { - case 2: - GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(1.0F, 0.0F, 0.0F); - break; - case 3: + + switch(tileEntity.facing) + { + case 2: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(1.0F, 0.0F, 0.0F); + break; + case 3: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, 0.0F, -1.0F); break; - case 4: + case 4: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 5: + case 5: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(1.0F, 0.0F, -1.0F); break; - } - + } + float lidangle = tileEntity.prevLidAngle + (tileEntity.lidAngle - tileEntity.prevLidAngle) * partialTick; - lidangle = 1.0F - lidangle; - lidangle = 1.0F - lidangle * lidangle * lidangle; - model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + lidangle = 1.0F - lidangle; + lidangle = 1.0F - lidangle * lidangle * lidangle; + model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.renderAll(); GL11.glPopMatrix(); } diff --git a/common/mekanism/client/render/tileentity/RenderElectricPump.java b/common/mekanism/client/render/tileentity/RenderElectricPump.java index 24c15704d..21f4c7ab0 100644 --- a/common/mekanism/client/render/tileentity/RenderElectricPump.java +++ b/common/mekanism/client/render/tileentity/RenderElectricPump.java @@ -15,28 +15,28 @@ import net.minecraft.tileentity.TileEntity; public class RenderElectricPump extends TileEntitySpecialRenderer { private ModelElectricPump model = new ModelElectricPump(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityElectricPump)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityElectricPump tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricPump.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderElectrolyticSeparator.java b/common/mekanism/client/render/tileentity/RenderElectrolyticSeparator.java index 8ca9e6bbf..3e6a1464e 100644 --- a/common/mekanism/client/render/tileentity/RenderElectrolyticSeparator.java +++ b/common/mekanism/client/render/tileentity/RenderElectrolyticSeparator.java @@ -15,29 +15,29 @@ import org.lwjgl.opengl.GL11; public class RenderElectrolyticSeparator extends TileEntitySpecialRenderer { private ModelElectrolyticSeparator model = new ModelElectrolyticSeparator(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityElectrolyticSeparator)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityElectrolyticSeparator tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectrolyticSeparator.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - } - - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + } + + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); model.render(0.0625F); GL11.glPopMatrix(); } diff --git a/common/mekanism/client/render/tileentity/RenderEnergyCube.java b/common/mekanism/client/render/tileentity/RenderEnergyCube.java index b6ab67031..b595bf439 100644 --- a/common/mekanism/client/render/tileentity/RenderEnergyCube.java +++ b/common/mekanism/client/render/tileentity/RenderEnergyCube.java @@ -22,61 +22,61 @@ public class RenderEnergyCube extends TileEntitySpecialRenderer { private ModelEnergyCube model = new ModelEnergyCube(); private ModelEnergyCore core = new ModelEnergyCore(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityEnergyCube)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityEnergyCube tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube" + tileEntity.tier.name + ".png")); - - switch(tileEntity.facing) - { - case 0: - GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, 1.0F, -1.0F); - break; - case 1: - GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, 1.0F, 1.0F); - break; - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 0: + GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, 1.0F, -1.0F); + break; + case 1: + GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, 1.0F, 1.0F); + break; + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); - - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png")); - MekanismRenderer.blendOn(); - MekanismRenderer.glowOn(); - - EnumColor c = tileEntity.tier.color; + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png")); - GL11.glPushMatrix(); - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), (float)(tileEntity.getEnergy()/tileEntity.getMaxEnergy())); - GL11.glTranslatef(0, (float)Math.sin(Math.toRadians((MekanismClient.ticksPassed + partialTick) * 3)) / 7, 0); - GL11.glRotatef((MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 0); - GL11.glRotatef(36F + (MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 1); - core.render(0.0625F); - GL11.glPopMatrix(); + MekanismRenderer.blendOn(); + MekanismRenderer.glowOn(); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); + EnumColor c = tileEntity.tier.color; - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), (float)(tileEntity.getEnergy()/tileEntity.getMaxEnergy())); + GL11.glTranslatef(0, (float)Math.sin(Math.toRadians((MekanismClient.ticksPassed + partialTick) * 3)) / 7, 0); + GL11.glRotatef((MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 0); + GL11.glRotatef(36F + (MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 1); + core.render(0.0625F); + GL11.glPopMatrix(); + + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + + GL11.glPopMatrix(); } } diff --git a/common/mekanism/client/render/tileentity/RenderGasTank.java b/common/mekanism/client/render/tileentity/RenderGasTank.java index f898cee3a..6f2878cdf 100644 --- a/common/mekanism/client/render/tileentity/RenderGasTank.java +++ b/common/mekanism/client/render/tileentity/RenderGasTank.java @@ -16,27 +16,27 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderGasTank extends TileEntitySpecialRenderer { private ModelGasTank model = new ModelGasTank(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityGasTank)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityGasTank tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasTank.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderLogisticalSorter.java b/common/mekanism/client/render/tileentity/RenderLogisticalSorter.java index 77812c96e..3adaa8efd 100644 --- a/common/mekanism/client/render/tileentity/RenderLogisticalSorter.java +++ b/common/mekanism/client/render/tileentity/RenderLogisticalSorter.java @@ -16,40 +16,40 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderLogisticalSorter extends TileEntitySpecialRenderer { private ModelLogisticalSorter model = new ModelLogisticalSorter(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityLogisticalSorter)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityLogisticalSorter tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter" + (tileEntity.isActive ? "On" : "") + ".png")); - - switch(tileEntity.facing) - { - case 0: - { - GL11.glRotatef(90F, 0.0F, 0.0F, -1.0F); - GL11.glTranslatef(1.0F, 1.0F, 0.0F); - break; - } - case 1: - { - GL11.glRotatef(90F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(-1.0F, 1.0F, 0.0F); - break; - } - case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 0: + { + GL11.glRotatef(90F, 0.0F, 0.0F, -1.0F); + GL11.glTranslatef(1.0F, 1.0F, 0.0F); + break; + } + case 1: + { + GL11.glRotatef(90F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-1.0F, 1.0F, 0.0F); + break; + } + case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F, tileEntity.isActive); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java b/common/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java index b6aa50d4e..c0e8b3410 100644 --- a/common/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java +++ b/common/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java @@ -17,32 +17,32 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderMetallurgicInfuser extends TileEntitySpecialRenderer { private ModelMetallurgicInfuser model = new ModelMetallurgicInfuser(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityMetallurgicInfuser)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityMetallurgicInfuser tileEntity, double x, double y, double z, float partialTick) - { + { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "MetallurgicInfuser.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); - + MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); } } \ No newline at end of file diff --git a/common/mekanism/client/render/tileentity/RenderObsidianTNT.java b/common/mekanism/client/render/tileentity/RenderObsidianTNT.java index 60199c8b4..0e0621cc4 100644 --- a/common/mekanism/client/render/tileentity/RenderObsidianTNT.java +++ b/common/mekanism/client/render/tileentity/RenderObsidianTNT.java @@ -16,20 +16,20 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderObsidianTNT extends TileEntitySpecialRenderer { private ModelObsidianTNT model = new ModelObsidianTNT(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityObsidianTNT)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityObsidianTNT tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png")); - + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderRotaryCondensentrator.java b/common/mekanism/client/render/tileentity/RenderRotaryCondensentrator.java index 8d7b35b24..faad61772 100644 --- a/common/mekanism/client/render/tileentity/RenderRotaryCondensentrator.java +++ b/common/mekanism/client/render/tileentity/RenderRotaryCondensentrator.java @@ -15,28 +15,28 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderRotaryCondensentrator extends TileEntitySpecialRenderer { private ModelRotaryCondensentrator model = new ModelRotaryCondensentrator(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityRotaryCondensentrator)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityRotaryCondensentrator tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/client/render/tileentity/RenderSalinationController.java b/common/mekanism/client/render/tileentity/RenderSalinationController.java index 3c1cbb636..76b7b66a6 100644 --- a/common/mekanism/client/render/tileentity/RenderSalinationController.java +++ b/common/mekanism/client/render/tileentity/RenderSalinationController.java @@ -27,50 +27,50 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderSalinationController extends TileEntitySpecialRenderer { private static Map> cachedCenterFluids = new HashMap>(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntitySalinationController)tileEntity, x, y, z, partialTick); } - + public void renderAModelAt(TileEntitySalinationController tileEntity, double x, double y, double z, float partialTick) - { + { if(tileEntity.structured && tileEntity.waterTank.getFluid() != null) { SalinationRenderData data = new SalinationRenderData(); - + data.height = tileEntity.height-2; data.side = ForgeDirection.getOrientation(tileEntity.facing); - + bindTexture(MekanismRenderer.getBlocksTexture()); - + if(data.height >= 2 && tileEntity.waterTank.getCapacity() > 0) { Coord4D renderLoc = tileEntity.getRenderLocation(); - + push(); - + GL11.glTranslated(getX(renderLoc.xCoord), getY(renderLoc.yCoord), getZ(renderLoc.zCoord)); - + MekanismRenderer.glowOn(tileEntity.waterTank.getFluid().getFluid().getLuminosity()); - + DisplayInteger[] displayList = getListAndRender(data, tileEntity.waterTank.getFluid().getFluid()); displayList[(int)(((float)tileEntity.waterTank.getFluidAmount()/tileEntity.waterTank.getCapacity())*((float)getStages(data.height)-1))].render(); - + MekanismRenderer.glowOff(); - + pop(); } } } - + private void pop() { GL11.glPopAttrib(); GL11.glPopMatrix(); } - + private void push() { GL11.glPushMatrix(); @@ -80,7 +80,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer GL11.glDisable(GL11.GL_LIGHTING); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } - + @SuppressWarnings("incomplete-switch") private DisplayInteger[] getListAndRender(SalinationRenderData data, Fluid fluid) { @@ -88,14 +88,14 @@ public class RenderSalinationController extends TileEntitySpecialRenderer { return cachedCenterFluids.get(data).get(fluid); } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.waterStill; toReturn.setTexture(fluid.getIcon()); - + final int stages = getStages(data.height); DisplayInteger[] displays = new DisplayInteger[stages]; - + if(cachedCenterFluids.containsKey(data)) { cachedCenterFluids.get(data).put(fluid, displays); @@ -105,13 +105,13 @@ public class RenderSalinationController extends TileEntitySpecialRenderer map.put(fluid, displays); cachedCenterFluids.put(data, map); } - + MekanismRenderer.colorFluid(fluid); - + for(int i = 0; i < stages; i++) { displays[i] = DisplayInteger.createAndStart(); - + if(fluid.getIcon() != null) { switch(data.side) @@ -120,7 +120,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer toReturn.minX = 0 + .01; toReturn.minY = 0 + .01; toReturn.minZ = 0 + .01; - + toReturn.maxX = 2 - .01; toReturn.maxY = ((float)i/(float)stages)*data.height - .01; toReturn.maxZ = 2 - .01; @@ -129,7 +129,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer toReturn.minX = -1 + .01; toReturn.minY = 0 + .01; toReturn.minZ = -1 + .01; - + toReturn.maxX = 1 - .01; toReturn.maxY = ((float)i/(float)stages)*data.height - .01; toReturn.maxZ = 1 - .01; @@ -138,7 +138,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer toReturn.minX = 0 + .01; toReturn.minY = 0 + .01; toReturn.minZ = -1 + .01; - + toReturn.maxX = 2 - .01; toReturn.maxY = ((float)i/(float)stages)*data.height - .01; toReturn.maxZ = 1 - .01; @@ -147,57 +147,57 @@ public class RenderSalinationController extends TileEntitySpecialRenderer toReturn.minX = -1 + .01; toReturn.minY = 0 + .01; toReturn.minZ = 0 + .01; - + toReturn.maxX = 1 - .01; toReturn.maxY = ((float)i/(float)stages)*data.height - .01; toReturn.maxZ = 2 - .01; break; } - + MekanismRenderer.renderObject(toReturn); } - + displays[i].endList(); } - + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - + return displays; } - + private int getStages(int height) { return height*(TankUpdateProtocol.FLUID_PER_TANK/10); } - + private double getX(int x) { return x - TileEntityRenderer.staticPlayerX; } - + private double getY(int y) { return y - TileEntityRenderer.staticPlayerY; } - + private double getZ(int z) { return z - TileEntityRenderer.staticPlayerZ; } - + public static class SalinationRenderData { public int height; public ForgeDirection side; - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + height; return code; } - + @Override public boolean equals(Object data) { diff --git a/common/mekanism/client/render/tileentity/RenderTeleporter.java b/common/mekanism/client/render/tileentity/RenderTeleporter.java index 254a0a00d..f261a1558 100644 --- a/common/mekanism/client/render/tileentity/RenderTeleporter.java +++ b/common/mekanism/client/render/tileentity/RenderTeleporter.java @@ -21,7 +21,7 @@ import org.lwjgl.opengl.GL11; public class RenderTeleporter extends TileEntitySpecialRenderer { private HashMap cachedOverlays = new HashMap(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { @@ -33,27 +33,27 @@ public class RenderTeleporter extends TileEntitySpecialRenderer if(tileEntity.shouldRender) { push(); - + GL11.glColor4f(EnumColor.PURPLE.getColor(0), EnumColor.PURPLE.getColor(1), EnumColor.PURPLE.getColor(2), 0.75F); - + bindTexture(MekanismRenderer.getBlocksTexture()); GL11.glTranslatef((float)x, (float)y, (float)z); - + Coord4D obj = Coord4D.get(tileEntity).getFromSide(ForgeDirection.WEST); int type = 0; - + if(obj.getBlockId(tileEntity.worldObj) == Mekanism.basicBlockID && obj.getMetadata(tileEntity.worldObj) == 7) { type = 1; } - + int display = getOverlayDisplay(type).display; GL11.glCallList(display); - + pop(); } } - + private void pop() { GL11.glPopAttrib(); @@ -61,7 +61,7 @@ public class RenderTeleporter extends TileEntitySpecialRenderer MekanismRenderer.blendOff(); GL11.glPopMatrix(); } - + private void push() { GL11.glPushMatrix(); @@ -71,20 +71,20 @@ public class RenderTeleporter extends TileEntitySpecialRenderer MekanismRenderer.glowOn(); MekanismRenderer.blendOn(); } - + private DisplayInteger getOverlayDisplay(Integer type) { if(cachedOverlays.containsKey(type)) { return cachedOverlays.get(type); } - + Model3D toReturn = new Model3D(); toReturn.baseBlock = Block.stone; toReturn.setTexture(GasRegistry.getGas("oxygen").getIcon()); - + DisplayInteger display = DisplayInteger.createAndStart(); - + if(cachedOverlays.containsKey(type)) { cachedOverlays.get(type); @@ -92,14 +92,14 @@ public class RenderTeleporter extends TileEntitySpecialRenderer else { cachedOverlays.put(type, display); } - + switch(type) { case 0: { toReturn.minY = 1; toReturn.maxY = 3; - + toReturn.minX = 0.46; toReturn.minZ = 0; toReturn.maxX = 0.54; @@ -110,7 +110,7 @@ public class RenderTeleporter extends TileEntitySpecialRenderer { toReturn.minY = 1; toReturn.maxY = 3; - + toReturn.minX = 0; toReturn.minZ = 0.46; toReturn.maxX = 1; @@ -118,10 +118,10 @@ public class RenderTeleporter extends TileEntitySpecialRenderer break; } } - + MekanismRenderer.renderObject(toReturn); display.endList(); - + return display; } } diff --git a/common/mekanism/client/sound/GasMaskSound.java b/common/mekanism/client/sound/GasMaskSound.java index 63a7f9374..050dc35e0 100644 --- a/common/mekanism/client/sound/GasMaskSound.java +++ b/common/mekanism/client/sound/GasMaskSound.java @@ -11,7 +11,7 @@ public class GasMaskSound extends PlayerSound { super(id, "GasMask.ogg", entity); } - + @Override public boolean update(World world) { @@ -35,15 +35,15 @@ public class GasMaskSound extends PlayerSound } } } - + if(isPlaying) { ticksSincePlay++; } - + return true; } - + private boolean hasGasMask(EntityPlayer player) { return player.inventory.armorInventory[3] != null && player.inventory.armorInventory[3].getItem() instanceof ItemGasMask; diff --git a/common/mekanism/client/sound/IHasSound.java b/common/mekanism/client/sound/IHasSound.java index 08606ae8a..58956b48a 100644 --- a/common/mekanism/client/sound/IHasSound.java +++ b/common/mekanism/client/sound/IHasSound.java @@ -5,14 +5,14 @@ package mekanism.client.sound; * @author AidanBrady * */ -public interface IHasSound +public interface IHasSound { /** * Gets the sound path of this block's sound. * @return sound path */ public String getSoundPath(); - + /** * Gets the multiplier to play this sound by. * @return sound multiplier diff --git a/common/mekanism/client/sound/JetpackSound.java b/common/mekanism/client/sound/JetpackSound.java index 748cead3e..4733cd63e 100644 --- a/common/mekanism/client/sound/JetpackSound.java +++ b/common/mekanism/client/sound/JetpackSound.java @@ -11,7 +11,7 @@ public class JetpackSound extends PlayerSound { super(id, "Jetpack.ogg", entity); } - + @Override public boolean update(World world) { @@ -35,15 +35,15 @@ public class JetpackSound extends PlayerSound } } } - + if(isPlaying) { ticksSincePlay++; } - + return true; } - + private boolean hasJetpack(EntityPlayer player) { return player.inventory.armorInventory[2] != null && player.inventory.armorInventory[2].getItem() instanceof ItemJetpack; diff --git a/common/mekanism/client/sound/PlayerSound.java b/common/mekanism/client/sound/PlayerSound.java index 248437512..5ec9ae2c7 100644 --- a/common/mekanism/client/sound/PlayerSound.java +++ b/common/mekanism/client/sound/PlayerSound.java @@ -8,20 +8,20 @@ public abstract class PlayerSound extends Sound { /** The TileEntity this sound is associated with. */ public EntityPlayer player; - + public PlayerSound(String id, String sound, EntityPlayer entity) { super(id, sound, entity, new Pos3D(entity)); - + player = entity; } - + @Override public float getMultiplier() { return super.getMultiplier()*0.3F; } - + @Override public boolean update(World world) { @@ -37,10 +37,10 @@ public abstract class PlayerSound extends Sound { return false; } - + return true; } - + @Override public Pos3D getLocation() { diff --git a/common/mekanism/client/sound/Sound.java b/common/mekanism/client/sound/Sound.java index 072df4edb..36558f40c 100644 --- a/common/mekanism/client/sound/Sound.java +++ b/common/mekanism/client/sound/Sound.java @@ -11,19 +11,19 @@ public abstract class Sound { /** The bundled path where the sound is */ public String soundPath; - + /** A unique identifier for this sound */ public String identifier; - + /** Whether or not this sound is playing */ public boolean isPlaying = false; - + public int ticksSincePlay = 0; - + private Object objRef; - + protected Minecraft mc = Minecraft.getMinecraft(); - + /** * A sound that runs off of the PaulsCode sound system. * @param id - unique identifier @@ -36,33 +36,33 @@ public abstract class Sound { return; } - + synchronized(MekanismClient.audioHandler.sounds) { soundPath = sound; identifier = id; objRef = obj; - + URL url = getClass().getClassLoader().getResource("assets/mekanism/sound/" + sound); - + if(url == null) { System.out.println("[Mekanism] Invalid sound file: " + sound); } - + if(SoundHandler.getSoundSystem() != null) { SoundHandler.getSoundSystem().newSource(false, id, url, sound, true, (float)loc.xPos, (float)loc.yPos, (float)loc.zPos, 0, 16F); updateVolume(); SoundHandler.getSoundSystem().activate(id); } - + MekanismClient.audioHandler.sounds.put(obj, this); } } - - /** - * Start looping the sound effect + + /** + * Start looping the sound effect */ public void play() { @@ -72,21 +72,21 @@ public abstract class Sound { return; } - + ticksSincePlay = 0; - + if(SoundHandler.getSoundSystem() != null) { updateVolume(); SoundHandler.getSoundSystem().play(identifier); } - + isPlaying = true; } } - - /** - * Stop looping the sound effect + + /** + * Stop looping the sound effect */ public void stopLoop() { @@ -96,19 +96,19 @@ public abstract class Sound { return; } - + if(SoundHandler.getSoundSystem() != null) { updateVolume(); SoundHandler.getSoundSystem().stop(identifier); } - + isPlaying = false; } } - - /** - * Remove the sound effect from the PaulsCode SoundSystem + + /** + * Remove the sound effect from the PaulsCode SoundSystem */ public void remove() { @@ -118,9 +118,9 @@ public abstract class Sound { stopLoop(); } - + MekanismClient.audioHandler.sounds.remove(objRef); - + if(SoundHandler.getSoundSystem() != null) { updateVolume(); @@ -128,38 +128,38 @@ public abstract class Sound } } } - + public abstract boolean update(World world); - + public abstract Pos3D getLocation(); - + public float getMultiplier() { return Math.min(1, ((float)ticksSincePlay/30F)); } - + /** * Updates the volume based on how far away the player is from the machine. * @param entityplayer - player who is near the machine, always Minecraft.thePlayer */ - public void updateVolume() - { + public void updateVolume() + { synchronized(MekanismClient.audioHandler.sounds) { try { float multiplier = getMultiplier(); - float volume = 0; - float masterVolume = MekanismClient.audioHandler.masterVolume; - - double distance = mc.thePlayer.getDistance(getLocation().xPos, getLocation().yPos, getLocation().zPos); - volume = (float)Math.min(Math.max(masterVolume-((distance*.08F)*masterVolume), 0)*multiplier, 1); - volume *= Math.max(0, Math.min(1, MekanismClient.baseSoundVolume)); - - if(SoundHandler.getSoundSystem() != null) - { - SoundHandler.getSoundSystem().setVolume(identifier, volume); - } + float volume = 0; + float masterVolume = MekanismClient.audioHandler.masterVolume; + + double distance = mc.thePlayer.getDistance(getLocation().xPos, getLocation().yPos, getLocation().zPos); + volume = (float)Math.min(Math.max(masterVolume-((distance*.08F)*masterVolume), 0)*multiplier, 1); + volume *= Math.max(0, Math.min(1, MekanismClient.baseSoundVolume)); + + if(SoundHandler.getSoundSystem() != null) + { + SoundHandler.getSoundSystem().setVolume(identifier, volume); + } } catch(Exception e) {} } - } + } } diff --git a/common/mekanism/client/sound/SoundHandler.java b/common/mekanism/client/sound/SoundHandler.java index a9281862e..b65fd1ce6 100644 --- a/common/mekanism/client/sound/SoundHandler.java +++ b/common/mekanism/client/sound/SoundHandler.java @@ -35,117 +35,117 @@ import cpw.mods.fml.relauncher.SideOnly; * */ @SideOnly(Side.CLIENT) -public class SoundHandler +public class SoundHandler { /** All the sound references in the Minecraft game. */ public Map sounds = Collections.synchronizedMap(new HashMap()); - + /** The current base volume Minecraft is using. */ public float masterVolume = 0; - + public Minecraft mc = Minecraft.getMinecraft(); - - /** + + /** * SoundHandler -- a class that handles all Sounds used by Mekanism. */ public SoundHandler() { MinecraftForge.EVENT_BUS.register(this); - + System.out.println("[Mekanism] Successfully set up SoundHandler."); } - + public void preloadSounds() { CodeSource src = getClass().getProtectionDomain().getCodeSource(); String corePath = src.getLocation().getFile().split("/mekanism/client")[0]; List listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sound"); - + for(String s : listings) { if(s.contains("etc") || s.contains("holiday")) { continue; } - + if(s.contains("/mekanism/sound/")) { s = s.split("/mekanism/sound/")[1]; } - + preloadSound(s); } - + System.out.println("[Mekanism] Preloaded " + listings.size() + " object sounds."); - + listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sound/etc"); - + for(String s : listings) { if(s.contains("/mekanism/sound/etc/")) { s = s.split("/mekanism/sound/etc/")[1]; } - + mc.sndManager.addSound("mekanism:etc/" + s); } - + System.out.println("[Mekanism] Initialized " + listings.size() + " sound effects."); - + if(MekanismClient.holidays) { listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sound/holiday"); - + for(String s : listings) { if(s.contains("/mekanism/sound/")) { s = s.split("/mekanism/sound/")[1]; } - + if(!s.contains("holiday")) { s = "holiday/" + s; } - + preloadSound(s); } } } - + private List listFiles(String path, String s) { List names = new ArrayList(); - + File f = new File(path); - + if(!f.exists()) { return names; } - + if(!f.isDirectory()) { try { ZipInputStream zip = new ZipInputStream(new FileInputStream(path)); - - while(true) + + while(true) { ZipEntry e = zip.getNextEntry(); - + if(e == null) { break; } - + String name = e.getName(); - + if(name.contains(s) && name.endsWith(".ogg")) { names.add(name); } } - + zip.close(); } catch(Exception e) { e.printStackTrace(); @@ -153,7 +153,7 @@ public class SoundHandler } else { f = new File(path + "/" + s); - + for(File file : f.listFiles()) { if(file.getPath().contains(s) && file.getName().endsWith(".ogg")) @@ -162,10 +162,10 @@ public class SoundHandler } } } - + return names; } - + private void preloadSound(String sound) { String id = "pre_" + sound; @@ -178,7 +178,7 @@ public class SoundHandler getSoundSystem().removeSource(id); } } - + /** * Ticks the sound handler. Should be called every Minecraft tick, or 20 times per second. */ @@ -192,7 +192,7 @@ public class SoundHandler { ArrayList soundsToRemove = new ArrayList(); World world = FMLClientHandler.instance().getClient().theWorld; - + for(Sound sound : sounds.values()) { if(FMLClientHandler.instance().getClient().thePlayer != null && world != null) @@ -204,12 +204,12 @@ public class SoundHandler } } } - + for(Sound sound : soundsToRemove) { sound.remove(); } - + for(Sound sound : sounds.values()) { if(sound.isPlaying) @@ -217,7 +217,7 @@ public class SoundHandler sound.updateVolume(); } } - + masterVolume = FMLClientHandler.instance().getClient().gameSettings.soundVolume; } else { @@ -235,7 +235,7 @@ public class SoundHandler } } } - + /** * Gets a sound object from a specific TileEntity, null if there is none. * @param tileEntity - the holder of the sound @@ -248,7 +248,7 @@ public class SoundHandler return sounds.get(obj); } } - + /** * Create and return an instance of a Sound. * @param tileEntity - the holder of this sound. @@ -260,7 +260,7 @@ public class SoundHandler { return; } - + synchronized(sounds) { if(getFrom(obj) == null) @@ -272,7 +272,7 @@ public class SoundHandler } } } - + /** * Get a unique identifier for a sound effect instance by combining the mod's name, * Mekanism, the new sound's unique position on the 'sounds' ArrayList, and a random @@ -284,7 +284,7 @@ public class SoundHandler synchronized(sounds) { String toReturn = "Mekanism_" + sounds.size() + "_" + new Random().nextInt(10000); - + for(Sound sound : sounds.values()) { if(sound.identifier.equals(toReturn)) @@ -292,11 +292,11 @@ public class SoundHandler return getIdentifier(); } } - + return toReturn; } } - + /** * Plays a sound in a specific location. * @param soundPath - sound path to play @@ -306,21 +306,21 @@ public class SoundHandler public void quickPlay(String soundPath, World world, Coord4D object) { URL url = getClass().getClassLoader().getResource("assets/mekanism/sound/" + soundPath); - + if(url == null) { System.out.println("[Mekanism] Invalid sound file: " + soundPath); } - + String s = getSoundSystem().quickPlay(false, url, soundPath, false, object.xCoord, object.yCoord, object.zCoord, 0, 16F); getSoundSystem().setVolume(s, masterVolume); } - + public static SoundSystem getSoundSystem() { return Minecraft.getMinecraft().sndManager.sndSystem; } - + @ForgeSubscribe public void onChunkUnload(ChunkEvent.Unload event) { @@ -331,7 +331,7 @@ public class SoundHandler if(obj instanceof TileEntity) { TileEntity tileEntity = (TileEntity)obj; - + if(tileEntity instanceof IHasSound) { if(getFrom(tileEntity) != null) diff --git a/common/mekanism/client/sound/TileSound.java b/common/mekanism/client/sound/TileSound.java index e2d7dd076..971efbb72 100644 --- a/common/mekanism/client/sound/TileSound.java +++ b/common/mekanism/client/sound/TileSound.java @@ -21,7 +21,7 @@ public class TileSound extends Sound { /** The TileEntity this sound is associated with. */ public TileEntity tileEntity; - + /** * A sound that runs off of the PaulsCode sound system. * @param id - unique identifier @@ -31,22 +31,22 @@ public class TileSound extends Sound public TileSound(String id, String sound, TileEntity tileentity) { super(id, sound, tileentity, new Pos3D(tileentity)); - + tileEntity = tileentity; } - + @Override public float getMultiplier() { return super.getMultiplier()*((IHasSound)tileEntity).getVolumeMultiplier(); } - + @Override public Pos3D getLocation() { return new Pos3D(tileEntity); } - + @Override public boolean update(World world) { @@ -75,12 +75,12 @@ public class TileSound extends Sound } } } - + if(isPlaying) { ticksSincePlay++; } - + return true; } } diff --git a/common/mekanism/client/voice/VoiceClient.java b/common/mekanism/client/voice/VoiceClient.java index fea78c88a..189ce3738 100644 --- a/common/mekanism/client/voice/VoiceClient.java +++ b/common/mekanism/client/voice/VoiceClient.java @@ -17,39 +17,39 @@ import cpw.mods.fml.relauncher.SideOnly; public class VoiceClient extends Thread { public Socket socket; - + public String ip; - + public AudioFormat format = new AudioFormat(11025.0F, 8, 1, true, true); - + public VoiceInput inputThread; public VoiceOutput outputThread; - + public DataInputStream input; public DataOutputStream output; - + public boolean running; - + public VoiceClient(String s) { ip = s; } - + @Override public void run() { System.out.println("[Mekanism] VoiceServer: Starting client connection..."); - + try { socket = new Socket(ip, Mekanism.VOICE_PORT); running = true; - + input = new DataInputStream(new BufferedInputStream(socket.getInputStream())); output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); - + (outputThread = new VoiceOutput(this)).start(); (inputThread = new VoiceInput(this)).start(); - + System.out.println("[Mekanism] VoiceServer: Successfully connected to server."); } catch(ConnectException e) { System.err.println("[Mekanism] VoiceServer: Server's VoiceServer is disabled."); @@ -58,43 +58,43 @@ public class VoiceClient extends Thread e.printStackTrace(); } } - + public void disconnect() { System.out.println("[Mekanism] VoiceServer: Stopping client connection..."); - + try { try { inputThread.interrupt(); outputThread.interrupt(); } catch(Exception e) {} - + try { interrupt(); } catch(Exception e) {} - + try { inputThread.close(); outputThread.close(); } catch(Exception e) {} - + try { output.flush(); output.close(); output = null; } catch(Exception e) {} - + try { input.close(); input = null; } catch(Exception e) {} - + try { socket.close(); socket = null; } catch(Exception e) {} - - + + running = false; } catch(Exception e) { System.err.println("[Mekanism] VoiceServer: Error while stopping client connection."); diff --git a/common/mekanism/client/voice/VoiceInput.java b/common/mekanism/client/voice/VoiceInput.java index 1f71c812c..6868c5cd0 100644 --- a/common/mekanism/client/voice/VoiceInput.java +++ b/common/mekanism/client/voice/VoiceInput.java @@ -13,20 +13,20 @@ import cpw.mods.fml.relauncher.SideOnly; public class VoiceInput extends Thread { public VoiceClient voiceClient; - + public DataLine.Info microphone; - + public TargetDataLine targetLine; - + public VoiceInput(VoiceClient client) { voiceClient = client; microphone = new DataLine.Info(TargetDataLine.class, voiceClient.format, 2200); - + setDaemon(true); setName("VoiceServer Client Input Thread"); } - + @Override public void run() { @@ -35,22 +35,22 @@ public class VoiceInput extends Thread targetLine.open(voiceClient.format, 2200); targetLine.start(); AudioInputStream audioInput = new AudioInputStream(targetLine); - + boolean doFlush = false; - + while(voiceClient.running) { if(MekanismKeyHandler.voiceKey.pressed) { targetLine.flush(); - + while(voiceClient.running && MekanismKeyHandler.voiceKey.pressed) { try { int availableBytes = audioInput.available(); byte[] audioData = new byte[availableBytes > 2200 ? 2200 : availableBytes]; int bytesRead = audioInput.read(audioData, 0, audioData.length); - + if(bytesRead > 0) { voiceClient.output.writeShort(audioData.length); @@ -58,11 +58,11 @@ public class VoiceInput extends Thread } } catch(Exception e) {} } - + try { Thread.sleep(200L); } catch(Exception e) {} - + doFlush = true; } else if(doFlush) @@ -70,22 +70,22 @@ public class VoiceInput extends Thread try { voiceClient.output.flush(); } catch(Exception e) {} - + doFlush = false; } - + try { Thread.sleep(20L); } catch(Exception e) {} } - + audioInput.close(); } catch(Exception e) { System.err.println("[Mekanism] VoiceServer: Error while running client input thread."); e.printStackTrace(); } } - + public void close() { targetLine.flush(); diff --git a/common/mekanism/client/voice/VoiceOutput.java b/common/mekanism/client/voice/VoiceOutput.java index ee666bb35..d8d14df34 100644 --- a/common/mekanism/client/voice/VoiceOutput.java +++ b/common/mekanism/client/voice/VoiceOutput.java @@ -11,20 +11,20 @@ import cpw.mods.fml.relauncher.SideOnly; public class VoiceOutput extends Thread { public VoiceClient voiceClient; - + public DataLine.Info speaker; - + public SourceDataLine sourceLine; - + public VoiceOutput(VoiceClient client) { voiceClient = client; speaker = new DataLine.Info(SourceDataLine.class, voiceClient.format, 2200); - + setDaemon(true); setName("VoiceServer Client Output Thread"); } - + @Override public void run() { @@ -32,14 +32,14 @@ public class VoiceOutput extends Thread sourceLine = ((SourceDataLine)AudioSystem.getLine(speaker)); sourceLine.open(voiceClient.format, 2200); sourceLine.start(); - + while(voiceClient.running) { try { short byteCount = voiceClient.input.readShort(); byte[] audioData = new byte[byteCount]; voiceClient.input.readFully(audioData); - + sourceLine.write(audioData, 0, audioData.length); } catch(Exception e) {} } @@ -48,7 +48,7 @@ public class VoiceOutput extends Thread e.printStackTrace(); } } - + public void close() { sourceLine.flush(); diff --git a/common/mekanism/common/BoxBlacklistParser.java b/common/mekanism/common/BoxBlacklistParser.java index 49ce4de78..63580a8a7 100644 --- a/common/mekanism/common/BoxBlacklistParser.java +++ b/common/mekanism/common/BoxBlacklistParser.java @@ -13,7 +13,7 @@ public final class BoxBlacklistParser { public static File mekanismDir = new File(Mekanism.proxy.getMinecraftDir(), "config/mekanism"); public static File boxBlacklistFile = new File(mekanismDir, "BoxBlacklist.txt"); - + public static void load() { try { @@ -23,18 +23,18 @@ public final class BoxBlacklistParser e.printStackTrace(); } } - + private static void generateFiles() throws IOException { mekanismDir.mkdirs(); - + if(!boxBlacklistFile.exists()) { boxBlacklistFile.createNewFile(); writeExamples(); } } - + private static boolean isInteger(String s) { try { @@ -45,52 +45,52 @@ public final class BoxBlacklistParser return false; } } - + private static void readBlacklist() throws IOException { BufferedReader reader = new BufferedReader(new FileReader(boxBlacklistFile)); int entries = 0; - + String readingLine; int line = 0; while((readingLine = reader.readLine()) != null) { line++; - + if(readingLine.startsWith("#")) { continue; } - + String[] split = readingLine.split(":"); - + if(split.length != 2 || !isInteger(split[0]) || !isInteger(split[1])) { System.err.println("[Mekanism] BoxBlacklist.txt: Couldn't parse blacklist data on line " + line); } - + MekanismAPI.addBoxBlacklist(Integer.parseInt(split[0]), Integer.parseInt(split[1])); entries++; } - + reader.close(); - + System.out.println("[Mekanism] Finished loading Cardboard Box blacklist (loaded " + entries + " entries)"); } - + private static void writeExamples() throws IOException { BufferedWriter writer = new BufferedWriter(new FileWriter(boxBlacklistFile)); - + writer.append("# Use this file to tell Mekanism which blocks should not be picked up by a cardboard box."); writer.newLine(); - + writer.append("# Proper syntax is \"ID:META\". Example (for stone):"); writer.newLine(); - + writer.append("# 1:0"); - + writer.flush(); writer.close(); } diff --git a/common/mekanism/common/CommandMekanism.java b/common/mekanism/common/CommandMekanism.java index 2eb0c8cd8..82022bfb8 100644 --- a/common/mekanism/common/CommandMekanism.java +++ b/common/mekanism/common/CommandMekanism.java @@ -18,83 +18,83 @@ public class CommandMekanism extends CommandBase { return MinecraftServer.getServer().isSinglePlayer() || super.canCommandSenderUseCommand(sender); } - + @Override - public String getCommandName() - { - return "mk"; - } - + public String getCommandName() + { + return "mk"; + } + @Override - public String getCommandUsage(ICommandSender sender) - { - return "/mk "; - } - + public String getCommandUsage(ICommandSender sender) + { + return "/mk "; + } + @Override public List getCommandAliases() { return Arrays.asList(new String[] {"mekanism", "mek"}); } - + @Override - public void processCommand(ICommandSender sender, String[] params) - { - if(params.length < 1) - { - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Version: " + EnumColor.DARK_GREY + Mekanism.versionNumber)); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Latest Version: " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber)); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Developed on Mac OS X 10.8 Mountain Lion")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Code, textures, and ideas by aidancbrady")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Recent News: " + EnumColor.INDIGO + Mekanism.recentNews)); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - else if(params.length == 1) - { - if(params[0].equalsIgnoreCase("help")) - { - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk" + EnumColor.GREY + " -- displays the main page.")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk help" + EnumColor.GREY + " -- displays this guide.")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk version" + EnumColor.GREY + " -- displays the version number.")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk latest" + EnumColor.GREY + " -- displays the latest version number.")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk news" + EnumColor.GREY + " -- displays most recent recent news.")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk debug" + EnumColor.GREY + " -- toggles Mekanism's debug mode.")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - else if(params[0].equalsIgnoreCase("version")) - { - if(!MekanismUtils.checkForUpdates((EntityPlayer)sender)) - { - if(Mekanism.updateNotifications || Mekanism.latestVersionNumber == null || Mekanism.recentNews == null || Mekanism.latestVersionNumber.equals("null")) - { - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Minecraft is in offline mode, could not check for updates.")); - } - else { - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Your client is up to date.")); - } - } - } - else if(params[0].equalsIgnoreCase("news")) - { - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Most recent news: " + EnumColor.INDIGO + Mekanism.recentNews)); - } - else if(params[0].equalsIgnoreCase("latest")) - { - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " The latest version for this mod is " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber + EnumColor.GREY + ".")); - } - else if(params[0].equalsIgnoreCase("debug")) - { - Mekanism.debug = !Mekanism.debug; - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Debug mode set to " + EnumColor.DARK_GREY + Mekanism.debug)); - } - else { - sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Unknown command. Type '" + EnumColor.INDIGO + "/mk help" + EnumColor.GREY + "' for help.")); - } - } - } - + public void processCommand(ICommandSender sender, String[] params) + { + if(params.length < 1) + { + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Version: " + EnumColor.DARK_GREY + Mekanism.versionNumber)); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Latest Version: " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber)); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Developed on Mac OS X 10.8 Mountain Lion")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Code, textures, and ideas by aidancbrady")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Recent News: " + EnumColor.INDIGO + Mekanism.recentNews)); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + } + else if(params.length == 1) + { + if(params[0].equalsIgnoreCase("help")) + { + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk" + EnumColor.GREY + " -- displays the main page.")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk help" + EnumColor.GREY + " -- displays this guide.")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk version" + EnumColor.GREY + " -- displays the version number.")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk latest" + EnumColor.GREY + " -- displays the latest version number.")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk news" + EnumColor.GREY + " -- displays most recent recent news.")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.INDIGO + " /mk debug" + EnumColor.GREY + " -- toggles Mekanism's debug mode.")); + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + } + else if(params[0].equalsIgnoreCase("version")) + { + if(!MekanismUtils.checkForUpdates((EntityPlayer)sender)) + { + if(Mekanism.updateNotifications || Mekanism.latestVersionNumber == null || Mekanism.recentNews == null || Mekanism.latestVersionNumber.equals("null")) + { + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Minecraft is in offline mode, could not check for updates.")); + } + else { + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Your client is up to date.")); + } + } + } + else if(params[0].equalsIgnoreCase("news")) + { + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Most recent news: " + EnumColor.INDIGO + Mekanism.recentNews)); + } + else if(params[0].equalsIgnoreCase("latest")) + { + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " The latest version for this mod is " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber + EnumColor.GREY + ".")); + } + else if(params[0].equalsIgnoreCase("debug")) + { + Mekanism.debug = !Mekanism.debug; + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Debug mode set to " + EnumColor.DARK_GREY + Mekanism.debug)); + } + else { + sender.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Unknown command. Type '" + EnumColor.INDIGO + "/mk help" + EnumColor.GREY + "' for help.")); + } + } + } + @Override public int compareTo(Object obj) { diff --git a/common/mekanism/common/CommonPlayerTickHandler.java b/common/mekanism/common/CommonPlayerTickHandler.java index e9c1d34cb..611c130bd 100644 --- a/common/mekanism/common/CommonPlayerTickHandler.java +++ b/common/mekanism/common/CommonPlayerTickHandler.java @@ -28,65 +28,65 @@ public class CommonPlayerTickHandler implements ITickHandler if(tickData[0] instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)tickData[0]; - + if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter) { ItemPortableTeleporter item = (ItemPortableTeleporter)player.getCurrentEquippedItem().getItem(); ItemStack itemstack = player.getCurrentEquippedItem(); - - Teleporter.Code teleCode = new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3)); - - if(Mekanism.teleporters.containsKey(teleCode)) - { - if(Mekanism.teleporters.get(teleCode).size() > 0 && Mekanism.teleporters.get(teleCode).size() <= 2) - { - int energyNeeded = item.calculateEnergyCost(player, MekanismUtils.getClosestCoords(teleCode, player)); - - if(item.getEnergy(itemstack) < energyNeeded) - { - if(item.getStatus(itemstack) != 2) - { - item.setStatus(itemstack, 2); - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(2), player); - } - } - else { - if(item.getStatus(itemstack) != 1) - { - item.setStatus(itemstack, 1); - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(1), player); - } - } - return; - } - else if(Mekanism.teleporters.get(teleCode).size() > 2) - { - if(item.getStatus(itemstack) != 3) - { - item.setStatus(itemstack, 3); - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(3), player); - } - return; - } - else { - if(item.getStatus(itemstack) != 4) - { - item.setStatus(itemstack, 4); - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(4), player); - } - return; - } - } - else { - if(item.getStatus(itemstack) != 4) - { - item.setStatus(itemstack, 4); - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(4), player); - } - return; - } + + Teleporter.Code teleCode = new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3)); + + if(Mekanism.teleporters.containsKey(teleCode)) + { + if(Mekanism.teleporters.get(teleCode).size() > 0 && Mekanism.teleporters.get(teleCode).size() <= 2) + { + int energyNeeded = item.calculateEnergyCost(player, MekanismUtils.getClosestCoords(teleCode, player)); + + if(item.getEnergy(itemstack) < energyNeeded) + { + if(item.getStatus(itemstack) != 2) + { + item.setStatus(itemstack, 2); + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(2), player); + } + } + else { + if(item.getStatus(itemstack) != 1) + { + item.setStatus(itemstack, 1); + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(1), player); + } + } + return; + } + else if(Mekanism.teleporters.get(teleCode).size() > 2) + { + if(item.getStatus(itemstack) != 3) + { + item.setStatus(itemstack, 3); + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(3), player); + } + return; + } + else { + if(item.getStatus(itemstack) != 4) + { + item.setStatus(itemstack, 4); + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(4), player); + } + return; + } + } + else { + if(item.getStatus(itemstack) != 4) + { + item.setStatus(itemstack, 4); + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketStatusUpdate().setParams(4), player); + } + return; + } } - + if(player.getCurrentItemOrArmor(1) != null && player.getCurrentItemOrArmor(1).getItem() instanceof ItemFreeRunners) { player.stepHeight = 1.002F; @@ -97,11 +97,11 @@ public class CommonPlayerTickHandler implements ITickHandler player.stepHeight = 0.5F; } } - + if(isJetpackOn(player)) { ItemJetpack jetpack = (ItemJetpack)player.getCurrentItemOrArmor(3).getItem(); - + if(jetpack.getMode(player.getCurrentItemOrArmor(3)) == JetpackMode.NORMAL) { player.motionY = Math.min(player.motionY + 0.15D, 0.5D); @@ -130,38 +130,38 @@ public class CommonPlayerTickHandler implements ITickHandler } } } - + player.fallDistance = 0.0F; - + if(player instanceof EntityPlayerMP) { ((EntityPlayerMP)player).playerNetServerHandler.ticksForFloatKick = 0; } - + jetpack.useGas(player.getCurrentItemOrArmor(3)); } - + if(isGasMaskOn(player)) { ItemScubaTank tank = (ItemScubaTank)player.getCurrentItemOrArmor(3).getItem(); - + tank.useGas(player.getCurrentItemOrArmor(3)); player.setAir(300); player.clearActivePotions(); } } } - + public boolean isJetpackOn(EntityPlayer player) { ItemStack stack = player.inventory.armorInventory[2]; - + if(stack != null) { if(stack.getItem() instanceof ItemJetpack) { ItemJetpack jetpack = (ItemJetpack)stack.getItem(); - + if(jetpack.getGas(stack) != null) { if((Mekanism.keyMap.has(player, KeySync.ASCEND) && jetpack.getMode(stack) == JetpackMode.NORMAL)) @@ -175,21 +175,21 @@ public class CommonPlayerTickHandler implements ITickHandler } } } - + return false; } - + public static boolean isGasMaskOn(EntityPlayer player) { ItemStack tank = player.inventory.armorInventory[2]; ItemStack mask = player.inventory.armorInventory[3]; - + if(tank != null && mask != null) { if(tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) { ItemScubaTank scubaTank = (ItemScubaTank)tank.getItem(); - + if(scubaTank.getGas(tank) != null) { if(scubaTank.getFlowing(tank)) @@ -199,7 +199,7 @@ public class CommonPlayerTickHandler implements ITickHandler } } } - + return false; } diff --git a/common/mekanism/common/CommonPlayerTracker.java b/common/mekanism/common/CommonPlayerTracker.java index c8739f240..d8cd5d214 100644 --- a/common/mekanism/common/CommonPlayerTracker.java +++ b/common/mekanism/common/CommonPlayerTracker.java @@ -12,7 +12,7 @@ import cpw.mods.fml.common.IPlayerTracker; public class CommonPlayerTracker implements IPlayerTracker { @Override - public void onPlayerLogin(EntityPlayer player) + public void onPlayerLogin(EntityPlayer player) { if(!player.worldObj.isRemote) { @@ -20,7 +20,7 @@ public class CommonPlayerTracker implements IPlayerTracker PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketBoxBlacklist().setParams(), player); PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketJetpackData().setParams(JetpackPacket.FULL), player); PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketScubaTankData().setParams(ScubaTankPacket.FULL), player); - + System.out.println("[Mekanism] Sent config to '" + player.username + ".'"); } } @@ -36,7 +36,7 @@ public class CommonPlayerTracker implements IPlayerTracker public void onPlayerChangedDimension(EntityPlayer player) { Mekanism.jetpackOn.remove(player); - + if(!player.worldObj.isRemote) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketJetpackData().setParams(JetpackPacket.FULL), player); diff --git a/common/mekanism/common/CommonProxy.java b/common/mekanism/common/CommonProxy.java index 4b2108e3f..faf91d703 100644 --- a/common/mekanism/common/CommonProxy.java +++ b/common/mekanism/common/CommonProxy.java @@ -91,7 +91,7 @@ public class CommonProxy /** * Register tile entities that have special models. Overwritten in client to register TESRs. */ - public void registerSpecialTileEntities() + public void registerSpecialTileEntities() { GameRegistry.registerTileEntity(TileEntityEnrichmentChamber.class, "EnrichmentChamber"); GameRegistry.registerTileEntity(TileEntityOsmiumCompressor.class, "OsmiumCompressor"); @@ -128,19 +128,19 @@ public class CommonProxy GameRegistry.registerTileEntity(TileEntityChemicalWasher.class, "ChemicalWasher"); GameRegistry.registerTileEntity(TileEntityChemicalCrystalizer.class, "ChemicalCrystalizer"); } - + /** * Registers a client-side sound, assigned to a TileEntity. * @param obj - TileEntity who is registering the sound */ public void registerSound(Object obj) {} - + /** * Unregisters a client-side sound, assigned to a TileEntity; * @param tileEntity - TileEntity who is unregistering the sound */ public void unregisterSound(TileEntity tileEntity) {} - + /** * Handles an ELECTRIC_CHEST_CLIENT_OPEN packet via the proxy, not handled on the server-side. * @param entityplayer - player the packet was sent from @@ -152,22 +152,22 @@ public class CommonProxy * @param z - z coordinate */ public void openElectricChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z) {} - + /** * Register and load client-only render information. */ public void registerRenderInformation() {} - + /** * Gets the armor index number from ClientProxy. * @param string - armor indicator * @return armor index number */ - public int getArmorIndex(String string) + public int getArmorIndex(String string) { return 0; } - + /** * Set and load the mod's common configuration properties. */ @@ -180,41 +180,41 @@ public class CommonProxy Mekanism.machineBlockID = Mekanism.configuration.getBlock("MachineBlock", Mekanism.BLOCK_ID++).getInt(); Mekanism.machineBlock2ID = Mekanism.configuration.getBlock("MachineBlock2", Mekanism.BLOCK_ID++).getInt(); Mekanism.cardboardBoxID = Mekanism.configuration.getBlock("CardboardBox", Mekanism.BLOCK_ID++).getInt(); - Mekanism.obsidianTNTID = Mekanism.configuration.getBlock("ObsidianTNT", Mekanism.BLOCK_ID++).getInt(); - Mekanism.energyCubeID = Mekanism.configuration.getBlock("EnergyCube", Mekanism.BLOCK_ID++).getInt(); - Mekanism.gasTankID = Mekanism.configuration.getBlock("GasTank", Mekanism.BLOCK_ID++).getInt(); - Mekanism.boundingBlockID = Mekanism.configuration.getBlock("BoundingBlock", Mekanism.BLOCK_ID++).getInt(); - - Mekanism.osmiumGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OsmiumGenerationEnabled", true).getBoolean(true); - Mekanism.copperGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "CopperGenerationEnabled", true).getBoolean(true); - Mekanism.tinGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "TinGenerationEnabled", true).getBoolean(true); - Mekanism.disableBCSteelCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCSteelCrafting", false).getBoolean(false); - Mekanism.disableBCBronzeCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCBronzeCrafting", false).getBoolean(false); - Mekanism.updateNotifications = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpdateNotifications", true).getBoolean(true); - Mekanism.controlCircuitOreDict = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true).getBoolean(true); - Mekanism.logPackets = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "LogPackets", false).getBoolean(false); - Mekanism.dynamicTankEasterEgg = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false).getBoolean(true); - Mekanism.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean(true); - Mekanism.forceBuildcraft = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ForceBuildcraftPower", false).getBoolean(false); - Mekanism.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean(true); - Mekanism.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt(); - Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); - Mekanism.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt(); - Mekanism.osmiumGenerationAmount = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OsmiumGenerationAmount", 12).getInt(); - Mekanism.copperGenerationAmount = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "CopperGenerationAmount", 16).getInt(); - Mekanism.tinGenerationAmount = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "TinGenerationAmount", 14).getInt(); - Mekanism.FROM_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToEU", 10D).getDouble(10D); - Mekanism.TO_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EUToJoules", .1D).getDouble(.1D); - Mekanism.FROM_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToMJ", 25D).getDouble(25D); - Mekanism.TO_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MJToJoules", .04D).getDouble(.04D); - Mekanism.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D).getDouble(10000D); - Mekanism.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123).getInt(); + Mekanism.obsidianTNTID = Mekanism.configuration.getBlock("ObsidianTNT", Mekanism.BLOCK_ID++).getInt(); + Mekanism.energyCubeID = Mekanism.configuration.getBlock("EnergyCube", Mekanism.BLOCK_ID++).getInt(); + Mekanism.gasTankID = Mekanism.configuration.getBlock("GasTank", Mekanism.BLOCK_ID++).getInt(); + Mekanism.boundingBlockID = Mekanism.configuration.getBlock("BoundingBlock", Mekanism.BLOCK_ID++).getInt(); + + Mekanism.osmiumGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OsmiumGenerationEnabled", true).getBoolean(true); + Mekanism.copperGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "CopperGenerationEnabled", true).getBoolean(true); + Mekanism.tinGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "TinGenerationEnabled", true).getBoolean(true); + Mekanism.disableBCSteelCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCSteelCrafting", false).getBoolean(false); + Mekanism.disableBCBronzeCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCBronzeCrafting", false).getBoolean(false); + Mekanism.updateNotifications = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpdateNotifications", true).getBoolean(true); + Mekanism.controlCircuitOreDict = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true).getBoolean(true); + Mekanism.logPackets = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "LogPackets", false).getBoolean(false); + Mekanism.dynamicTankEasterEgg = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false).getBoolean(true); + Mekanism.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean(true); + Mekanism.forceBuildcraft = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ForceBuildcraftPower", false).getBoolean(false); + Mekanism.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean(true); + Mekanism.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt(); + Mekanism.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); + Mekanism.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt(); + Mekanism.osmiumGenerationAmount = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OsmiumGenerationAmount", 12).getInt(); + Mekanism.copperGenerationAmount = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "CopperGenerationAmount", 16).getInt(); + Mekanism.tinGenerationAmount = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "TinGenerationAmount", 14).getInt(); + Mekanism.FROM_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToEU", 10D).getDouble(10D); + Mekanism.TO_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EUToJoules", .1D).getDouble(.1D); + Mekanism.FROM_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToMJ", 25D).getDouble(25D); + Mekanism.TO_BC = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MJToJoules", .04D).getDouble(.04D); + Mekanism.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D).getDouble(10000D); + Mekanism.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123).getInt(); //If this is less than 1, upgrades make machines worse. If less than 0, I don't even know. - Mekanism.maxUpgradeMultiplier = Math.max(1, Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpgradeModifier", 10).getInt()); - - Mekanism.TO_TE = Mekanism.TO_BC*10; - Mekanism.FROM_TE = Mekanism.FROM_BC/10; - + Mekanism.maxUpgradeMultiplier = Math.max(1, Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpgradeModifier", 10).getInt()); + + Mekanism.TO_TE = Mekanism.TO_BC*10; + Mekanism.FROM_TE = Mekanism.FROM_BC/10; + if(Mekanism.cardboardSpawners) { MekanismAPI.removeBoxBlacklist(Block.mobSpawner.blockID, 0); @@ -222,7 +222,7 @@ public class CommonProxy else { MekanismAPI.addBoxBlacklist(Block.mobSpawner.blockID, 0); } - + Mekanism.enrichmentChamberUsage = Mekanism.configuration.get("usage", "EnrichmentChamberUsage", 50D).getDouble(50D); Mekanism.osmiumCompressorUsage = Mekanism.configuration.get("usage", "OsmiumCompressorUsage", 100D).getDouble(100D); Mekanism.combinerUsage = Mekanism.configuration.get("usage", "CombinerUsage", 50D).getDouble(50D); @@ -241,9 +241,9 @@ public class CommonProxy Mekanism.chemicalDissolutionChamberUsage = Mekanism.configuration.get("usage", "ChemicalDissolutionChamberUsage", 400D).getDouble(400D); Mekanism.chemicalWasherUsage = Mekanism.configuration.get("usage", "ChemicalWasherUsage", 200D).getDouble(200D); Mekanism.chemicalCrystalizerUsage = Mekanism.configuration.get("usage", "ChemicalCrystalizerUsage", 400D).getDouble(400D); - Mekanism.configuration.save(); + Mekanism.configuration.save(); } - + /** * Set up and load the utilities this mod uses. */ @@ -252,30 +252,30 @@ public class CommonProxy TickRegistry.registerTickHandler(new CommonPlayerTickHandler(), Side.SERVER); TickRegistry.registerTickHandler(new CommonWorldTickHandler(), Side.SERVER); } - + /** * Set up and load the sound handler. */ public void loadSoundHandler() {} - + /** * Unload the sound handler. */ public void unloadSoundHandler() {} - - /** - * Whether or not the game is paused. + + /** + * Whether or not the game is paused. */ - public boolean isPaused() + public boolean isPaused() { return false; } - + /** * Does the Dynamic Tank creation animation, starting from the rendering block. */ public void doTankAnimation(TileEntityDynamicTank tileEntity) {} - + /** * Get the actual interface for a GUI. Client-only. * @param ID - gui ID @@ -286,11 +286,11 @@ public class CommonProxy * @param z - gui's z position * @return the GuiScreen of the GUI */ - public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } - + /** * Get the container for a GUI. Common. * @param ID - gui ID @@ -301,10 +301,10 @@ public class CommonProxy * @param z - gui's z position * @return the Container of the GUI */ - public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + switch(ID) { case 0: @@ -343,7 +343,7 @@ public class CommonProxy return new ContainerDynamicTank(player.inventory, (TileEntityDynamicTank)tileEntity); case 21: EntityRobit robit = (EntityRobit)world.getEntityByID(x); - + if(robit != null) { return new ContainerRobitMain(player.inventory, robit); @@ -352,14 +352,14 @@ public class CommonProxy return new ContainerRobitCrafting(player.inventory, world); case 23: EntityRobit robit1 = (EntityRobit)world.getEntityByID(x); - + if(robit1 != null) { return new ContainerRobitInventory(player.inventory, robit1); } case 24: EntityRobit robit2 = (EntityRobit)world.getEntityByID(x); - + if(robit2 != null) { return new ContainerRobitSmelting(player.inventory, robit2); @@ -391,22 +391,22 @@ public class CommonProxy case 37: return new ContainerChemicalCrystalizer(player.inventory, (TileEntityChemicalCrystalizer)tileEntity); } - + return null; } - + public void preInit() {} - + public double getReach(EntityPlayer player) { if(player instanceof EntityPlayerMP) { return ((EntityPlayerMP)player).theItemInWorldManager.getBlockReachDistance(); } - + return 0; } - + /** * Gets the Minecraft base directory. * @return base directory @@ -415,8 +415,8 @@ public class CommonProxy { return (File)FMLInjectionData.data()[6]; } - - public void onConfigSync() + + public void onConfigSync() { if(Mekanism.cardboardSpawners) { @@ -425,7 +425,7 @@ public class CommonProxy else { MekanismAPI.addBoxBlacklist(Block.mobSpawner.blockID, 0); } - + System.out.println("[Mekanism] Received config from server."); } } diff --git a/common/mekanism/common/CommonWorldTickHandler.java b/common/mekanism/common/CommonWorldTickHandler.java index 62ac7de47..88cc8e3e3 100644 --- a/common/mekanism/common/CommonWorldTickHandler.java +++ b/common/mekanism/common/CommonWorldTickHandler.java @@ -27,39 +27,39 @@ public class CommonWorldTickHandler implements ITickHandler { ArrayList idsToKill = new ArrayList(); HashMap> tilesToKill = new HashMap>(); - + World world = (World)tickData[0]; - + if(!world.isRemote) { for(Map.Entry entry : Mekanism.dynamicInventories.entrySet()) { int inventoryID = entry.getKey(); - + for(Coord4D obj : entry.getValue().locations) { if(obj.dimensionId == world.provider.dimensionId) { TileEntity tileEntity = obj.getTileEntity(world); - + if(!(tileEntity instanceof TileEntityDynamicTank) || ((TileEntityDynamicTank)tileEntity).inventoryID != inventoryID) { if(!tilesToKill.containsKey(inventoryID)) { tilesToKill.put(inventoryID, new HashSet()); } - + tilesToKill.get(inventoryID).add(obj); } } } - + if(entry.getValue().locations.isEmpty()) { idsToKill.add(inventoryID); } } - + for(Map.Entry> entry : tilesToKill.entrySet()) { for(Coord4D obj : entry.getValue()) @@ -67,13 +67,13 @@ public class CommonWorldTickHandler implements ITickHandler Mekanism.dynamicInventories.get(entry.getKey()).locations.remove(obj); } } - + for(int inventoryID : idsToKill) - { + { for(Coord4D obj : Mekanism.dynamicInventories.get(inventoryID).locations) { TileEntityDynamicTank dynamicTank = (TileEntityDynamicTank)obj.getTileEntity(world); - + if(dynamicTank != null) { dynamicTank.cachedFluid = null; @@ -81,7 +81,7 @@ public class CommonWorldTickHandler implements ITickHandler dynamicTank.inventoryID = -1; } } - + Mekanism.dynamicInventories.remove(inventoryID); } } diff --git a/common/mekanism/common/ConnectedTextureRenderer.java b/common/mekanism/common/ConnectedTextureRenderer.java index ff6a6e817..dcfed64d7 100644 --- a/common/mekanism/common/ConnectedTextureRenderer.java +++ b/common/mekanism/common/ConnectedTextureRenderer.java @@ -14,87 +14,87 @@ import cpw.mods.fml.relauncher.SideOnly; public class ConnectedTextureRenderer { public static final byte[][] sideEdges = {{2, 5, 3, 4}, {2, 5, 3, 4}, {1, 4, 0, 5}, {1, 5, 0, 4}, {1, 3, 0, 2}, {1, 2, 0, 3}}; - + public int blockID; public int metadata; - + public String iconTitle; - + public Map glassMap = new HashMap(); - + public ConnectedTextureRenderer(String title, int id, int meta) { iconTitle = title; blockID = id; metadata = meta; } - + @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) { - glassMap.put(0, register.registerIcon("mekanism:" + iconTitle + "_13")); - glassMap.put(1, register.registerIcon("mekanism:" + iconTitle + "_20")); - glassMap.put(4, register.registerIcon("mekanism:" + iconTitle + "_19")); - glassMap.put(5, register.registerIcon("mekanism:" + iconTitle + "_23")); - glassMap.put(7, register.registerIcon("mekanism:" + iconTitle + "_1")); - glassMap.put(16, register.registerIcon("mekanism:" + iconTitle + "_7")); - glassMap.put(17, register.registerIcon("mekanism:" + iconTitle + "_35")); - glassMap.put(20, register.registerIcon("mekanism:" + iconTitle + "_40")); - glassMap.put(21, register.registerIcon("mekanism:" + iconTitle + "_21")); - glassMap.put(23, register.registerIcon("mekanism:" + iconTitle + "_31")); - glassMap.put(28, register.registerIcon("mekanism:" + iconTitle + "_14")); - glassMap.put(29, register.registerIcon("mekanism:" + iconTitle + "_45")); - glassMap.put(31, register.registerIcon("mekanism:" + iconTitle + "_2")); - glassMap.put(64, register.registerIcon("mekanism:" + iconTitle + "_8")); - glassMap.put(65, register.registerIcon("mekanism:" + iconTitle + "_41")); - glassMap.put(68, register.registerIcon("mekanism:" + iconTitle + "_46")); - glassMap.put(69, register.registerIcon("mekanism:" + iconTitle + "_22")); - glassMap.put(71, register.registerIcon("mekanism:" + iconTitle + "_32")); - glassMap.put(80, register.registerIcon("mekanism:" + iconTitle + "_11")); - glassMap.put(81, register.registerIcon("mekanism:" + iconTitle + "_10")); - glassMap.put(84, register.registerIcon("mekanism:" + iconTitle + "_9")); - glassMap.put(85, register.registerIcon("mekanism:" + iconTitle + "_17")); - glassMap.put(87, register.registerIcon("mekanism:" + iconTitle + "_5")); - glassMap.put(92, register.registerIcon("mekanism:" + iconTitle + "_34")); - glassMap.put(93, register.registerIcon("mekanism:" + iconTitle + "_18")); - glassMap.put(95, register.registerIcon("mekanism:" + iconTitle + "_6")); - glassMap.put(112, register.registerIcon("mekanism:" + iconTitle + "_25")); - glassMap.put(113, register.registerIcon("mekanism:" + iconTitle + "_43")); - glassMap.put(116, register.registerIcon("mekanism:" + iconTitle + "_42")); - glassMap.put(117, register.registerIcon("mekanism:" + iconTitle + "_29")); - glassMap.put(119, register.registerIcon("mekanism:" + iconTitle + "_37")); - glassMap.put(124, register.registerIcon("mekanism:" + iconTitle + "_26")); - glassMap.put(125, register.registerIcon("mekanism:" + iconTitle + "_30")); - glassMap.put(127, register.registerIcon("mekanism:" + iconTitle + "_38")); - glassMap.put(193, register.registerIcon("mekanism:" + iconTitle + "_12")); - glassMap.put(197, register.registerIcon("mekanism:" + iconTitle + "_44")); - glassMap.put(199, register.registerIcon("mekanism:" + iconTitle + "_0")); - glassMap.put(209, register.registerIcon("mekanism:" + iconTitle + "_33")); - glassMap.put(213, register.registerIcon("mekanism:" + iconTitle + "_16")); - glassMap.put(215, register.registerIcon("mekanism:" + iconTitle + "_4")); - glassMap.put(221, register.registerIcon("mekanism:" + iconTitle + "_15")); - glassMap.put(223, register.registerIcon("mekanism:" + iconTitle + "_3")); - glassMap.put(241, register.registerIcon("mekanism:" + iconTitle + "_24")); - glassMap.put(245, register.registerIcon("mekanism:" + iconTitle + "_28")); - glassMap.put(247, register.registerIcon("mekanism:" + iconTitle + "_36")); - glassMap.put(253, register.registerIcon("mekanism:" + iconTitle + "_27")); - glassMap.put(255, register.registerIcon("mekanism:" + iconTitle + "_39")); + glassMap.put(0, register.registerIcon("mekanism:" + iconTitle + "_13")); + glassMap.put(1, register.registerIcon("mekanism:" + iconTitle + "_20")); + glassMap.put(4, register.registerIcon("mekanism:" + iconTitle + "_19")); + glassMap.put(5, register.registerIcon("mekanism:" + iconTitle + "_23")); + glassMap.put(7, register.registerIcon("mekanism:" + iconTitle + "_1")); + glassMap.put(16, register.registerIcon("mekanism:" + iconTitle + "_7")); + glassMap.put(17, register.registerIcon("mekanism:" + iconTitle + "_35")); + glassMap.put(20, register.registerIcon("mekanism:" + iconTitle + "_40")); + glassMap.put(21, register.registerIcon("mekanism:" + iconTitle + "_21")); + glassMap.put(23, register.registerIcon("mekanism:" + iconTitle + "_31")); + glassMap.put(28, register.registerIcon("mekanism:" + iconTitle + "_14")); + glassMap.put(29, register.registerIcon("mekanism:" + iconTitle + "_45")); + glassMap.put(31, register.registerIcon("mekanism:" + iconTitle + "_2")); + glassMap.put(64, register.registerIcon("mekanism:" + iconTitle + "_8")); + glassMap.put(65, register.registerIcon("mekanism:" + iconTitle + "_41")); + glassMap.put(68, register.registerIcon("mekanism:" + iconTitle + "_46")); + glassMap.put(69, register.registerIcon("mekanism:" + iconTitle + "_22")); + glassMap.put(71, register.registerIcon("mekanism:" + iconTitle + "_32")); + glassMap.put(80, register.registerIcon("mekanism:" + iconTitle + "_11")); + glassMap.put(81, register.registerIcon("mekanism:" + iconTitle + "_10")); + glassMap.put(84, register.registerIcon("mekanism:" + iconTitle + "_9")); + glassMap.put(85, register.registerIcon("mekanism:" + iconTitle + "_17")); + glassMap.put(87, register.registerIcon("mekanism:" + iconTitle + "_5")); + glassMap.put(92, register.registerIcon("mekanism:" + iconTitle + "_34")); + glassMap.put(93, register.registerIcon("mekanism:" + iconTitle + "_18")); + glassMap.put(95, register.registerIcon("mekanism:" + iconTitle + "_6")); + glassMap.put(112, register.registerIcon("mekanism:" + iconTitle + "_25")); + glassMap.put(113, register.registerIcon("mekanism:" + iconTitle + "_43")); + glassMap.put(116, register.registerIcon("mekanism:" + iconTitle + "_42")); + glassMap.put(117, register.registerIcon("mekanism:" + iconTitle + "_29")); + glassMap.put(119, register.registerIcon("mekanism:" + iconTitle + "_37")); + glassMap.put(124, register.registerIcon("mekanism:" + iconTitle + "_26")); + glassMap.put(125, register.registerIcon("mekanism:" + iconTitle + "_30")); + glassMap.put(127, register.registerIcon("mekanism:" + iconTitle + "_38")); + glassMap.put(193, register.registerIcon("mekanism:" + iconTitle + "_12")); + glassMap.put(197, register.registerIcon("mekanism:" + iconTitle + "_44")); + glassMap.put(199, register.registerIcon("mekanism:" + iconTitle + "_0")); + glassMap.put(209, register.registerIcon("mekanism:" + iconTitle + "_33")); + glassMap.put(213, register.registerIcon("mekanism:" + iconTitle + "_16")); + glassMap.put(215, register.registerIcon("mekanism:" + iconTitle + "_4")); + glassMap.put(221, register.registerIcon("mekanism:" + iconTitle + "_15")); + glassMap.put(223, register.registerIcon("mekanism:" + iconTitle + "_3")); + glassMap.put(241, register.registerIcon("mekanism:" + iconTitle + "_24")); + glassMap.put(245, register.registerIcon("mekanism:" + iconTitle + "_28")); + glassMap.put(247, register.registerIcon("mekanism:" + iconTitle + "_36")); + glassMap.put(253, register.registerIcon("mekanism:" + iconTitle + "_27")); + glassMap.put(255, register.registerIcon("mekanism:" + iconTitle + "_39")); } - - @SideOnly(Side.CLIENT) + + @SideOnly(Side.CLIENT) public Icon getIcon(IBlockAccess world, int x, int y, int z, int side) { int map = 0; - + for(int face = 0; face < 4; face++) { int side0 = sideEdges[side][((face + 3) % 4)]; int side1 = sideEdges[side][face]; - if(!canConnect(world, new Coord4D(x, y, z), sideEdges[side][face], side)) + if(!canConnect(world, new Coord4D(x, y, z), sideEdges[side][face], side)) { map |= (7 << face * 2) % 256 | 7 >>> 8 - face * 2; - } + } else if(!canConnect(world, new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side0)), side1, side)) { map |= 1 << face * 2; @@ -110,12 +110,12 @@ public class ConnectedTextureRenderer private boolean canConnect(IBlockAccess access, Coord4D obj, int side, int face) { - Coord4D block = obj.getFromSide(ForgeDirection.getOrientation(side)); - Coord4D blockabove = obj.getFromSide(ForgeDirection.getOrientation(face)); + Coord4D block = obj.getFromSide(ForgeDirection.getOrientation(side)); + Coord4D blockabove = obj.getFromSide(ForgeDirection.getOrientation(face)); - return (block.getBlockId(access) == blockID && block.getMetadata(access) == metadata) && (blockabove.getBlockId(access) != blockID || blockabove.getMetadata(access) != metadata); + return (block.getBlockId(access) == blockID && block.getMetadata(access) == metadata) && (blockabove.getBlockId(access) != blockID || blockabove.getMetadata(access) != metadata); } - + @SideOnly(Side.CLIENT) public boolean shouldRenderSide(IBlockAccess world, int x, int y, int z, int side) { diff --git a/common/mekanism/common/CoreGuiHandler.java b/common/mekanism/common/CoreGuiHandler.java index 263ec23cd..fdf9f934d 100644 --- a/common/mekanism/common/CoreGuiHandler.java +++ b/common/mekanism/common/CoreGuiHandler.java @@ -5,7 +5,7 @@ import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; /** - * Client and server GUI hander for Mekanism. + * Client and server GUI hander for Mekanism. * Uses CommonProxy to get the server GUI and ClientProxy for the client GUI. * @author AidanBrady * @@ -13,13 +13,13 @@ import cpw.mods.fml.common.network.IGuiHandler; public class CoreGuiHandler implements IGuiHandler { @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return Mekanism.proxy.getServerGui(ID, player, world, x, y, z); } @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return Mekanism.proxy.getClientGui(ID, player, world, x, y, z); } diff --git a/common/mekanism/common/CreativeTabMekanism.java b/common/mekanism/common/CreativeTabMekanism.java index b7545e482..3d39433d0 100644 --- a/common/mekanism/common/CreativeTabMekanism.java +++ b/common/mekanism/common/CreativeTabMekanism.java @@ -9,7 +9,7 @@ public class CreativeTabMekanism extends CreativeTabs { super("tabMekanism"); } - + @Override public ItemStack getIconItemStack() { diff --git a/common/mekanism/common/EnergyDisplay.java b/common/mekanism/common/EnergyDisplay.java index a7641006e..1a566d21d 100644 --- a/common/mekanism/common/EnergyDisplay.java +++ b/common/mekanism/common/EnergyDisplay.java @@ -7,12 +7,12 @@ public class EnergyDisplay { public static enum ElectricUnit { - AMPERE("Amp", "I"), - AMP_HOUR("Amp Hour", "Ah"), - VOLTAGE("Volt", "V"), + AMPERE("Amp", "I"), + AMP_HOUR("Amp Hour", "Ah"), + VOLTAGE("Volt", "V"), WATT("Watt", "W"), - WATT_HOUR("Watt Hour", "Wh"), - RESISTANCE("Ohm", "R"), + WATT_HOUR("Watt Hour", "Wh"), + RESISTANCE("Ohm", "R"), CONDUCTANCE("Siemen", "S"), JOULES("Joule", "J"); @@ -34,24 +34,24 @@ public class EnergyDisplay /** Metric system of measurement. */ public static enum MeasurementUnit { - MICRO("Micro", "u", 0.000001D), - MILLI("Milli", "m", 0.001D), + MICRO("Micro", "u", 0.000001D), + MILLI("Milli", "m", 0.001D), BASE("", "", 1), - KILO("Kilo", "k", 1000D), - MEGA("Mega", "M", 1000000D), + KILO("Kilo", "k", 1000D), + MEGA("Mega", "M", 1000000D), GIGA("Giga", "G", 1000000000D), - TERA("Tera", "T", 1000000000000D), + TERA("Tera", "T", 1000000000000D), PETA("Peta", "P", 1000000000000000D), - EXA("Exa", "E", 1000000000000000000D), + EXA("Exa", "E", 1000000000000000000D), ZETTA("Zetta", "Z", 1000000000000000000000D), YOTTA("Yotta", "Y", 1000000000000000000000000D); /** long name for the unit */ public String name; - + /** short unit version of the unit */ public String symbol; - + /** Point by which a number is consider to be of this unit */ public double value; @@ -98,7 +98,7 @@ public class EnergyDisplay { String unitName = unit.name; String prefix = ""; - + if(value < 0) { value = Math.abs(value); @@ -122,19 +122,19 @@ public class EnergyDisplay for(int i = 0; i < MeasurementUnit.values().length; i++) { MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; - + if(lowerMeasure.below(value) && lowerMeasure.ordinal() == 0) { return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName; } - + if(lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length) { return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName; } - + MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; - + if((lowerMeasure.above(value) && upperMeasure.below(value)) || lowerMeasure.value == value) { return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName; @@ -190,7 +190,7 @@ public class EnergyDisplay { return roundDecimals(d, 2); } - + public static enum EnergyType { J, diff --git a/common/mekanism/common/EnergyNetwork.java b/common/mekanism/common/EnergyNetwork.java index a397add5f..921a7a5e8 100644 --- a/common/mekanism/common/EnergyNetwork.java +++ b/common/mekanism/common/EnergyNetwork.java @@ -33,28 +33,28 @@ public class EnergyNetwork extends DynamicNetwork private double lastPowerScale = 0; private double joulesTransmitted = 0; private double jouleBufferLastTick = 0; - + public double clientEnergyScale = 0; - + public double electricityStored; - + public EnergyNetwork(IGridTransmitter... varCables) { transmitters.addAll(Arrays.asList(varCables)); register(); } - + public EnergyNetwork(Collection> collection) { transmitters.addAll(collection); register(); } - + public static double round(double d) { return Math.round(d * 10000)/10000; } - + public EnergyNetwork(Set networks) { for(EnergyNetwork net : networks) @@ -68,84 +68,84 @@ public class EnergyNetwork extends DynamicNetwork joulesTransmitted = net.joulesTransmitted; lastPowerScale = net.lastPowerScale; } - + electricityStored += net.electricityStored; - + addAllTransmitters(net.transmitters); net.deregister(); } } - + refresh(); register(); } - @Override + @Override public double getMeanCapacity() { - //Use the harmonic mean. Because we're mean. - int numCables = transmitters.size(); - double reciprocalSum = 0; - - for(IGridTransmitter cable : transmitters) - { - reciprocalSum += 1.0/(double)cable.getCapacity(); - } - + //Use the harmonic mean. Because we're mean. + int numCables = transmitters.size(); + double reciprocalSum = 0; + + for(IGridTransmitter cable : transmitters) + { + reciprocalSum += 1.0/(double)cable.getCapacity(); + } + return (double)numCables / reciprocalSum; } - - @Override - public void onNetworksCreated(List networks) - { - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - double[] caps = new double[networks.size()]; - double cap = 0; - - for(EnergyNetwork network : networks) - { - caps[networks.indexOf(network)] = network.getCapacity(); - cap += network.getCapacity(); - } - - electricityStored = Math.min(cap, electricityStored); - - double[] percent = ListUtils.percent(caps); - - for(EnergyNetwork network : networks) - { - network.electricityStored = round(percent[networks.indexOf(network)]*electricityStored); - } - } - } - + + @Override + public void onNetworksCreated(List networks) + { + if(FMLCommonHandler.instance().getEffectiveSide().isServer()) + { + double[] caps = new double[networks.size()]; + double cap = 0; + + for(EnergyNetwork network : networks) + { + caps[networks.indexOf(network)] = network.getCapacity(); + cap += network.getCapacity(); + } + + electricityStored = Math.min(cap, electricityStored); + + double[] percent = ListUtils.percent(caps); + + for(EnergyNetwork network : networks) + { + network.electricityStored = round(percent[networks.indexOf(network)]*electricityStored); + } + } + } + public synchronized double getEnergyNeeded() { if(FMLCommonHandler.instance().getEffectiveSide().isClient()) { return 0; } - + return getCapacity()-electricityStored; } - + public synchronized double tickEmit(double energyToSend) { if(FMLCommonHandler.instance().getEffectiveSide().isClient()) { return 0; } - + double sent = 0; boolean tryAgain = false; - + do { tryAgain = false; - + double prev = sent; sent += doEmit(energyToSend-sent); - + if(energyToSend-sent > 0 && sent-prev > 0) { tryAgain = true; @@ -155,21 +155,21 @@ public class EnergyNetwork extends DynamicNetwork joulesTransmitted = sent; return sent; } - + public synchronized double emit(double energyToSend) { double toUse = Math.min(getEnergyNeeded(), energyToSend); electricityStored += toUse; return energyToSend-toUse; } - + /** * @return sent */ public synchronized double doEmit(double energyToSend) - { + { double sent = 0; - + List availableAcceptors = Arrays.asList(getAcceptors().toArray()); Collections.shuffle(availableAcceptors); @@ -187,14 +187,14 @@ public class EnergyNetwork extends DynamicNetwork TileEntity acceptor = (TileEntity)obj; double currentSending = sending+remaining; ForgeDirection side = acceptorDirections.get(acceptor); - + if(side == null) { continue; } - + remaining = 0; - + if(acceptor instanceof IStrictEnergyAcceptor) { sent += ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending); @@ -214,45 +214,45 @@ public class EnergyNetwork extends DynamicNetwork else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) { PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(side.getOpposite()); - + if(receiver != null) { - float toSend = receiver.receiveEnergy(Type.PIPE, (float)(Math.min(receiver.powerRequest(), currentSending*Mekanism.TO_BC)), side.getOpposite()); - sent += toSend*Mekanism.FROM_BC; + float toSend = receiver.receiveEnergy(Type.PIPE, (float)(Math.min(receiver.powerRequest(), currentSending*Mekanism.TO_BC)), side.getOpposite()); + sent += toSend*Mekanism.FROM_BC; } } } } } - + return sent; } - + @Override public synchronized Set getAcceptors(Object... data) { Set toReturn = new HashSet(); - + if(FMLCommonHandler.instance().getEffectiveSide().isClient()) { return toReturn; } - + Set copy = (Set)possibleAcceptors.clone(); - + for(TileEntity acceptor : copy) { ForgeDirection side = acceptorDirections.get(acceptor); - + if(side == null) { continue; } - + if(acceptor instanceof IStrictEnergyAcceptor) { IStrictEnergyAcceptor handler = (IStrictEnergyAcceptor)acceptor; - + if(handler.canReceiveEnergy(side.getOpposite())) { if(handler.getMaxEnergy() - handler.getEnergy() > 0) @@ -264,7 +264,7 @@ public class EnergyNetwork extends DynamicNetwork else if(acceptor instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)acceptor; - + if(handler.canInterface(side.getOpposite())) { if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0 || handler.receiveEnergy(side.getOpposite(), 1, true) > 0) @@ -276,7 +276,7 @@ public class EnergyNetwork extends DynamicNetwork else if(acceptor instanceof IEnergySink) { IEnergySink handler = (IEnergySink)acceptor; - + if(handler.acceptsEnergyFrom(null, side.getOpposite())) { if(Math.min((handler.demandedEnergyUnits()*Mekanism.FROM_IC2), (handler.getMaxSafeInput()*Mekanism.FROM_IC2)) > 0) @@ -288,7 +288,7 @@ public class EnergyNetwork extends DynamicNetwork else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) { IPowerReceptor handler = (IPowerReceptor)acceptor; - + if(handler.getPowerReceiver(side.getOpposite()) != null) { if((handler.getPowerReceiver(side.getOpposite()).powerRequest()*Mekanism.FROM_BC) > 0) @@ -297,13 +297,13 @@ public class EnergyNetwork extends DynamicNetwork { continue; } - + toReturn.add(acceptor); } } } } - + return toReturn; } @@ -312,7 +312,7 @@ public class EnergyNetwork extends DynamicNetwork { Set> iterCables = (Set>)transmitters.clone(); Iterator> it = iterCables.iterator(); - + possibleAcceptors.clear(); acceptorDirections.clear(); @@ -329,15 +329,15 @@ public class EnergyNetwork extends DynamicNetwork conductor.setTransmitterNetwork(this); } } - + for(IGridTransmitter transmitter : iterCables) { TileEntity[] acceptors = CableUtils.getConnectedEnergyAcceptors((TileEntity)transmitter); - + for(TileEntity acceptor : acceptors) { ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor)); - + if(side != null && acceptor != null && !(acceptor instanceof IGridTransmitter) && transmitter.canConnectToAcceptor(side, true)) { possibleAcceptors.add(acceptor); @@ -345,7 +345,7 @@ public class EnergyNetwork extends DynamicNetwork } } } - + needsUpdate = true; } @@ -361,13 +361,13 @@ public class EnergyNetwork extends DynamicNetwork newNetwork.refresh(); } } - + public static class EnergyTransferEvent extends Event { public final EnergyNetwork energyNetwork; - + public final double power; - + public EnergyTransferEvent(EnergyNetwork network, double currentPower) { energyNetwork = network; @@ -383,13 +383,13 @@ public class EnergyNetwork extends DynamicNetwork @Override public void onUpdate() - { + { super.onUpdate(); - + clearJoulesTransmitted(); - + double currentPowerScale = getPowerScale(); - + if(FMLCommonHandler.instance().getEffectiveSide().isServer()) { if(Math.abs(currentPowerScale-lastPowerScale) > 0.01 || (currentPowerScale != lastPowerScale && (currentPowerScale == 0 || currentPowerScale == 1))) @@ -403,32 +403,32 @@ public class EnergyNetwork extends DynamicNetwork lastPowerScale = currentPowerScale; needsUpdate = false; } - + if(electricityStored > 0) { electricityStored -= tickEmit(electricityStored); } } } - + public double getPowerScale() { return Math.max(jouleBufferLastTick == 0 ? 0 : Math.min(Math.ceil(Math.log10(getPower())*2)/10, 1), getCapacity() == 0 ? 0 : electricityStored/getCapacity()); } - + public void clearJoulesTransmitted() { jouleBufferLastTick = electricityStored; joulesTransmitted = 0; } - + public double getPower() { return jouleBufferLastTick * 20; } - + @Override - protected EnergyNetwork create(IGridTransmitter... varTransmitters) + protected EnergyNetwork create(IGridTransmitter... varTransmitters) { EnergyNetwork network = new EnergyNetwork(varTransmitters); network.clientEnergyScale = clientEnergyScale; @@ -440,7 +440,7 @@ public class EnergyNetwork extends DynamicNetwork } @Override - protected EnergyNetwork create(Collection> collection) + protected EnergyNetwork create(Collection> collection) { EnergyNetwork network = new EnergyNetwork(collection); network.clientEnergyScale = clientEnergyScale; @@ -452,17 +452,17 @@ public class EnergyNetwork extends DynamicNetwork } @Override - protected EnergyNetwork create(Set networks) + protected EnergyNetwork create(Set networks) { return new EnergyNetwork(networks); } - + @Override public TransmissionType getTransmissionType() { return TransmissionType.ENERGY; } - + @Override public String getNeeded() { diff --git a/common/mekanism/common/FluidNetwork.java b/common/mekanism/common/FluidNetwork.java index 5db6d1193..2345fbdf4 100644 --- a/common/mekanism/common/FluidNetwork.java +++ b/common/mekanism/common/FluidNetwork.java @@ -26,31 +26,31 @@ import cpw.mods.fml.common.FMLCommonHandler; public class FluidNetwork extends DynamicNetwork { public int transferDelay = 0; - + public boolean didTransfer; public boolean prevTransfer; - + public float fluidScale; - + public Fluid refFluid; - + public FluidStack fluidStored; public int prevStored; public int prevTransferAmount = 0; - + public FluidNetwork(IGridTransmitter... varPipes) { transmitters.addAll(Arrays.asList(varPipes)); register(); } - + public FluidNetwork(Collection> collection) { transmitters.addAll(collection); register(); } - + public FluidNetwork(Set networks) { for(FluidNetwork net : networks) @@ -64,7 +64,7 @@ public class FluidNetwork extends DynamicNetwork refFluid = net.refFluid; fluidScale = net.fluidScale; fluidStored = net.fluidStored; - + net.fluidScale = 0; net.refFluid = null; net.fluidStored = null; @@ -80,113 +80,113 @@ public class FluidNetwork extends DynamicNetwork else { fluidStored.amount += net.fluidStored.amount; } - + net.fluidStored = null; } } - + addAllTransmitters(net.transmitters); net.deregister(); } } - + fluidScale = getScale(); - + refresh(); register(); } - - @Override - public void onNetworksCreated(List networks) - { + + @Override + public void onNetworksCreated(List networks) + { if(fluidStored != null && FMLCommonHandler.instance().getEffectiveSide().isServer()) { - int[] caps = new int[networks.size()]; - int cap = 0; - - for(FluidNetwork network : networks) - { - caps[networks.indexOf(network)] = network.getCapacity(); - cap += network.getCapacity(); - } - - fluidStored.amount = Math.min(cap, fluidStored.amount); - - int[] values = ListUtils.calcPercentInt(ListUtils.percent(caps), fluidStored.amount); - - for(FluidNetwork network : networks) - { - int index = networks.indexOf(network); - - if(values[index] > 0) - { - network.fluidStored = new FluidStack(fluidStored.getFluid(), values[index]); - network.fluidScale = network.getScale(); - network.refFluid = fluidStored.getFluid(); - } - } + int[] caps = new int[networks.size()]; + int cap = 0; + + for(FluidNetwork network : networks) + { + caps[networks.indexOf(network)] = network.getCapacity(); + cap += network.getCapacity(); + } + + fluidStored.amount = Math.min(cap, fluidStored.amount); + + int[] values = ListUtils.calcPercentInt(ListUtils.percent(caps), fluidStored.amount); + + for(FluidNetwork network : networks) + { + int index = networks.indexOf(network); + + if(values[index] > 0) + { + network.fluidStored = new FluidStack(fluidStored.getFluid(), values[index]); + network.fluidScale = network.getScale(); + network.refFluid = fluidStored.getFluid(); + } + } } - - fluidScale = 0; - fluidStored = null; - refFluid = null; - } - + + fluidScale = 0; + fluidStored = null; + refFluid = null; + } + public synchronized int getFluidNeeded() { return getCapacity()-(fluidStored != null ? fluidStored.amount : 0); } - + public synchronized int tickEmit(FluidStack fluidToSend, boolean doTransfer) { List availableAcceptors = Arrays.asList(getAcceptors(fluidToSend).toArray()); - + Collections.shuffle(availableAcceptors); - + int fluidSent = 0; - + if(!availableAcceptors.isEmpty()) { int divider = availableAcceptors.size(); int remaining = fluidToSend.amount % divider; int sending = (fluidToSend.amount-remaining)/divider; - + for(Object obj : availableAcceptors) { if(obj instanceof IFluidHandler) { IFluidHandler acceptor = (IFluidHandler)obj; int currentSending = sending; - + if(remaining > 0) { currentSending++; remaining--; } - + fluidSent += acceptor.fill(acceptorDirections.get(acceptor).getOpposite(), new FluidStack(fluidToSend.fluidID, currentSending), doTransfer); } } } - + if(doTransfer && fluidSent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer()) { didTransfer = true; transferDelay = 2; } - + return fluidSent; } - + public synchronized int emit(FluidStack fluidToSend, boolean doTransfer) { if(fluidToSend == null || (fluidStored != null && fluidStored.getFluid() != fluidToSend.getFluid())) { return 0; } - + int toUse = Math.min(getFluidNeeded(), fluidToSend.amount); - + if(doTransfer) { if(fluidStored == null) @@ -198,15 +198,15 @@ public class FluidNetwork extends DynamicNetwork fluidStored.amount += toUse; } } - + return toUse; } - + @Override public void onUpdate() { super.onUpdate(); - + if(FMLCommonHandler.instance().getEffectiveSide().isServer()) { if(transferDelay == 0) @@ -216,28 +216,28 @@ public class FluidNetwork extends DynamicNetwork else { transferDelay--; } - + int stored = fluidStored != null ? fluidStored.amount : 0; - + if(stored != prevStored) { needsUpdate = true; } - + prevStored = stored; - + if(didTransfer != prevTransfer || needsUpdate) { MinecraftForge.EVENT_BUS.post(new FluidTransferEvent(this, fluidStored, didTransfer)); needsUpdate = false; } - + prevTransfer = didTransfer; - + if(fluidStored != null) { fluidStored.amount -= tickEmit(fluidStored, true); - + if(fluidStored.amount <= 0) { fluidStored = null; @@ -245,14 +245,14 @@ public class FluidNetwork extends DynamicNetwork } } } - + @Override public void clientTick() { super.clientTick(); - + fluidScale = Math.max(fluidScale, getScale()); - + if(didTransfer && fluidScale < 1) { fluidScale = Math.max(getScale(), Math.min(1, fluidScale+0.02F)); @@ -260,42 +260,42 @@ public class FluidNetwork extends DynamicNetwork else if(!didTransfer && fluidScale > 0) { fluidScale = getScale(); - + if(fluidScale == 0) { fluidStored = null; } } } - + @Override public synchronized Set getAcceptors(Object... data) { FluidStack fluidToSend = (FluidStack)data[0]; Set toReturn = new HashSet(); - + for(IFluidHandler acceptor : possibleAcceptors) { if(acceptorDirections.get(acceptor) == null) { continue; } - + if(acceptor.canFill(acceptorDirections.get(acceptor).getOpposite(), fluidToSend.getFluid())) { toReturn.add(acceptor); } } - + return toReturn; } - + @Override public synchronized void refresh() { Set> iterPipes = (Set>)transmitters.clone(); Iterator it = iterPipes.iterator(); - + possibleAcceptors.clear(); acceptorDirections.clear(); @@ -312,15 +312,15 @@ public class FluidNetwork extends DynamicNetwork conductor.setTransmitterNetwork(this); } } - + for(IGridTransmitter transmitter : iterPipes) { IFluidHandler[] acceptors = PipeUtils.getConnectedAcceptors((TileEntity)transmitter); - + for(IFluidHandler acceptor : acceptors) { ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor)); - + if(side != null && acceptor != null && !(acceptor instanceof IGridTransmitter) && transmitter.canConnectToAcceptor(side, true)) { possibleAcceptors.add(acceptor); @@ -342,14 +342,14 @@ public class FluidNetwork extends DynamicNetwork newNetwork.refresh(); } } - + public static class FluidTransferEvent extends Event { public final FluidNetwork fluidNetwork; - + public final FluidStack fluidType; public final boolean didTransfer; - + public FluidTransferEvent(FluidNetwork network, FluidStack type, boolean did) { fluidNetwork = network; @@ -357,24 +357,24 @@ public class FluidNetwork extends DynamicNetwork didTransfer = did; } } - + public float getScale() { return Math.min(1, (fluidStored == null || getCapacity() == 0 ? 0 : (float)fluidStored.amount/getCapacity())); } - + @Override public String toString() { return "[FluidNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors."; } - + @Override - protected FluidNetwork create(IGridTransmitter... varTransmitters) + protected FluidNetwork create(IGridTransmitter... varTransmitters) { FluidNetwork network = new FluidNetwork(varTransmitters); network.refFluid = refFluid; - + if(fluidStored != null) { if(network.fluidStored == null) @@ -385,22 +385,22 @@ public class FluidNetwork extends DynamicNetwork network.fluidStored.amount += fluidStored.amount; } } - + network.fluidScale = network.getScale(); - + fluidScale = 0; refFluid = null; fluidStored = null; - + return network; } @Override - protected FluidNetwork create(Collection> collection) + protected FluidNetwork create(Collection> collection) { FluidNetwork network = new FluidNetwork(collection); network.refFluid = refFluid; - + if(fluidStored != null) { if(network.fluidStored == null) @@ -411,44 +411,44 @@ public class FluidNetwork extends DynamicNetwork network.fluidStored.amount += fluidStored.amount; } } - + network.fluidScale = network.getScale(); - + return network; } - + @Override public boolean canMerge(List> networks) { Fluid found = null; - + for(ITransmitterNetwork network : networks) { if(network instanceof FluidNetwork) { FluidNetwork net = (FluidNetwork)network; - + if(net.fluidStored != null) { if(found != null && found != net.fluidStored.getFluid()) { return false; } - + found = net.fluidStored.getFluid(); } } } - + return true; } @Override - protected FluidNetwork create(Set networks) + protected FluidNetwork create(Set networks) { return new FluidNetwork(networks); } - + @Override public TransmissionType getTransmissionType() { @@ -460,7 +460,7 @@ public class FluidNetwork extends DynamicNetwork { return "Fluid needed: " + (float)getFluidNeeded()/1000F + " buckets"; } - + @Override public String getStored() { diff --git a/common/mekanism/common/FluidSlot.java b/common/mekanism/common/FluidSlot.java index 1863d551c..38ff5b9eb 100644 --- a/common/mekanism/common/FluidSlot.java +++ b/common/mekanism/common/FluidSlot.java @@ -6,17 +6,17 @@ package mekanism.common; * @author AidanBrady * */ -public class FluidSlot +public class FluidSlot { /** The amount of fluid this slot is currently holding. */ public int fluidStored; - + /** The maximum amount of fluid this slot can handle. */ public int MAX_FLUID; - + /** The fluid's ID. */ public int fluidID; - + /** * Creates a FluidSlot with a defined fluid ID and max fluid. The fluid stored starts at 0. * @param max - max fluid @@ -27,7 +27,7 @@ public class FluidSlot MAX_FLUID = max; fluidID = id; } - + /** * Sets the fluid to a new amount. * @param fluid - amount to store diff --git a/common/mekanism/common/HashList.java b/common/mekanism/common/HashList.java index ab6312661..3c100f242 100644 --- a/common/mekanism/common/HashList.java +++ b/common/mekanism/common/HashList.java @@ -6,27 +6,27 @@ import java.util.Iterator; public class HashList implements Iterable { private ArrayList list = new ArrayList(256); - + public boolean contains(T obj) { return list.contains(obj); } - + public void clear() { list.clear(); } - + public T get(int index) { if(index > size()-1) { return null; } - + return list.get(index); } - + public void add(T obj) { if(!list.contains(obj)) @@ -34,7 +34,7 @@ public class HashList implements Iterable list.add(obj); } } - + public void add(int index, T obj) { if(!list.contains(obj)) @@ -46,65 +46,65 @@ public class HashList implements Iterable list.add(i, null); } } - + list.add(index, obj); } } - + public boolean isEmpty() { return list.isEmpty(); } - + public void remove(int index) { if(isEmpty() || index > size()-1) { return; } - + list.remove(index); } - + public void replace(int index, T obj) { if(get(index) != null) { remove(index); } - + add(index, obj); } - + public void remove(T obj) { list.remove(obj); } - + public int indexOf(T obj) { return list.indexOf(obj); } - + public int size() { return list.size(); } - + @Override public int hashCode() { return list.hashCode(); } - + @Override public boolean equals(Object obj) { return list.equals(obj); } - + @Override - public Iterator iterator() + public Iterator iterator() { return list.iterator(); } diff --git a/common/mekanism/common/IActiveState.java b/common/mekanism/common/IActiveState.java index 13c8b0baf..50a1515a2 100644 --- a/common/mekanism/common/IActiveState.java +++ b/common/mekanism/common/IActiveState.java @@ -5,25 +5,25 @@ package mekanism.common; * @author aidancbrady * */ -public interface IActiveState +public interface IActiveState { /** * Gets the active state as a boolean. * @return active state */ public boolean getActive(); - + /** * Sets the active state to a new value. * @param active - new active state */ public void setActive(boolean active); - + /** * Whether or not this block has a visual effect when it is on it's active state. Used for rendering. * @return if the block has a visual effect in it's active state */ public boolean renderUpdate(); - + public boolean lightUpdate(); } diff --git a/common/mekanism/common/IAdvancedBoundingBlock.java b/common/mekanism/common/IAdvancedBoundingBlock.java index c05a9653d..f11ce2635 100644 --- a/common/mekanism/common/IAdvancedBoundingBlock.java +++ b/common/mekanism/common/IAdvancedBoundingBlock.java @@ -14,12 +14,12 @@ import dan200.computer.api.IPeripheral; public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral { public int[] getBoundSlots(Coord4D location, int side); - + public boolean canBoundInsert(Coord4D location, int i, ItemStack itemstack); public boolean canBoundExtract(Coord4D location, int i, ItemStack itemstack, int j); - + public void onPower(); - + public void onNoPower(); } diff --git a/common/mekanism/common/IBoundingBlock.java b/common/mekanism/common/IBoundingBlock.java index 575c01ee7..9dfa02f9b 100644 --- a/common/mekanism/common/IBoundingBlock.java +++ b/common/mekanism/common/IBoundingBlock.java @@ -6,13 +6,13 @@ package mekanism.common; * @author AidanBrady * */ -public interface IBoundingBlock +public interface IBoundingBlock { /** * Called when the main block is placed. */ public void onPlace(); - + /** * Called when any part of the structure is broken. */ diff --git a/common/mekanism/common/IConfigurable.java b/common/mekanism/common/IConfigurable.java index 44b5978a7..64823095e 100644 --- a/common/mekanism/common/IConfigurable.java +++ b/common/mekanism/common/IConfigurable.java @@ -5,6 +5,6 @@ import net.minecraft.entity.player.EntityPlayer; public interface IConfigurable { public boolean onSneakRightClick(EntityPlayer player, int side); - + public boolean onRightClick(EntityPlayer player, int side); } diff --git a/common/mekanism/common/IEjector.java b/common/mekanism/common/IEjector.java index c5f54fd64..6ecfcfe18 100644 --- a/common/mekanism/common/IEjector.java +++ b/common/mekanism/common/IEjector.java @@ -3,23 +3,23 @@ package mekanism.common; import mekanism.api.EnumColor; import net.minecraftforge.common.ForgeDirection; -public interface IEjector +public interface IEjector { public void onOutput(); - + public EnumColor getOutputColor(); - + public void setOutputColor(EnumColor color); - + public EnumColor getInputColor(ForgeDirection side); - + public void setInputColor(ForgeDirection side, EnumColor color); - + public boolean isEjecting(); - + public void setEjecting(boolean eject); - + public boolean hasStrictInput(); - + public void setStrictInput(boolean strict); } diff --git a/common/mekanism/common/IElectricChest.java b/common/mekanism/common/IElectricChest.java index e69551c6c..56599deaa 100644 --- a/common/mekanism/common/IElectricChest.java +++ b/common/mekanism/common/IElectricChest.java @@ -15,77 +15,77 @@ public interface IElectricChest * @param auth - new value */ public void setAuthenticated(ItemStack itemStack, boolean auth); - + /** * Retrieves the 'authenticated' value of this electric chest. * @param itemStack - electric chest ItemStack * @return authenticated value */ public boolean getAuthenticated(ItemStack itemStack); - + /** * Sets the 'password' value of this electric chest to a new value. * @param itemStack - electric chest ItemStack * @param pass - new value */ public void setPassword(ItemStack itemStack, String pass); - + /** * Retrieves the 'password' value of this electric chest. * @param itemStack - electric chest ItemStack * @return authenticated value */ public String getPassword(ItemStack itemStack); - + /** * Sets the 'locked' value of this electric chest to a new value. * @param itemStack - electric chest ItemStack * @param locked - new value */ public void setLocked(ItemStack itemStack, boolean locked); - + /** * Retrieves the 'locked' value of this electric chest. * @param itemStack - electric chest ItemStack * @return authenticated value */ public boolean getLocked(ItemStack itemStack); - + /** * Sets the 'open' value of this electric chest to a new value. * @param itemStack - electric chest ItemStack * @param open - new value */ public void setOpen(ItemStack itemStack, boolean open); - + /** * Retrieves the 'open' value of this electric chest. * @param itemStack - electric chest ItemStack * @return open value */ public boolean getOpen(ItemStack itemStack); - + /** * Sets the 'lidAngle' value of this electric chest to a new value. * @param itemStack - electric chest ItemStack * @param lidAngle - new value */ public void setLidAngle(ItemStack itemStack, float lidAngle); - + /** * Retrieves the 'lidAngle' value of this electric chest. * @param itemStack - electric chest ItemStack * @return lidAngle value */ public float getLidAngle(ItemStack itemStack); - + /** * Sets the 'prevLidAngle' value of this electric chest to a new value. * @param itemStack - electric chest ItemStack * @param prevLidAngle - new value */ public void setPrevLidAngle(ItemStack itemStack, float prevLidAngle); - + /** * Retrieves the 'prevLidAngle' value of this electric chest. * @param itemStack - electric chest ItemStack diff --git a/common/mekanism/common/IElectricMachine.java b/common/mekanism/common/IElectricMachine.java index f34bfdb72..f9119c096 100644 --- a/common/mekanism/common/IElectricMachine.java +++ b/common/mekanism/common/IElectricMachine.java @@ -10,22 +10,22 @@ import java.util.Map; */ public interface IElectricMachine { - /** - * Update call for machines. Use instead of updateEntity() - it's called every tick. - */ + /** + * Update call for machines. Use instead of updateEntity() - it's called every tick. + */ public void onUpdate(); - - /** - * Whether or not this machine can operate. - * @return can operate - */ + + /** + * Whether or not this machine can operate. + * @return can operate + */ public boolean canOperate(); - + /** * Runs this machine's operation -- or smelts the item. */ public void operate(); - + /** * Gets this machine's recipes. */ diff --git a/common/mekanism/common/IEnergyCube.java b/common/mekanism/common/IEnergyCube.java index 75e2b791b..7e2162375 100644 --- a/common/mekanism/common/IEnergyCube.java +++ b/common/mekanism/common/IEnergyCube.java @@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public interface IEnergyCube +public interface IEnergyCube { /** * Gets the tier of this energy cube. @@ -16,7 +16,7 @@ public interface IEnergyCube * @return tier */ public EnergyCubeTier getEnergyCubeTier(ItemStack itemstack); - + /** * Sets the tier of this energy cube * @param itemstack - ItemStack to set diff --git a/common/mekanism/common/IFactory.java b/common/mekanism/common/IFactory.java index 36820b9fb..6f5e431d6 100644 --- a/common/mekanism/common/IFactory.java +++ b/common/mekanism/common/IFactory.java @@ -20,7 +20,7 @@ import net.minecraftforge.common.ForgeDirection; * @author AidanBrady * */ -public interface IFactory +public interface IFactory { /** * Gets the recipe type this Smelting Factory currently has. @@ -28,14 +28,14 @@ public interface IFactory * @return RecipeType ordinal */ public int getRecipeType(ItemStack itemStack); - + /** * Sets the recipe type of this Smelting Factory to a new value. * @param type - RecipeType ordinal * @param itemStack - stack to set */ public void setRecipeType(int type, ItemStack itemStack); - + public static enum RecipeType { SMELTING("smelting", "Smelter.ogg", MachineType.ENERGIZED_SMELTER.getStack(), false, null), @@ -45,38 +45,38 @@ public interface IFactory COMBINING("combining", "Combiner.ogg", MachineType.COMBINER.getStack(), true, Recipe.COMBINER), PURIFYING("purifying", "PurificationChamber.ogg", MachineType.PURIFICATION_CHAMBER.getStack(), true, Recipe.PURIFICATION_CHAMBER), INJECTING("injecting", "ChemicalInjectionChamber.ogg", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, Recipe.CHEMICAL_INJECTION_CHAMBER); - + private String name; private String sound; private ItemStack stack; private boolean usesFuel; private Recipe recipe; private TileEntityAdvancedElectricMachine cacheTile; - + public ItemStack getCopiedOutput(ItemStack input, Gas gas, boolean stackDecrease) { if(input == null) { return null; } - + if(this == SMELTING) { if(FurnaceRecipes.smelting().getSmeltingResult(input) != null) { ItemStack toReturn = FurnaceRecipes.smelting().getSmeltingResult(input).copy(); - + if(stackDecrease) { input.stackSize--; } - + return toReturn; } - + return null; } - + if(usesFuel()) { return RecipeHandler.getOutput(new AdvancedInput(input, gas), stackDecrease, recipe.get()); @@ -85,82 +85,82 @@ public interface IFactory return RecipeHandler.getOutput(input, stackDecrease, recipe.get()); } } - + public GasStack getItemGas(ItemStack itemstack) { if(usesFuel) { return getTile().getItemGas(itemstack); } - + return null; } - + public int getSecondaryEnergyPerTick() { if(usesFuel) { return getTile().SECONDARY_ENERGY_PER_TICK; } - + return 0; } - + public boolean canReceiveGas(ForgeDirection side, Gas type) { if(usesFuel) { return getTile().canReceiveGas(side, type); } - + return false; } - + public boolean canTubeConnect(ForgeDirection side) { if(usesFuel) { return getTile().canTubeConnect(side); } - + return false; } - + public boolean isValidGas(Gas gas) { if(usesFuel) { return getTile().isValidGas(gas); } - + return false; } - - public boolean hasRecipe(ItemStack itemStack) - { - if(itemStack == null) - { - return false; - } - - for(Object obj : recipe.get().entrySet()) - { - if(((Map.Entry)obj).getKey() instanceof AdvancedInput) + + public boolean hasRecipe(ItemStack itemStack) + { + if(itemStack == null) + { + return false; + } + + for(Object obj : recipe.get().entrySet()) + { + if(((Map.Entry)obj).getKey() instanceof AdvancedInput) { - Map.Entry entry = (Map.Entry)obj; - + Map.Entry entry = (Map.Entry)obj; + ItemStack stack = ((AdvancedInput)entry.getKey()).itemStack; - + if(StackUtils.equalsWildcard(stack, itemStack)) { return true; } } - } - - return false; - } - + } + + return false; + } + public TileEntityAdvancedElectricMachine getTile() { if(cacheTile == null) @@ -168,35 +168,35 @@ public interface IFactory MachineType type = MachineType.get(getStack().itemID, getStack().getItemDamage()); cacheTile = (TileEntityAdvancedElectricMachine)type.create(); } - + return cacheTile; } - + public int getMaxSecondaryEnergy() { return 200; } - + public ItemStack getStack() { return stack; } - + public String getName() { return MekanismUtils.localize("gui.factory." + name); } - + public String getSound() { return sound; } - + public boolean usesFuel() { return usesFuel; } - + private RecipeType(String s, String s1, ItemStack is, boolean b, Recipe r) { name = s; diff --git a/common/mekanism/common/IInvConfiguration.java b/common/mekanism/common/IInvConfiguration.java index 26a06c011..17aea937c 100644 --- a/common/mekanism/common/IInvConfiguration.java +++ b/common/mekanism/common/IInvConfiguration.java @@ -7,26 +7,26 @@ import java.util.ArrayList; * @author AidanBrady * */ -public interface IInvConfiguration +public interface IInvConfiguration { /** * Gets an ArrayList of side data this machine contains. * @return */ public ArrayList getSideData(); - + /** * Gets this machine's configuration as a byte[] -- each byte matching with the index of the defined SideData. * @return */ public byte[] getConfiguration(); - + /** * Gets this machine's current orientation. * @return */ public int getOrientation(); - + /** * Gets this machine's ejector. * @return diff --git a/common/mekanism/common/ILogisticalTransporter.java b/common/mekanism/common/ILogisticalTransporter.java index 8d9f0389e..66a1f577f 100644 --- a/common/mekanism/common/ILogisticalTransporter.java +++ b/common/mekanism/common/ILogisticalTransporter.java @@ -12,20 +12,20 @@ import net.minecraftforge.common.ForgeDirection; public interface ILogisticalTransporter extends IBlockableConnection { public ItemStack insert(Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min); - + public ItemStack insertRR(TileEntityLogisticalSorter outputter, ItemStack itemStack, EnumColor color, boolean doEmit, int min); - + public void entityEntering(TransporterStack stack); - + public EnumColor getColor(); - + public void setColor(EnumColor c); - + public TileEntity getTile(); - + public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side); - + public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side); - + public int getCost(); } diff --git a/common/mekanism/common/IModule.java b/common/mekanism/common/IModule.java index 896d4f47f..c97b8a8d4 100644 --- a/common/mekanism/common/IModule.java +++ b/common/mekanism/common/IModule.java @@ -17,20 +17,20 @@ public interface IModule * @return the module's version */ public Version getVersion(); - + /** * Gets the name of the module. Note that this doesn't include "Mekanism" like the actual module's name does, just the * unique name. For example, MekanismGenerators returns "Generators" here. * @return unique name of the module */ public String getName(); - + /** * Writes this module's configuration to a ConfigSync packet. * @param dataStream - the DataOutputStream of the sync packet */ public void writeConfig(DataOutputStream dataStream) throws IOException; - + /** * Reads this module's configuration from the original ConfigSync packet. * @param dataStream - the incoming ByteArrayDataInput of the sync packet diff --git a/common/mekanism/common/IRedstoneControl.java b/common/mekanism/common/IRedstoneControl.java index 4cc8089bc..6519151a8 100644 --- a/common/mekanism/common/IRedstoneControl.java +++ b/common/mekanism/common/IRedstoneControl.java @@ -2,39 +2,39 @@ package mekanism.common; import mekanism.common.util.MekanismUtils; -public interface IRedstoneControl +public interface IRedstoneControl { public static enum RedstoneControl { DISABLED("control.disabled"), HIGH("control.high"), LOW("control.low"); - + private String display; - + public String getDisplay() { return MekanismUtils.localize(display); } - + private RedstoneControl(String s) { display = s; } } - + /** * Gets the RedstoneControl type from this block. * @return this block's RedstoneControl type */ public RedstoneControl getControlType(); - + /** * Sets this block's RedstoneControl type to a new value. * @param type - RedstoneControl type to set */ public void setControlType(RedstoneControl type); - + /** * If the block is getting powered or not by redstone (indirectly). * @return if the block is getting powered indirectly diff --git a/common/mekanism/common/ISpecialBounds.java b/common/mekanism/common/ISpecialBounds.java index 6744078d0..be718b7c3 100644 --- a/common/mekanism/common/ISpecialBounds.java +++ b/common/mekanism/common/ISpecialBounds.java @@ -7,7 +7,7 @@ import net.minecraft.block.Block; * @author aidancbrady * */ -public interface ISpecialBounds +public interface ISpecialBounds { /** * Sets the render bounds for this particular block's subtype. @@ -15,7 +15,7 @@ public interface ISpecialBounds * @param metadata - metadata of the block being rendered */ public void setRenderBounds(Block block, int metadata); - + /** * Whether or not to call the default setBlockBoundsForItemRender() before rendering this block as an item. * @param metadata - metadata of the block being rendered diff --git a/common/mekanism/common/ISustainedInventory.java b/common/mekanism/common/ISustainedInventory.java index fe962ae98..6f7d47536 100644 --- a/common/mekanism/common/ISustainedInventory.java +++ b/common/mekanism/common/ISustainedInventory.java @@ -7,7 +7,7 @@ import net.minecraft.nbt.NBTTagList; * @author AidanBrady * */ -public interface ISustainedInventory +public interface ISustainedInventory { /** * Sets the inventory tag list to a new value. @@ -15,7 +15,7 @@ public interface ISustainedInventory * @param data - ItemStack parameter if using on item */ public void setInventory(NBTTagList nbtTags, Object... data); - + /** * Gets the inventory tag list from an item or block. * @param data - ItemStack parameter if using on item diff --git a/common/mekanism/common/ISustainedTank.java b/common/mekanism/common/ISustainedTank.java index f33907f94..a4c281f16 100644 --- a/common/mekanism/common/ISustainedTank.java +++ b/common/mekanism/common/ISustainedTank.java @@ -7,7 +7,7 @@ import net.minecraftforge.fluids.FluidStack; * @author AidanBrady * */ -public interface ISustainedTank +public interface ISustainedTank { /** * Sets the tank tag list to a new value. @@ -15,14 +15,14 @@ public interface ISustainedTank * @param data - ItemStack parameter if using on item */ public void setFluidStack(FluidStack fluidStack, Object... data); - + /** * Gets the tank tag list from an item or block. * @param data - ItemStack parameter if using on item * @return inventory tag list */ public FluidStack getFluidStack(Object... data); - + /** * Whether or not this block or item has an internal tank. * @param data - ItemStack parameter if using on item diff --git a/common/mekanism/common/ITileComponent.java b/common/mekanism/common/ITileComponent.java index 80ff6e724..b04822d39 100644 --- a/common/mekanism/common/ITileComponent.java +++ b/common/mekanism/common/ITileComponent.java @@ -6,15 +6,15 @@ import com.google.common.io.ByteArrayDataInput; import net.minecraft.nbt.NBTTagCompound; -public interface ITileComponent +public interface ITileComponent { public void tick(); - + public void read(NBTTagCompound nbtTags); - + public void read(ByteArrayDataInput dataStream); - + public void write(NBTTagCompound nbtTags); - + public void write(ArrayList data); } diff --git a/common/mekanism/common/ITileNetwork.java b/common/mekanism/common/ITileNetwork.java index 33888bbf5..09e25d08b 100644 --- a/common/mekanism/common/ITileNetwork.java +++ b/common/mekanism/common/ITileNetwork.java @@ -9,7 +9,7 @@ import com.google.common.io.ByteArrayDataInput; * @author AidanBrady * */ -public interface ITileNetwork +public interface ITileNetwork { /** * Receive and manage a data input. @@ -19,7 +19,7 @@ public interface ITileNetwork * @param dataStream */ public void handlePacketData(ByteArrayDataInput dataStream) throws Exception; - + /** * Gets an ArrayList of data this tile entity keeps synchronized with the client. * @param data - list of data diff --git a/common/mekanism/common/IUpgradeManagement.java b/common/mekanism/common/IUpgradeManagement.java index d0edf2e36..afe50ecd2 100644 --- a/common/mekanism/common/IUpgradeManagement.java +++ b/common/mekanism/common/IUpgradeManagement.java @@ -5,7 +5,7 @@ package mekanism.common; * @author AidanBrady * */ -public interface IUpgradeManagement +public interface IUpgradeManagement { /** * Gets the energy multiplier from an item or block. @@ -13,28 +13,28 @@ public interface IUpgradeManagement * @return energy multiplier */ public int getEnergyMultiplier(Object... data); - + /** * Sets the energy multiplier of an item or block. * @param multiplier - new multiplier * @param data - ItemStack parameter if getting from an item */ public void setEnergyMultiplier(int multiplier, Object... data); - + /** * Gets the speed multiplier from an item or block. * @param data - ItemStack parameter if getting from an item * @return speed multiplier */ public int getSpeedMultiplier(Object... data); - + /** * Sets the speed multiplier of an item or block. * @param multiplier - new multiplier * @param data - ItemStack parameter if getting from an item */ public void setSpeedMultiplier(int multiplier, Object... data); - + /** * Whether or not this item or block supports upgrades. * @param data - ItemStack parameter if getting from an item diff --git a/common/mekanism/common/ItemAttacher.java b/common/mekanism/common/ItemAttacher.java index 1cd9a8c93..5cc346702 100644 --- a/common/mekanism/common/ItemAttacher.java +++ b/common/mekanism/common/ItemAttacher.java @@ -7,29 +7,29 @@ import mekanism.common.multipart.TransmitterType; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -public final class ItemAttacher +public final class ItemAttacher { private static final List attachable = new ArrayList(); - - static + + static { attachable.add(new ItemStack(Block.lever)); attachable.add(new ItemStack(Block.torchRedstoneIdle)); attachable.add(new ItemStack(Block.torchWood)); - + for(TransmitterType type : TransmitterType.values()) { attachable.add(new ItemStack(Mekanism.PartTransmitter, 1, type.ordinal())); } } - + public static boolean canAttach(ItemStack itemStack) { if(itemStack == null) { return false; } - + for(ItemStack stack : attachable) { if(stack.isItemEqual(itemStack)) @@ -37,7 +37,7 @@ public final class ItemAttacher return true; } } - + return false; } } diff --git a/common/mekanism/common/KeySync.java b/common/mekanism/common/KeySync.java index 80a3c374e..9d9a39ad0 100644 --- a/common/mekanism/common/KeySync.java +++ b/common/mekanism/common/KeySync.java @@ -11,24 +11,24 @@ public class KeySync { public static int ASCEND = 0; public static int DESCEND = 1; - + public Map keys = new HashMap(); - + public static class KeySet { public Set keysActive = new HashSet(); - + public KeySet(int key) { keysActive.add(key); } } - + public KeySet getPlayerKeys(EntityPlayer player) { return keys.get(player); } - + public void add(EntityPlayer player, int key) { if(!keys.containsKey(player)) @@ -36,30 +36,30 @@ public class KeySync keys.put(player, new KeySet(key)); return; } - + keys.get(player).keysActive.add(key); } - + public void remove(EntityPlayer player, int key) { if(!keys.containsKey(player)) { return; } - + keys.get(player).keysActive.remove(key); } - + public boolean has(EntityPlayer player, int key) { if(!keys.containsKey(player)) { return false; } - + return keys.get(player).keysActive.contains(key); } - + public void update(EntityPlayer player, int key, boolean add) { if(add) diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 73c6aefc0..0f5393679 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -165,70 +165,70 @@ public class Mekanism { /** Mekanism logger instance */ public static Logger logger = Logger.getLogger("Minecraft"); - + /** Mekanism proxy instance */ @SidedProxy(clientSide = "mekanism.client.ClientProxy", serverSide = "mekanism.common.CommonProxy") public static CommonProxy proxy; - + /** Mekanism debug mode */ public static boolean debug = false; - - /** Mekanism mod instance */ + + /** Mekanism mod instance */ @Instance("Mekanism") - public static Mekanism instance; - - /** Mekanism hooks instance */ - public static MekanismHooks hooks = new MekanismHooks(); - - /** Mekanism configuration instance */ - public static Configuration configuration; - + public static Mekanism instance; + + /** Mekanism hooks instance */ + public static MekanismHooks hooks = new MekanismHooks(); + + /** Mekanism configuration instance */ + public static Configuration configuration; + /** Mekanism version number */ public static Version versionNumber = new Version(6, 0, 3); - + /** Map of Teleporters */ public static Map> teleporters = new HashMap>(); - + /** A map containing references to all dynamic tank inventory caches. */ public static Map dynamicInventories = new HashMap(); - + /** Mekanism creative tab */ public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism(); - + /** List of Mekanism modules loaded */ public static List modulesLoaded = new ArrayList(); - + /** The latest version number which is received from the Mekanism server */ public static String latestVersionNumber; - + /** The recent news which is received from the Mekanism server */ public static String recentNews; - + /** The VoiceServer manager for walkie talkies */ public static VoiceServerManager voiceManager; - + /** A list of the usernames of players who have donated to Mekanism. */ public static List donators = new ArrayList(); - + public static KeySync keyMap = new KeySync(); - + public static Set jetpackOn = new HashSet(); public static Set gasmaskOn = new HashSet(); - + public static Set ic2Registered = new HashSet(); - + //Block IDs - public static int basicBlockID; - public static int basicBlock2ID; - public static int machineBlockID; - public static int machineBlock2ID; - public static int oreBlockID; + public static int basicBlockID; + public static int basicBlock2ID; + public static int machineBlockID; + public static int machineBlock2ID; + public static int oreBlockID; public static int obsidianTNTID; public static int energyCubeID; public static int boundingBlockID; public static int gasTankID; public static int cardboardBoxID; - + //Items public static ItemElectricBow ElectricBow; public static Item EnrichedAlloy; @@ -280,7 +280,7 @@ public class Mekanism public static Item DirtyDust; public static Item Shard; public static Item Crystal; - + public static int ITEM_ID = 11200; public static int BLOCK_ID = 3000; @@ -354,7 +354,7 @@ public class Mekanism "***", "***", "***", Character.valueOf('*'), "ingotRefinedObsidian" })); CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Ingot, 9, 0), new Object[] { - "*", Character.valueOf('*'), new ItemStack(BasicBlock, 1, 2) + "*", Character.valueOf('*'), new ItemStack(BasicBlock, 1, 2) })); CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(BasicBlock, 1, 4), new Object[] { "***", "***", "***", Character.valueOf('*'), "ingotRefinedGlowstone" @@ -392,7 +392,7 @@ public class Mekanism CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Ingot, 9, 6), new Object[] { "*", Character.valueOf('*'), new ItemStack(BasicBlock, 1, 13) })); - + //Base Recipes CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(ObsidianTNT, 1), new Object[] { "***", "XXX", "***", Character.valueOf('*'), Block.obsidian, Character.valueOf('X'), Block.tnt @@ -510,7 +510,7 @@ public class Mekanism Character.valueOf('I'), new ItemStack(BasicBlock, 1, 8), Character.valueOf('T'), TeleportationCore })); CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MachineBlock2, 1, 0), new Object[] { - "GCG", "tET", "GIG", Character.valueOf('G'), Block.glass, Character.valueOf('C'), "circuitBasic", Character.valueOf('t'), MekanismUtils.getEmptyGasTank(), Character.valueOf('E'), EnergyTablet.getUnchargedItem(), + "GCG", "tET", "GIG", Character.valueOf('G'), Block.glass, Character.valueOf('C'), "circuitBasic", Character.valueOf('t'), MekanismUtils.getEmptyGasTank(), Character.valueOf('E'), EnergyTablet.getUnchargedItem(), Character.valueOf('T'), new ItemStack(BasicBlock, 1, 9), Character.valueOf('I'), new ItemStack(BasicBlock, 1, 8) })); CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(Jetpack.getEmptyItem(), new Object[] { @@ -586,28 +586,28 @@ public class Mekanism "CAC", "cOc", "CAC", Character.valueOf('C'), "circuitBasic", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('c'), AtomicCore, Character.valueOf('O'), MekanismUtils.getFactory(FactoryTier.ADVANCED, type) })); } - + CraftingManager.getInstance().getRecipeList().add(new BinRecipe()); - - //Transmitters - CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 0), new Object[] { - "SRS", Character.valueOf('S'), "ingotSteel", Character.valueOf('R'), Item.redstone - })); - CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 1), new Object[] { - "ETE", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 0) - })); - CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 2), new Object[] { - "CTC", Character.valueOf('C'), "circuitBasic", Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 0) - })); - CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 3), new Object[] { - "CTC", Character.valueOf('C'), AtomicCore, Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 0) - })); - CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 4), new Object[] { - "SBS", Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Item.bucketEmpty - })); - CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 5), new Object[] { - "SGS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), Block.glass - })); + + //Transmitters + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 0), new Object[] { + "SRS", Character.valueOf('S'), "ingotSteel", Character.valueOf('R'), Item.redstone + })); + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 1), new Object[] { + "ETE", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 0) + })); + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 2), new Object[] { + "CTC", Character.valueOf('C'), "circuitBasic", Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 0) + })); + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 1, 3), new Object[] { + "CTC", Character.valueOf('C'), AtomicCore, Character.valueOf('T'), new ItemStack(PartTransmitter, 1, 0) + })); + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 4), new Object[] { + "SBS", Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Item.bucketEmpty + })); + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 5), new Object[] { + "SGS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), Block.glass + })); CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 8, 6), new Object[] { "SCS", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "circuitBasic" })); @@ -617,31 +617,31 @@ public class Mekanism CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(PartTransmitter, 2, 8), new Object[] { "RRR", "SBS", "RRR", Character.valueOf('R'), Item.redstone, Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Block.fenceIron })); - - for(int i = 0; i < EnumColor.DYES.length; i++) - { - EnumColor color = EnumColor.DYES[i]; - - if(color != null) - { - CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(Balloon, 2, i), new Object[] { - Item.leather, Item.silk, new ItemStack(Item.dyePowder, 1, i) - })); - - for(int j = 0; j < EnumColor.DYES.length; j++) - { - EnumColor color1 = EnumColor.DYES[j]; - - if(color1 != null) - { - CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(Balloon, 1, i), new Object[] { - new ItemStack(Balloon, 1, j), new ItemStack(Item.dyePowder, 1, i) - })); - } - } - } - } - + + for(int i = 0; i < EnumColor.DYES.length; i++) + { + EnumColor color = EnumColor.DYES[i]; + + if(color != null) + { + CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(Balloon, 2, i), new Object[] { + Item.leather, Item.silk, new ItemStack(Item.dyePowder, 1, i) + })); + + for(int j = 0; j < EnumColor.DYES.length; j++) + { + EnumColor color1 = EnumColor.DYES[j]; + + if(color1 != null) + { + CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(new ItemStack(Balloon, 1, i), new Object[] { + new ItemStack(Balloon, 1, j), new ItemStack(Item.dyePowder, 1, i) + })); + } + } + } + } + //Furnace Recipes FurnaceRecipes.smelting().addSmelting(oreBlockID, 0, new ItemStack(Ingot, 1, 1), 1.0F); FurnaceRecipes.smelting().addSmelting(oreBlockID, 1, new ItemStack(Ingot, 1, 5), 1.0F); @@ -652,10 +652,10 @@ public class Mekanism FurnaceRecipes.smelting().addSmelting(Dust.itemID, 5, new ItemStack(Ingot, 1, 4), 0.0F); FurnaceRecipes.smelting().addSmelting(Dust.itemID, 6, new ItemStack(Ingot, 1, 5), 0.0F); FurnaceRecipes.smelting().addSmelting(Dust.itemID, 7, new ItemStack(Ingot, 1, 6), 0.0F); - + //Enrichment Chamber Recipes RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreRedstone), new ItemStack(Item.redstone, 12)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.obsidian), new ItemStack(DirtyDust, 2, 6)); + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.obsidian), new ItemStack(DirtyDust, 2, 6)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Item.coal, 1, 0), new ItemStack(CompressedCarbon)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Item.coal, 1, 1), new ItemStack(CompressedCarbon)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Item.redstone), new ItemStack(CompressedRedstone)); @@ -670,37 +670,37 @@ public class Mekanism RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.stoneBrick, 1, 2), new ItemStack(Block.stoneBrick, 1, 0)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(Block.stoneBrick, 1, 3)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.stoneBrick, 1, 1), new ItemStack(Block.stoneBrick, 1, 0)); - + //Combiner recipes RecipeHandler.addCombinerRecipe(new ItemStack(Item.redstone, 16), new ItemStack(Block.oreRedstone)); RecipeHandler.addCombinerRecipe(new ItemStack(Item.dyePowder, 16, 4), new ItemStack(Block.oreLapis)); RecipeHandler.addCombinerRecipe(new ItemStack(Item.flint), new ItemStack(Block.gravel)); - + //Osmium Compressor Recipes RecipeHandler.addOsmiumCompressorRecipe(new ItemStack(Item.glowstone), new ItemStack(Ingot, 1, 3)); - + //Crusher Recipes RecipeHandler.addCrusherRecipe(new ItemStack(Item.diamond), new ItemStack(Dust, 1, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.ingotIron), new ItemStack(Dust, 1, 0)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.ingotGold), new ItemStack(Dust, 1, 1)); - RecipeHandler.addCrusherRecipe(new ItemStack(Block.gravel), new ItemStack(Block.sand)); - RecipeHandler.addCrusherRecipe(new ItemStack(Block.stone), new ItemStack(Block.cobblestone)); - RecipeHandler.addCrusherRecipe(new ItemStack(Block.cobblestone), new ItemStack(Block.gravel)); - RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 2), new ItemStack(Block.stone)); - RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(Block.stoneBrick, 1, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 3), new ItemStack(Block.stoneBrick, 1, 0)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.flint, 4), new ItemStack(Item.gunpowder)); - RecipeHandler.addCrusherRecipe(new ItemStack(Block.sandStone), new ItemStack(Block.sand, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.ingotIron), new ItemStack(Dust, 1, 0)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.ingotGold), new ItemStack(Dust, 1, 1)); + RecipeHandler.addCrusherRecipe(new ItemStack(Block.gravel), new ItemStack(Block.sand)); + RecipeHandler.addCrusherRecipe(new ItemStack(Block.stone), new ItemStack(Block.cobblestone)); + RecipeHandler.addCrusherRecipe(new ItemStack(Block.cobblestone), new ItemStack(Block.gravel)); + RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 2), new ItemStack(Block.stone)); + RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(Block.stoneBrick, 1, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 3), new ItemStack(Block.stoneBrick, 1, 0)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.flint, 4), new ItemStack(Item.gunpowder)); + RecipeHandler.addCrusherRecipe(new ItemStack(Block.sandStone), new ItemStack(Block.sand, 2)); + + //Purification Chamber Recipes + RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.obsidian), new ItemStack(Clump, 3, 6)); + RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.gravel), new ItemStack(Item.flint)); + + //Chemical Injection Chamber Recipes + RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Block.obsidian), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Shard, 4, 6)); + RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Block.dirt), GasRegistry.getGas("water")), new ItemStack(Block.blockClay)); + RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Item.gunpowder), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Dust, 1, 10)); - //Purification Chamber Recipes - RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.obsidian), new ItemStack(Clump, 3, 6)); - RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.gravel), new ItemStack(Item.flint)); - - //Chemical Injection Chamber Recipes - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Block.obsidian), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Shard, 4, 6)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Block.dirt), GasRegistry.getGas("water")), new ItemStack(Block.blockClay)); - RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(new ItemStack(Item.gunpowder), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Dust, 1, 10)); - //Precision Sawmill Recipes RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.ladder, 3), new ChanceOutput(new ItemStack(Item.stick, 7))); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.chest), new ChanceOutput(new ItemStack(Block.planks, 8))); @@ -715,52 +715,52 @@ public class Mekanism RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.music), new ChanceOutput(new ItemStack(Block.planks, 8), new ItemStack(Item.redstone, 1), 1)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.torchRedstoneIdle), new ChanceOutput(new ItemStack(Item.stick, 1), new ItemStack(Item.redstone), 1)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.workbench), new ChanceOutput(new ItemStack(Block.planks, 4))); - - //Metallurgic Infuser Recipes - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(Item.ingotIron)), new ItemStack(EnrichedIron)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(EnrichedIron)), new ItemStack(Dust, 1, 5)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("REDSTONE"), 10, new ItemStack(Item.ingotIron)), new ItemStack(EnrichedAlloy)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Block.dirt)), new ItemStack(Block.mycelium)); - - if(InfuseRegistry.contains("BIO")) - { - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("BIO"), 10, new ItemStack(Block.cobblestone)), new ItemStack(Block.cobblestoneMossy)); - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("BIO"), 10, new ItemStack(Block.stoneBrick, 1, 0)), new ItemStack(Block.stoneBrick, 1, 1)); - } - - //Chemical Infuser Recipes - RecipeHandler.addChemicalInfuserRecipe(new ChemicalPair(new GasStack(GasRegistry.getGas("oxygen"), 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 2)), new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 2)); + + //Metallurgic Infuser Recipes + RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(Item.ingotIron)), new ItemStack(EnrichedIron)); + RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(EnrichedIron)), new ItemStack(Dust, 1, 5)); + RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("REDSTONE"), 10, new ItemStack(Item.ingotIron)), new ItemStack(EnrichedAlloy)); + RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Block.dirt)), new ItemStack(Block.mycelium)); + + if(InfuseRegistry.contains("BIO")) + { + RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("BIO"), 10, new ItemStack(Block.cobblestone)), new ItemStack(Block.cobblestoneMossy)); + RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("BIO"), 10, new ItemStack(Block.stoneBrick, 1, 0)), new ItemStack(Block.stoneBrick, 1, 1)); + } + + //Chemical Infuser Recipes + RecipeHandler.addChemicalInfuserRecipe(new ChemicalPair(new GasStack(GasRegistry.getGas("oxygen"), 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 2)), new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 2)); RecipeHandler.addChemicalInfuserRecipe(new ChemicalPair(new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 1), new GasStack(GasRegistry.getGas("water"), 1)), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1)); RecipeHandler.addChemicalInfuserRecipe(new ChemicalPair(new GasStack(GasRegistry.getGas("hydrogen"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1)), new GasStack(GasRegistry.getGas("hydrogenChloride"), 1)); //Electrolytic Separator Recipes RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("water", 2), new ChemicalPair(new GasStack(GasRegistry.getGas("hydrogen"), 2), new GasStack(GasRegistry.getGas("oxygen"), 1))); RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("brine", 10), new ChemicalPair(new GasStack(GasRegistry.getGas("hydrogen"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1))); - + //Chemical Washer Recipes for(Gas gas : GasRegistry.getRegisteredGasses()) { if(gas instanceof OreGas && !((OreGas)gas).isClean()) { OreGas oreGas = (OreGas)gas; - + RecipeHandler.addChemicalWasherRecipe(new GasStack(oreGas, 1), new GasStack(oreGas.getCleanGas(), 1)); RecipeHandler.addChemicalCrystalizerRecipe(new GasStack(oreGas.getCleanGas(), 200), new ItemStack(Crystal, 1, Resource.getFromName(oreGas.getName()).ordinal())); } } - //Infuse objects - InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 1), new InfuseObject(InfuseRegistry.get("CARBON"), 20)); - InfuseRegistry.registerInfuseObject(new ItemStack(CompressedCarbon), new InfuseObject(InfuseRegistry.get("CARBON"), 100)); - InfuseRegistry.registerInfuseObject(new ItemStack(Item.redstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Block.blockRedstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 90)); - InfuseRegistry.registerInfuseObject(new ItemStack(CompressedRedstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 100)); - InfuseRegistry.registerInfuseObject(new ItemStack(Block.mushroomRed), new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Block.mushroomBrown), new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); - - //Fuels - GameRegistry.registerFuelHandler(new IFuelHandler() { + //Infuse objects + InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10)); + InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 1), new InfuseObject(InfuseRegistry.get("CARBON"), 20)); + InfuseRegistry.registerInfuseObject(new ItemStack(CompressedCarbon), new InfuseObject(InfuseRegistry.get("CARBON"), 100)); + InfuseRegistry.registerInfuseObject(new ItemStack(Item.redstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 10)); + InfuseRegistry.registerInfuseObject(new ItemStack(Block.blockRedstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 90)); + InfuseRegistry.registerInfuseObject(new ItemStack(CompressedRedstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 100)); + InfuseRegistry.registerInfuseObject(new ItemStack(Block.mushroomRed), new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); + InfuseRegistry.registerInfuseObject(new ItemStack(Block.mushroomBrown), new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); + + //Fuels + GameRegistry.registerFuelHandler(new IFuelHandler() { @Override public int getBurnTime(ItemStack fuel) { @@ -768,17 +768,17 @@ public class Mekanism { return 200 * 8 * 9; // 1 item (200) * 8 items (1 charcoal) * 9 (9 in a block) } - + return 0; } - }); + }); } - + /** * Adds and registers all items. */ public void addItems() - { + { //Declarations configuration.load(); PartTransmitter = new ItemPartTransmitter(configuration.getItem("MultipartTransmitter", ITEM_ID++).getInt()).setUnlocalizedName("MultipartTransmitter"); @@ -819,10 +819,10 @@ public class Mekanism ItemProxy = new ItemProxy(configuration.getItem("ItemProxy", ITEM_ID++).getInt()).setUnlocalizedName("ItemProxy"); configuration.save(); - + //Fluid Container stuff FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid("brine"), new ItemStack(BrineBucket), FluidContainerRegistry.EMPTY_BUCKET); - + //Registrations GameRegistry.registerItem(ElectricBow, "ElectricBow"); GameRegistry.registerItem(Dust, "Dust"); @@ -860,7 +860,7 @@ public class Mekanism GameRegistry.registerItem(FreeRunners, "FrictionBoots"); GameRegistry.registerItem(ArmoredJetpack, "ArmoredJetpack"); } - + /** * Adds and registers all blocks. */ @@ -877,7 +877,7 @@ public class Mekanism BoundingBlock = (BlockBounding) new BlockBounding(boundingBlockID).setUnlocalizedName("BoundingBlock"); GasTank = new BlockGasTank(gasTankID).setUnlocalizedName("GasTank"); CardboardBox = new BlockCardboardBox(cardboardBoxID).setUnlocalizedName("CardboardBox"); - + //Registrations GameRegistry.registerBlock(BasicBlock, ItemBlockBasic.class, "BasicBlock"); GameRegistry.registerBlock(BasicBlock2, ItemBlockBasic.class, "BasicBlock2"); @@ -890,7 +890,7 @@ public class Mekanism GameRegistry.registerBlock(GasTank, ItemBlockGasTank.class, "GasTank"); GameRegistry.registerBlock(CardboardBox, ItemBlockCardboardBox.class, "CardboardBox"); } - + /** * Registers specified items with the Ore Dictionary. */ @@ -900,14 +900,14 @@ public class Mekanism OreDictionary.registerOre("universalCable", new ItemStack(PartTransmitter, 8, 0)); OreDictionary.registerOre("battery", EnergyTablet.getUnchargedItem()); OreDictionary.registerOre("pulpWood", Sawdust); - + //for RailCraft/IC2. OreDictionary.registerOre("dustObsidian", new ItemStack(DirtyDust, 1, 6)); - + //GregoriousT? OreDictionary.registerOre("itemSalt", Salt); OreDictionary.registerOre("dustSalt", Salt); - + OreDictionary.registerOre("dustIron", new ItemStack(Dust, 1, 0)); OreDictionary.registerOre("dustGold", new ItemStack(Dust, 1, 1)); OreDictionary.registerOre("dustOsmium", new ItemStack(Dust, 1, 2)); @@ -919,7 +919,7 @@ public class Mekanism OreDictionary.registerOre("dustSilver", new ItemStack(Dust, 1, 8)); OreDictionary.registerOre("dustLead", new ItemStack(Dust, 1, 9)); OreDictionary.registerOre("dustSulfur", new ItemStack(Dust, 1, 10)); - + OreDictionary.registerOre("ingotRefinedObsidian", new ItemStack(Ingot, 1, 0)); OreDictionary.registerOre("ingotOsmium", new ItemStack(Ingot, 1, 1)); OreDictionary.registerOre("ingotBronze", new ItemStack(Ingot, 1, 2)); @@ -927,7 +927,7 @@ public class Mekanism OreDictionary.registerOre("ingotSteel", new ItemStack(Ingot, 1, 4)); OreDictionary.registerOre("ingotCopper", new ItemStack(Ingot, 1, 5)); OreDictionary.registerOre("ingotTin", new ItemStack(Ingot, 1, 6)); - + OreDictionary.registerOre("blockOsmium", new ItemStack(BasicBlock, 1, 0)); OreDictionary.registerOre("blockBronze", new ItemStack(BasicBlock, 1, 1)); OreDictionary.registerOre("blockRefinedObsidian", new ItemStack(BasicBlock, 1, 2)); @@ -936,7 +936,7 @@ public class Mekanism OreDictionary.registerOre("blockSteel", new ItemStack(BasicBlock, 1, 5)); OreDictionary.registerOre("blockCopper", new ItemStack(BasicBlock, 1, 12)); OreDictionary.registerOre("blockTin", new ItemStack(BasicBlock, 1, 13)); - + for(Resource resource : Resource.values()) { OreDictionary.registerOre("dustDirty" + resource.getName(), new ItemStack(DirtyDust, 1, resource.ordinal())); @@ -944,82 +944,82 @@ public class Mekanism OreDictionary.registerOre("shard" + resource.getName(), new ItemStack(Shard, 1, resource.ordinal())); OreDictionary.registerOre("crystal" + resource.getName(), new ItemStack(Crystal, 1, resource.ordinal())); } - + OreDictionary.registerOre("oreOsmium", new ItemStack(OreBlock, 1, 0)); OreDictionary.registerOre("oreCopper", new ItemStack(OreBlock, 1, 1)); OreDictionary.registerOre("oreTin", new ItemStack(OreBlock, 1, 2)); - + //MC stuff OreDictionary.registerOre("oreCoal", new ItemStack(Block.oreCoal)); OreDictionary.registerOre("ingotIron", new ItemStack(Item.ingotIron)); OreDictionary.registerOre("ingotGold", new ItemStack(Item.ingotGold)); OreDictionary.registerOre("oreRedstone", new ItemStack(Block.oreRedstone)); OreDictionary.registerOre("oreRedstone", new ItemStack(Block.oreRedstoneGlowing)); - + if(controlCircuitOreDict || !hooks.BasicComponentsLoaded) { OreDictionary.registerOre("circuitBasic", new ItemStack(ControlCircuit)); } - + OreDictionary.registerOre("itemCompressedCarbon", new ItemStack(CompressedCarbon)); OreDictionary.registerOre("itemEnrichedAlloy", new ItemStack(EnrichedAlloy)); } - + /** * Integrates the mod with other mods -- registering items and blocks with the Forge Ore Dictionary * and adding machine recipes with other items' corresponding resources. */ public void addIntegratedItems() - { + { if(hooks.MetallurgyCoreLoaded) { try { String[] setNames = {"base", "precious", "nether", "fantasy", "ender", "utility"}; - + for(String setName : setNames ) { for(IOreInfo oreInfo : MetallurgyAPI.getMetalSet(setName).getOreList().values()) { - switch(oreInfo.getType()) + switch(oreInfo.getType()) { - case ALLOY: + case ALLOY: { if(oreInfo.getIngot() != null && oreInfo.getDust() != null) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(oreInfo.getIngot(), 1), MekanismUtils.size(oreInfo.getDust(), 1)); } - + break; } - case DROP: + case DROP: { ItemStack ore = oreInfo.getOre(); ItemStack drop = oreInfo.getDrop(); - + if(drop != null && ore != null) - { + { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), MekanismUtils.size(drop, 12)); } - + break; } - default: + default: { ItemStack ore = oreInfo.getOre(); ItemStack dust = oreInfo.getDust(); ItemStack ingot = oreInfo.getIngot(); - + if(ore != null && dust != null) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), MekanismUtils.size(dust, 2)); RecipeHandler.addCombinerRecipe(MekanismUtils.size(dust, 8), MekanismUtils.size(ore, 1)); } - + if(ingot != null && dust != null) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ingot, 1), MekanismUtils.size(dust, 1)); } - + break; } } @@ -1028,7 +1028,7 @@ public class Mekanism } catch(Exception e) {} } } - + /** * Adds and registers all entities and tile entities. */ @@ -1038,21 +1038,21 @@ public class Mekanism EntityRegistry.registerGlobalEntityID(EntityObsidianTNT.class, "ObsidianTNT", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityRobit.class, "Robit", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityBalloon.class, "Balloon", EntityRegistry.findGlobalUniqueEntityId()); - + //Registrations EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 0, this, 40, 5, true); EntityRegistry.registerModEntity(EntityRobit.class, "Robit", 1, this, 40, 2, true); EntityRegistry.registerModEntity(EntityBalloon.class, "Balloon", 2, this, 40, 1, true); - + //Tile entities GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock"); GameRegistry.registerTileEntity(TileEntityAdvancedBoundingBlock.class, "AdvancedBoundingBlock"); GameRegistry.registerTileEntity(TileEntityCardboardBox.class, "CardboardBox"); - + //Load tile entities that have special renderers. proxy.registerSpecialTileEntities(); } - + @EventHandler public void serverStarting(FMLServerStartingEvent event) { @@ -1060,24 +1060,24 @@ public class Mekanism { voiceManager.start(); } - + //Load cached furnace recipes TileEntityEnergizedSmelter.furnaceRecipes.clear(); - + for(Map.Entry, ItemStack> entry : FurnaceRecipes.smelting().getMetaSmeltingList().entrySet()) { TileEntityEnergizedSmelter.furnaceRecipes.put(new ItemStack(entry.getKey().get(0), 1, entry.getKey().get(1)), entry.getValue()); } - + for(Object obj : FurnaceRecipes.smelting().getSmeltingList().entrySet()) { Map.Entry entry = (Map.Entry)obj; TileEntityEnergizedSmelter.furnaceRecipes.put(new ItemStack(entry.getKey(), 1, OreDictionary.WILDCARD_VALUE), entry.getValue()); } - + event.registerServerCommand(new CommandMekanism()); } - + @EventHandler public void serverStopping(FMLServerStoppingEvent event) { @@ -1085,26 +1085,26 @@ public class Mekanism { voiceManager.stop(); } - + //Clear all cache data teleporters.clear(); dynamicInventories.clear(); ic2Registered.clear(); jetpackOn.clear(); gasmaskOn.clear(); - + TransporterManager.flowingStacks.clear(); } - + @EventHandler public void preInit(FMLPreInitializationEvent event) { logger.setParent(FMLLog.getLogger()); File config = event.getSuggestedConfigurationFile(); - + //Set the mod's configuration configuration = new Configuration(config); - + if(config.getAbsolutePath().contains("voltz")) { System.out.println("[Mekanism] Detected Voltz in root directory - hello, fellow user!"); @@ -1113,7 +1113,7 @@ public class Mekanism { System.out.println("[Mekanism] Detected Tekkit in root directory - hello, fellow user!"); } - + GasRegistry.register(new Gas("hydrogen")).registerFluid(); GasRegistry.register(new Gas("oxygen")).registerFluid(); GasRegistry.register(new Gas("water")).registerFluid(); @@ -1124,45 +1124,45 @@ public class Mekanism GasRegistry.register(new Gas("hydrogenChloride")).registerFluid(); GasRegistry.register(new Gas("liquidOsmium").setVisible(false)); GasRegistry.register(new Gas("liquidStone").setVisible(false)); - + for(Resource resource : Resource.values()) { String name = resource.getName(); - + OreGas clean = (OreGas)GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false)); GasRegistry.register(new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()).setCleanGas(clean).setVisible(false)); } FluidRegistry.registerFluid(new Fluid("brine")); - + Mekanism.proxy.preInit(); - + //Register infuses - InfuseRegistry.registerInfuseType(new InfuseType("CARBON", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 0, 0).setUnlocalizedName("infuse.carbon")); - InfuseRegistry.registerInfuseType(new InfuseType("TIN", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 4, 0).setUnlocalizedName("infuse.tin")); - InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 8, 0).setUnlocalizedName("infuse.diamond")); - InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 16, 0).setUnlocalizedName("infuse.redstone")); - InfuseRegistry.registerInfuseType(new InfuseType("FUNGI", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 20, 0).setUnlocalizedName("infuse.fungi")); + InfuseRegistry.registerInfuseType(new InfuseType("CARBON", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 0, 0).setUnlocalizedName("infuse.carbon")); + InfuseRegistry.registerInfuseType(new InfuseType("TIN", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 4, 0).setUnlocalizedName("infuse.tin")); + InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 8, 0).setUnlocalizedName("infuse.diamond")); + InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 16, 0).setUnlocalizedName("infuse.redstone")); + InfuseRegistry.registerInfuseType(new InfuseType("FUNGI", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 20, 0).setUnlocalizedName("infuse.fungi")); } - + @EventHandler - public void init(FMLInitializationEvent event) + public void init(FMLInitializationEvent event) { //Register the mod's ore handler GameRegistry.registerWorldGenerator(new OreHandler()); - + //Register player tracker GameRegistry.registerPlayerTracker(new CommonPlayerTracker()); - + //Register the mod's GUI handler NetworkRegistry.instance().registerGuiHandler(this, new CoreGuiHandler()); - + //Initialization notification System.out.println("[Mekanism] Version " + versionNumber + " initializing..."); - + //Get data from server. new ThreadGetData(); - + //Register to receive subscribed events MinecraftForge.EVENT_BUS.register(this); @@ -1171,10 +1171,10 @@ public class Mekanism { voiceManager = new VoiceServerManager(); } - + //Register with TransmitterNetworkRegistry TransmitterNetworkRegistry.initiate(); - + //Load configuration proxy.loadConfiguration(); @@ -1183,7 +1183,7 @@ public class Mekanism addBlocks(); addRecipes(); addEntities(); - + registerOreDict(); new MultipartMekanism(); @@ -1214,33 +1214,33 @@ public class Mekanism PacketHandler.registerPacket(PacketScubaTankData.class); PacketHandler.registerPacket(PacketConfigSync.class); PacketHandler.registerPacket(PacketBoxBlacklist.class); - + //Load proxy proxy.registerRenderInformation(); proxy.loadUtilities(); - + //Completion notification System.out.println("[Mekanism] Loading complete."); - + //Success message logger.info("[Mekanism] Mod loaded."); - } - + } + @EventHandler public void postInit(FMLPostInitializationEvent event) - { + { proxy.loadSoundHandler(); hooks.hook(); - + MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent()); - + addIntegratedItems(); - + OreDictManager.init(); - + System.out.println("[Mekanism] Hooking complete."); } - + @ForgeSubscribe public void onEnergyTransferred(EnergyTransferEvent event) { @@ -1248,7 +1248,7 @@ public class Mekanism PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.ENERGY, event.energyNetwork.transmitters.iterator().next(), event.power)); } catch(Exception e) {} } - + @ForgeSubscribe public void onGasTransferred(GasTransferEvent event) { @@ -1256,7 +1256,7 @@ public class Mekanism PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.GAS, event.gasNetwork.transmitters.iterator().next(), event.transferType, event.didTransfer)); } catch(Exception e) {} } - + @ForgeSubscribe public void onLiquidTransferred(FluidTransferEvent event) { @@ -1264,7 +1264,7 @@ public class Mekanism PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTransmitterUpdate().setParams(PacketType.FLUID, event.fluidNetwork.transmitters.iterator().next(), event.fluidType, event.didTransfer)); } catch(Exception e) {} } - + @ForgeSubscribe public void onNetworkClientRequest(NetworkClientRequest event) { @@ -1272,7 +1272,7 @@ public class Mekanism PacketHandler.sendPacket(Transmission.SERVER, new PacketDataRequest().setParams(Coord4D.get(event.tileEntity))); } catch(Exception e) {} } - + @ForgeSubscribe public void onClientTickUpdate(ClientTickUpdate event) { @@ -1286,7 +1286,7 @@ public class Mekanism } } catch(Exception e) {} } - + @ForgeSubscribe public void onBlacklistUpdate(BoxBlacklistEvent event) { @@ -1300,25 +1300,25 @@ public class Mekanism MekanismAPI.addBoxBlacklist(Block.doorWood.blockID, OreDictionary.WILDCARD_VALUE); MekanismAPI.addBoxBlacklist(Block.doorIron.blockID, OreDictionary.WILDCARD_VALUE); MekanismAPI.addBoxBlacklist(MultipartProxy.block().blockID, OreDictionary.WILDCARD_VALUE); - + BoxBlacklistParser.load(); } - + @ForgeSubscribe public synchronized void onChunkLoad(ChunkEvent.Load event) { if(event.getChunk() != null && !event.world.isRemote) { Map copy = (Map)((HashMap)event.getChunk().chunkTileEntityMap).clone(); - + for(Iterator iter = copy.values().iterator(); iter.hasNext();) { Object obj = iter.next(); - + if(obj instanceof TileEntity) { TileEntity tileEntity = (TileEntity)obj; - + if(tileEntity instanceof TileEntityElectricBlock) { ((TileEntityElectricBlock)tileEntity).register(); diff --git a/common/mekanism/common/ObfuscatedNames.java b/common/mekanism/common/ObfuscatedNames.java index 8a62e06de..398c845d9 100644 --- a/common/mekanism/common/ObfuscatedNames.java +++ b/common/mekanism/common/ObfuscatedNames.java @@ -1,6 +1,6 @@ package mekanism.common; -public final class ObfuscatedNames +public final class ObfuscatedNames { public static String[] TextureManager_listTickables = new String[] {"listTickables", "field_110583_b", "c"}; public static String[] Minecraft_timer = new String[] {"timer", "field_71428_T", "S"}; diff --git a/common/mekanism/common/OreDictCache.java b/common/mekanism/common/OreDictCache.java index 2e8989086..10f992f92 100644 --- a/common/mekanism/common/OreDictCache.java +++ b/common/mekanism/common/OreDictCache.java @@ -14,41 +14,41 @@ import net.minecraftforge.oredict.OreDictionary; public class OreDictCache { public static HashMap> cachedKeys = new HashMap>(); - + public static List getOreDictName(ItemStack check) { ItemInfo info = ItemInfo.get(check); - + if(cachedKeys.get(info) != null) { return cachedKeys.get(info); } - - List idsFound = new ArrayList(); - HashMap> oreStacks = (HashMap>)MekanismUtils.getPrivateValue(null, OreDictionary.class, new String[] {"oreStacks"}); - oreStacks = (HashMap>)oreStacks.clone(); - - for(Map.Entry> entry : oreStacks.entrySet()) - { - for(ItemStack stack : entry.getValue()) - { - if(StackUtils.equalsWildcard(stack, check)) - { - idsFound.add(entry.getKey()); - break; - } - } - } - - List ret = new ArrayList(); - - for(Integer id : idsFound) - { - ret.add(OreDictionary.getOreName(id)); - } - - cachedKeys.put(info, ret); - - return ret; + + List idsFound = new ArrayList(); + HashMap> oreStacks = (HashMap>)MekanismUtils.getPrivateValue(null, OreDictionary.class, new String[] {"oreStacks"}); + oreStacks = (HashMap>)oreStacks.clone(); + + for(Map.Entry> entry : oreStacks.entrySet()) + { + for(ItemStack stack : entry.getValue()) + { + if(StackUtils.equalsWildcard(stack, check)) + { + idsFound.add(entry.getKey()); + break; + } + } + } + + List ret = new ArrayList(); + + for(Integer id : idsFound) + { + ret.add(OreDictionary.getOreName(id)); + } + + cachedKeys.put(info, ret); + + return ret; } } diff --git a/common/mekanism/common/OreHandler.java b/common/mekanism/common/OreHandler.java index 3e402ff5c..636d4b491 100644 --- a/common/mekanism/common/OreHandler.java +++ b/common/mekanism/common/OreHandler.java @@ -12,9 +12,9 @@ import net.minecraft.world.gen.feature.WorldGenMinable; import cpw.mods.fml.common.IWorldGenerator; public class OreHandler implements IWorldGenerator -{ +{ @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if(!(chunkGenerator instanceof ChunkProviderHell) && !(chunkGenerator instanceof ChunkProviderEnd)) { @@ -28,7 +28,7 @@ public class OreHandler implements IWorldGenerator new WorldGenMinable(Mekanism.oreBlockID, 0, 8, Block.stone.blockID).generate(world, random, randPosX, randPosY, randPosZ); } } - + if(Mekanism.copperGenerationEnabled) { for(int i = 0; i < Mekanism.copperGenerationAmount; i++) @@ -39,7 +39,7 @@ public class OreHandler implements IWorldGenerator new WorldGenMinable(Mekanism.oreBlockID, 1, 8, Block.stone.blockID).generate(world, random, randPosX, randPosY, randPosZ); } } - + if(Mekanism.tinGenerationEnabled) { for(int i = 0; i < Mekanism.tinGenerationAmount; i++) diff --git a/common/mekanism/common/PacketHandler.java b/common/mekanism/common/PacketHandler.java index 9998c3b1f..a418e13c8 100644 --- a/common/mekanism/common/PacketHandler.java +++ b/common/mekanism/common/PacketHandler.java @@ -28,32 +28,32 @@ public class PacketHandler implements IPacketHandler { /** The ArrayList of registered packet classes, who's index tells which packet is which. */ public static List> packets = new ArrayList>(); - + @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { ByteArrayDataInput dataStream = ByteStreams.newDataInput(packet.data); - EntityPlayer entityplayer = (EntityPlayer)player; - + EntityPlayer entityplayer = (EntityPlayer)player; + if(packet.channel.equals("MEK")) { try { int packetIndex = dataStream.readInt(); - + if(packets.get(packetIndex) == null) { System.err.println("[Mekanism] Received unknown packet identifier '" + packetIndex + ".' Ignorning!"); return; } - + IMekanismPacket packetType = packets.get(packetIndex).newInstance(); - + if(packetType == null) { System.err.println("[Mekanism] Unable to create instance of packet type '" + packetIndex + ".' Ignoring!"); return; } - + try { packetType.read(dataStream, entityplayer, entityplayer.worldObj); } catch(Exception e) { @@ -66,7 +66,7 @@ public class PacketHandler implements IPacketHandler } } } - + /** * Registers a packet class for identification and reflection purposes. This MUST be called both server-side and client-side, * otherwise the packet will not be handled correctly. @@ -79,7 +79,7 @@ public class PacketHandler implements IPacketHandler packets.add(packetClass); } } - + /** * Encodes an Object[] of data into a DataOutputStream. * @param dataValues - an Object[] of data to encode @@ -88,57 +88,57 @@ public class PacketHandler implements IPacketHandler public static void encode(Object[] dataValues, DataOutputStream output) { try { - for(Object data : dataValues) - { - if(data instanceof Integer) - { - output.writeInt((Integer)data); - } - else if(data instanceof Boolean) - { - output.writeBoolean((Boolean)data); - } - else if(data instanceof Double) - { - output.writeDouble((Double)data); - } - else if(data instanceof Float) - { - output.writeFloat((Float)data); - } - else if(data instanceof String) - { - output.writeUTF((String)data); - } - else if(data instanceof Byte) - { - output.writeByte((Byte)data); - } - else if(data instanceof int[]) - { - for(int i : (int[])data) - { - output.writeInt(i); - } - } - else if(data instanceof byte[]) - { - for(byte b : (byte[])data) - { - output.writeByte(b); - } - } - else if(data instanceof ArrayList) - { - encode(((ArrayList)data).toArray(), output); - } - } + for(Object data : dataValues) + { + if(data instanceof Integer) + { + output.writeInt((Integer)data); + } + else if(data instanceof Boolean) + { + output.writeBoolean((Boolean)data); + } + else if(data instanceof Double) + { + output.writeDouble((Double)data); + } + else if(data instanceof Float) + { + output.writeFloat((Float)data); + } + else if(data instanceof String) + { + output.writeUTF((String)data); + } + else if(data instanceof Byte) + { + output.writeByte((Byte)data); + } + else if(data instanceof int[]) + { + for(int i : (int[])data) + { + output.writeInt(i); + } + } + else if(data instanceof byte[]) + { + for(byte b : (byte[])data) + { + output.writeByte(b); + } + } + else if(data instanceof ArrayList) + { + encode(((ArrayList)data).toArray(), output); + } + } } catch(Exception e) { - System.err.println("[Mekanism] Error while encoding packet data."); - e.printStackTrace(); + System.err.println("[Mekanism] Error while encoding packet data."); + e.printStackTrace(); } } - + /** * Sends a packet with the defined type of transmission. * @param trans - the type of transmission to use with this packet @@ -152,52 +152,52 @@ public class PacketHandler implements IPacketHandler System.err.println("[Mekanism] Attempted to send null packet, ignoring!"); return; } - + if(!packets.contains(packetType.getClass())) { System.err.println("[Mekanism] Attempted to send unregistered packet '" + packetType.getName() + ",' ignoring!"); return; } - - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(bytes); - - try { - data.writeInt(packets.indexOf(packetType.getClass())); - packetType.write(data); - } catch(Exception e) { - System.err.println("[Mekanism] Error while encoding packet data."); - e.printStackTrace(); - } - - Packet250CustomPayload packet = new Packet250CustomPayload(); - packet.channel = "MEK"; - packet.data = bytes.toByteArray(); - packet.length = packet.data.length; - - switch(trans) - { - case SERVER: - PacketDispatcher.sendPacketToServer(packet); - break; - case ALL_CLIENTS: - PacketDispatcher.sendPacketToAllPlayers(packet); - break; - case CLIENTS_RANGE: - Coord4D obj = (Coord4D)transParams[0]; - PacketDispatcher.sendPacketToAllAround(obj.xCoord, obj.yCoord, obj.zCoord, (Double)transParams[1], obj.dimensionId, packet); - break; - case CLIENTS_DIM: - PacketDispatcher.sendPacketToAllInDimension(packet, (Integer)transParams[0]); - break; - case SINGLE_CLIENT: - ((EntityPlayerMP)transParams[0]).playerNetServerHandler.sendPacketToPlayer(packet); - break; - } - - log(trans, packetType, transParams); + + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + DataOutputStream data = new DataOutputStream(bytes); + + try { + data.writeInt(packets.indexOf(packetType.getClass())); + packetType.write(data); + } catch(Exception e) { + System.err.println("[Mekanism] Error while encoding packet data."); + e.printStackTrace(); + } + + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "MEK"; + packet.data = bytes.toByteArray(); + packet.length = packet.data.length; + + switch(trans) + { + case SERVER: + PacketDispatcher.sendPacketToServer(packet); + break; + case ALL_CLIENTS: + PacketDispatcher.sendPacketToAllPlayers(packet); + break; + case CLIENTS_RANGE: + Coord4D obj = (Coord4D)transParams[0]; + PacketDispatcher.sendPacketToAllAround(obj.xCoord, obj.yCoord, obj.zCoord, (Double)transParams[1], obj.dimensionId, packet); + break; + case CLIENTS_DIM: + PacketDispatcher.sendPacketToAllInDimension(packet, (Integer)transParams[0]); + break; + case SINGLE_CLIENT: + ((EntityPlayerMP)transParams[0]).playerNetServerHandler.sendPacketToPlayer(packet); + break; + } + + log(trans, packetType, transParams); } - + /** * Writes a log to the console with information about a packet recently sent. * @param trans - transmission type this packet used when it was sent @@ -228,26 +228,26 @@ public class PacketHandler implements IPacketHandler } } } - + public static enum Transmission { /** No additional parameters. */ SERVER(0), - + /** No additional parameters. */ ALL_CLIENTS(0), - + /** 2 parameters - Object3D representing the location of the transmission, and a double of the distance this packet can be sent in. */ CLIENTS_RANGE(2), - + /** 1 parameter - int representing the dimension ID to send this packet to. */ CLIENTS_DIM(1), - + /** 1 parameter - EntityPlayer to send this packet to. */ SINGLE_CLIENT(1); - + public int parameters; - + private Transmission(int params) { parameters = params; diff --git a/common/mekanism/common/Resource.java b/common/mekanism/common/Resource.java index faf554fec..fbd40993c 100644 --- a/common/mekanism/common/Resource.java +++ b/common/mekanism/common/Resource.java @@ -10,14 +10,14 @@ public enum Resource SILVER("Silver"), OBSIDIAN("Obsidian"), LEAD("Lead"); - + private String name; - + private Resource(String s) { name = s; } - + public static Resource getFromName(String s) { for(Resource r : values()) @@ -27,10 +27,10 @@ public enum Resource return r; } } - + return null; } - + public String getName() { return name; diff --git a/common/mekanism/common/RobitAIFollow.java b/common/mekanism/common/RobitAIFollow.java index 197442193..d9c7d1979 100644 --- a/common/mekanism/common/RobitAIFollow.java +++ b/common/mekanism/common/RobitAIFollow.java @@ -10,133 +10,133 @@ import net.minecraft.world.World; public class RobitAIFollow extends EntityAIBase { /** The robit entity. */ - private EntityRobit theRobit; - - /** The robit's owner. */ - private EntityPlayer theOwner; - - /** The world the robit is located in. */ - private World theWorld; - - /** How fast the robit can travel. */ - private float moveSpeed; - - /** The robit's pathfinder. */ - private PathNavigate thePathfinder; - - /** The ticker for updates. */ - private int ticker; - - /** The distance between the owner the robit must be at in order for the protocol to begin. */ - private float maxDist; - - /** The distance between the owner the robit must reach before it stops the protocol. */ - private float minDist; - - /** Whether or not this robit avoids water. */ - private boolean avoidWater; + private EntityRobit theRobit; - public RobitAIFollow(EntityRobit entityRobit, float speed, float min, float max) - { - theRobit = entityRobit; - theWorld = entityRobit.worldObj; - moveSpeed = speed; - thePathfinder = entityRobit.getNavigator(); - minDist = min; - maxDist = max; - setMutexBits(3); - } + /** The robit's owner. */ + private EntityPlayer theOwner; - @Override - public boolean shouldExecute() - { - EntityPlayer player = theRobit.getOwner(); + /** The world the robit is located in. */ + private World theWorld; - if(player == null) - { - return false; - } - else if(theRobit.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId) - { - return false; - } - else if(!theRobit.getFollowing()) - { - //Still looks up at the player if on chargepad or not following - - theRobit.getLookHelper().setLookPositionWithEntity(player, 6.0F, theRobit.getVerticalFaceSpeed()/10); - return false; - } - else if(theRobit.getDistanceSqToEntity(player) < (minDist * minDist)) - { - return false; - } - else if(theRobit.getEnergy() == 0) - { - return false; - } - else { - theOwner = player; - return true; - } - } + /** How fast the robit can travel. */ + private float moveSpeed; - @Override - public boolean continueExecuting() - { - return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0 && theOwner.worldObj.provider.dimensionId == theRobit.worldObj.provider.dimensionId; - } + /** The robit's pathfinder. */ + private PathNavigate thePathfinder; - @Override - public void startExecuting() - { - ticker = 0; - avoidWater = theRobit.getNavigator().getAvoidsWater(); - theRobit.getNavigator().setAvoidsWater(false); - } + /** The ticker for updates. */ + private int ticker; - @Override - public void resetTask() - { - theOwner = null; - thePathfinder.clearPathEntity(); - theRobit.getNavigator().setAvoidsWater(avoidWater); - } + /** The distance between the owner the robit must be at in order for the protocol to begin. */ + private float maxDist; - @Override - public void updateTask() - { - theRobit.getLookHelper().setLookPositionWithEntity(theOwner, 6.0F, theRobit.getVerticalFaceSpeed()/10); + /** The distance between the owner the robit must reach before it stops the protocol. */ + private float minDist; - if(theRobit.getFollowing()) - { - if(--ticker <= 0) - { - ticker = 10; + /** Whether or not this robit avoids water. */ + private boolean avoidWater; - if(!thePathfinder.tryMoveToEntityLiving(theOwner, moveSpeed)) - { - if(theRobit.getDistanceSqToEntity(theOwner) >= 144.0D) - { - int x = MathHelper.floor_double(theOwner.posX) - 2; - int y = MathHelper.floor_double(theOwner.posZ) - 2; - int z = MathHelper.floor_double(theOwner.boundingBox.minY); + public RobitAIFollow(EntityRobit entityRobit, float speed, float min, float max) + { + theRobit = entityRobit; + theWorld = entityRobit.worldObj; + moveSpeed = speed; + thePathfinder = entityRobit.getNavigator(); + minDist = min; + maxDist = max; + setMutexBits(3); + } - for(int l = 0; l <= 4; ++l) - { - for(int i1 = 0; i1 <= 4; ++i1) - { - if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && theWorld.doesBlockHaveSolidTopSurface(x + l, z - 1, y + i1) && !theWorld.isBlockNormalCube(x + l, z, y + i1) && !theWorld.isBlockNormalCube(x + l, z + 1, y + i1)) - { - theRobit.setLocationAndAngles((x + l) + 0.5F, z, (y + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); - thePathfinder.clearPathEntity(); - return; - } - } - } - } - } - } - } - } + @Override + public boolean shouldExecute() + { + EntityPlayer player = theRobit.getOwner(); + + if(player == null) + { + return false; + } + else if(theRobit.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId) + { + return false; + } + else if(!theRobit.getFollowing()) + { + //Still looks up at the player if on chargepad or not following + + theRobit.getLookHelper().setLookPositionWithEntity(player, 6.0F, theRobit.getVerticalFaceSpeed()/10); + return false; + } + else if(theRobit.getDistanceSqToEntity(player) < (minDist * minDist)) + { + return false; + } + else if(theRobit.getEnergy() == 0) + { + return false; + } + else { + theOwner = player; + return true; + } + } + + @Override + public boolean continueExecuting() + { + return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0 && theOwner.worldObj.provider.dimensionId == theRobit.worldObj.provider.dimensionId; + } + + @Override + public void startExecuting() + { + ticker = 0; + avoidWater = theRobit.getNavigator().getAvoidsWater(); + theRobit.getNavigator().setAvoidsWater(false); + } + + @Override + public void resetTask() + { + theOwner = null; + thePathfinder.clearPathEntity(); + theRobit.getNavigator().setAvoidsWater(avoidWater); + } + + @Override + public void updateTask() + { + theRobit.getLookHelper().setLookPositionWithEntity(theOwner, 6.0F, theRobit.getVerticalFaceSpeed()/10); + + if(theRobit.getFollowing()) + { + if(--ticker <= 0) + { + ticker = 10; + + if(!thePathfinder.tryMoveToEntityLiving(theOwner, moveSpeed)) + { + if(theRobit.getDistanceSqToEntity(theOwner) >= 144.0D) + { + int x = MathHelper.floor_double(theOwner.posX) - 2; + int y = MathHelper.floor_double(theOwner.posZ) - 2; + int z = MathHelper.floor_double(theOwner.boundingBox.minY); + + for(int l = 0; l <= 4; ++l) + { + for(int i1 = 0; i1 <= 4; ++i1) + { + if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && theWorld.doesBlockHaveSolidTopSurface(x + l, z - 1, y + i1) && !theWorld.isBlockNormalCube(x + l, z, y + i1) && !theWorld.isBlockNormalCube(x + l, z + 1, y + i1)) + { + theRobit.setLocationAndAngles((x + l) + 0.5F, z, (y + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); + thePathfinder.clearPathEntity(); + return; + } + } + } + } + } + } + } + } } diff --git a/common/mekanism/common/RobitAIPickup.java b/common/mekanism/common/RobitAIPickup.java index fc14e39f8..c55e6816e 100644 --- a/common/mekanism/common/RobitAIPickup.java +++ b/common/mekanism/common/RobitAIPickup.java @@ -62,13 +62,13 @@ public class RobitAIPickup extends EntityAIBase Iterator iter = items.iterator(); //Cached for slight performance double closestDistance=-1; - + while(iter.hasNext()) { EntityItem entity = (EntityItem)iter.next(); - + double distance = theRobit.getDistanceToEntity(entity); - + if(distance <= 10) { if(closestDistance == -1 || distance < closestDistance) @@ -81,13 +81,13 @@ public class RobitAIPickup extends EntityAIBase } } } - + if(closest == null) { //No valid items return false; } - + return true; } @@ -117,7 +117,7 @@ public class RobitAIPickup extends EntityAIBase public void updateTask() { theRobit.getLookHelper().setLookPositionWithEntity(closest, 6.0F, theRobit.getVerticalFaceSpeed()/10); - + if(!theRobit.getDropPickup()) { return; diff --git a/common/mekanism/common/SideData.java b/common/mekanism/common/SideData.java index f892bcf89..909fd7d5f 100644 --- a/common/mekanism/common/SideData.java +++ b/common/mekanism/common/SideData.java @@ -2,14 +2,14 @@ package mekanism.common; import mekanism.api.EnumColor; -public class SideData +public class SideData { /** The color of this SideData */ public EnumColor color; - + /** Int[] of available side slots */ public int[] availableSlots; - + public SideData(EnumColor colour, int[] slots) { color = colour; diff --git a/common/mekanism/common/Teleporter.java b/common/mekanism/common/Teleporter.java index edb0e4623..d4536e52a 100644 --- a/common/mekanism/common/Teleporter.java +++ b/common/mekanism/common/Teleporter.java @@ -13,7 +13,7 @@ public class Teleporter public int digitTwo; public int digitThree; public int digitFour; - + public Code(int one, int two, int three, int four) { digitOne = one; @@ -23,7 +23,7 @@ public class Teleporter } @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + digitOne; @@ -32,7 +32,7 @@ public class Teleporter code = 31 * code + digitFour; return code; } - + @Override public boolean equals(Object code) { diff --git a/common/mekanism/common/ThreadGetData.java b/common/mekanism/common/ThreadGetData.java index 6b069d555..310154f54 100644 --- a/common/mekanism/common/ThreadGetData.java +++ b/common/mekanism/common/ThreadGetData.java @@ -14,13 +14,13 @@ public class ThreadGetData extends Thread setDaemon(true); start(); } - + @Override public void run() { Mekanism.latestVersionNumber = MekanismUtils.getLatestVersion(); Mekanism.recentNews = MekanismUtils.getRecentNews(); - + MekanismUtils.updateDonators(); } } diff --git a/common/mekanism/common/Tier.java b/common/mekanism/common/Tier.java index 9498330e3..0367ddd5b 100644 --- a/common/mekanism/common/Tier.java +++ b/common/mekanism/common/Tier.java @@ -9,7 +9,7 @@ import net.minecraft.util.ResourceLocation; * @author aidancbrady * */ -public final class Tier +public final class Tier { /** * The tiers used by the Energy Cube and their corresponding values. @@ -22,12 +22,12 @@ public final class Tier ADVANCED("Advanced", EnumColor.DARK_RED, 8000000, 3200), ELITE("Elite", EnumColor.DARK_BLUE, 32000000, 12800), ULTIMATE("Ultimate", EnumColor.PURPLE, 128000000, 51200); - + public double MAX_ELECTRICITY; public double OUTPUT; public String name; public EnumColor color; - + public static EnergyCubeTier getFromName(String tierName) { for(EnergyCubeTier tier : values()) @@ -37,11 +37,11 @@ public final class Tier return tier; } } - + System.out.println("[Mekanism] Invalid tier identifier when retrieving with name."); return BASIC; } - + private EnergyCubeTier(String s, EnumColor c, double maxEnergy, double out) { name = s; @@ -50,7 +50,7 @@ public final class Tier OUTPUT = out; } } - + /** * The tiers used by the Factory and their corresponding values. * @author aidancbrady @@ -61,11 +61,11 @@ public final class Tier BASIC("Basic", 3, new ResourceLocation("mekanism", "gui/factory/GuiBasicFactory.png")), ADVANCED("Advanced", 5, new ResourceLocation("mekanism", "gui/factory/GuiAdvancedFactory.png")), ELITE("Elite", 7, new ResourceLocation("mekanism", "gui/factory/GuiEliteFactory.png")); - + public int processes; public ResourceLocation guiLocation; public String name; - + public static FactoryTier getFromName(String tierName) { for(FactoryTier tier : values()) @@ -75,11 +75,11 @@ public final class Tier return tier; } } - + System.out.println("[Mekanism] Invalid tier identifier when retrieving with name."); return BASIC; } - + private FactoryTier(String s, int process, ResourceLocation gui) { name = s; @@ -99,10 +99,10 @@ public final class Tier ADVANCED(2000, TransmitterType.UNIVERSAL_CABLE_ADVANCED), ELITE(8000, TransmitterType.UNIVERSAL_CABLE_ELITE), ULTIMATE(32000, TransmitterType.UNIVERSAL_CABLE_ULTIMATE); - + public int cableCapacity; public TransmitterType type; - + private CableTier(int capacity, TransmitterType transmitterType) { cableCapacity = capacity; diff --git a/common/mekanism/common/Version.java b/common/mekanism/common/Version.java index bd8e217fe..ee5b058cd 100644 --- a/common/mekanism/common/Version.java +++ b/common/mekanism/common/Version.java @@ -9,13 +9,13 @@ public class Version { /** Major number for version */ public int major; - + /** Minor number for version */ public int minor; - + /** Build number for version */ public int build; - + /** * Creates a version number with 3 digits. * @param majorNum - major version @@ -28,9 +28,9 @@ public class Version minor = minorNum; build = buildNum; } - - /** - * Resets the version number to "0.0.0." + + /** + * Resets the version number to "0.0.0." */ public void reset() { @@ -38,7 +38,7 @@ public class Version minor = 0; build = 0; } - + /** * 1: greater than * 0: equal to @@ -80,7 +80,7 @@ public class Version return 1; } } - + /** * Gets a version object from a string. * @param s - string object @@ -89,12 +89,12 @@ public class Version public static Version get(String s) { String[] split = s.replace('.', ':').split(":"); - + if(split.length != 3) { return null; } - + for(String i : split) { for(Character c : i.toCharArray()) @@ -105,17 +105,17 @@ public class Version } } } - + int[] digits = new int[3]; - + for(int i = 0; i < 3; i++) { digits[i] = Integer.parseInt(split[i]); } - + return new Version(digits[0], digits[1], digits[2]); } - + @Override public String toString() { diff --git a/common/mekanism/common/asm/LoadingHook.java b/common/mekanism/common/asm/LoadingHook.java index fc4c200e1..f3ea22d15 100644 --- a/common/mekanism/common/asm/LoadingHook.java +++ b/common/mekanism/common/asm/LoadingHook.java @@ -11,7 +11,7 @@ public class LoadingHook implements IFMLLoadingPlugin { DepLoader.load(); } - + public String[] getLibraryRequestClass() { return null; @@ -34,6 +34,6 @@ public class LoadingHook implements IFMLLoadingPlugin public void injectData(Map data) { - + } } diff --git a/common/mekanism/common/block/BlockBasic.java b/common/mekanism/common/block/BlockBasic.java index 348a666d5..85709c0ab 100644 --- a/common/mekanism/common/block/BlockBasic.java +++ b/common/mekanism/common/block/BlockBasic.java @@ -72,9 +72,9 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockBasic extends Block { public Icon[][] icons = new Icon[256][6]; - + public ConnectedTextureRenderer glassRenderer = new ConnectedTextureRenderer("glass/DynamicGlass", blockID, 10); - + public BlockBasic(int id) { super(id, Material.iron); @@ -82,26 +82,26 @@ public class BlockBasic extends Block setResistance(10F); setCreativeTab(Mekanism.tabMekanism); } - + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { if(!world.isRemote) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(id == blockID && tileEntity instanceof TileEntityDynamicTank) { ((TileEntityDynamicTank)tileEntity).update(); } - + if(tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock)tileEntity).onNeighborChange(id); } } } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) @@ -130,7 +130,7 @@ public class BlockBasic extends Block icons[14][1] = register.registerIcon("mekanism:SalinationControllerOn"); icons[14][2] = register.registerIcon("mekanism:SalinationBlock"); icons[15][0] = register.registerIcon("mekanism:SalinationValve"); - + glassRenderer.registerIcons(register); } else if(blockID == Mekanism.basicBlock2ID) @@ -138,19 +138,19 @@ public class BlockBasic extends Block icons[0][0] = register.registerIcon("mekanism:SalinationBlock"); } } - - @Override - @SideOnly(Side.CLIENT) - public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) - { - int metadata = world.getBlockMetadata(x, y, z); - if(blockID == Mekanism.basicBlockID) - { + @Override + @SideOnly(Side.CLIENT) + public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) + { + int metadata = world.getBlockMetadata(x, y, z); + + if(blockID == Mekanism.basicBlockID) + { if(metadata == 6) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - + if(side == 0 || side == 1) { return MekanismUtils.isActive(world, x, y, z) ? icons[6][3] : icons[6][1]; @@ -163,14 +163,14 @@ public class BlockBasic extends Block return icons[6][0]; } } - else if(metadata == 10) - { - return glassRenderer.getIcon(world, x, y, z, side); - } + else if(metadata == 10) + { + return glassRenderer.getIcon(world, x, y, z, side); + } else if(metadata == 14) { TileEntitySalinationController tileEntity = (TileEntitySalinationController)world.getBlockTileEntity(x, y, z); - + if(side == tileEntity.facing) { return tileEntity.structured ? icons[14][1] : icons[14][0]; @@ -179,18 +179,18 @@ public class BlockBasic extends Block return icons[14][2]; } } - else { - return getIcon(side, metadata); - } - } - else if(blockID == Mekanism.basicBlock2ID) - { - return getIcon(side, metadata); - } - - return null; - } - + else { + return getIcon(side, metadata); + } + } + else if(blockID == Mekanism.basicBlock2ID) + { + return getIcon(side, metadata); + } + + return null; + } + @Override @SideOnly(Side.CLIENT) public Icon getIcon(int side, int meta) @@ -230,16 +230,16 @@ public class BlockBasic extends Block { return icons[meta][0]; } - + return null; } - + @Override public int damageDropped(int i) { return i; } - + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(int i, CreativeTabs creativetabs, List list) @@ -268,56 +268,56 @@ public class BlockBasic extends Block list.add(new ItemStack(i, 1, 0)); } } - + @Override - public boolean canCreatureSpawn(EnumCreatureType type, World world, int x, int y, int z) - { - int meta = world.getBlockMetadata(x, y, z); - - if(blockID == Mekanism.basicBlockID) - { - if(meta == 9 || meta == 10 || meta == 11) - { - TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)world.getBlockTileEntity(x, y, z); - - if(tileEntity != null) - { - if(!world.isRemote) - { - if(tileEntity.structure != null) - { - return false; - } - } - else { - if(tileEntity.clientHasStructure) - { - return false; - } - } - } - } - } - else if(blockID == Mekanism.basicBlock2ID) - { - - } - - return super.canCreatureSpawn(type, world, x, y, z); - } - + public boolean canCreatureSpawn(EnumCreatureType type, World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + + if(blockID == Mekanism.basicBlockID) + { + if(meta == 9 || meta == 10 || meta == 11) + { + TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)world.getBlockTileEntity(x, y, z); + + if(tileEntity != null) + { + if(!world.isRemote) + { + if(tileEntity.structure != null) + { + return false; + } + } + else { + if(tileEntity.clientHasStructure) + { + return false; + } + } + } + } + } + else if(blockID == Mekanism.basicBlock2ID) + { + + } + + return super.canCreatureSpawn(type, world, x, y, z); + } + @Override public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { int meta = world.getBlockMetadata(x, y, z); - + if(blockID == Mekanism.basicBlockID) { if(!world.isRemote && meta == 6) - { + { TileEntityBin bin = (TileEntityBin)world.getBlockTileEntity(x, y, z); MovingObjectPosition pos = MekanismUtils.rayTrace(world, player); - + if(pos != null && pos.sideHit == bin.facing) { if(bin.bottomStack != null) @@ -334,31 +334,31 @@ public class BlockBasic extends Block } } } - + @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) - { - int metadata = world.getBlockMetadata(x, y, z); - - if(blockID == Mekanism.basicBlockID) - { - if(metadata != 6) - { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) + { + int metadata = world.getBlockMetadata(x, y, z); + + if(blockID == Mekanism.basicBlockID) + { + if(metadata != 6) + { if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) { return false; } - } - - if(metadata == 2) - { - if(entityplayer.isSneaking()) - { - entityplayer.openGui(Mekanism.instance, 1, world, x, y, z); - return true; - } - } - + } + + if(metadata == 2) + { + if(entityplayer.isSneaking()) + { + entityplayer.openGui(Mekanism.instance, 1, world, x, y, z); + return true; + } + } + if(metadata == 14) { if(!entityplayer.isSneaking()) @@ -367,56 +367,56 @@ public class BlockBasic extends Block return true; } } - - if(world.isRemote) - { - return true; - } - - if(metadata == 6) - { - TileEntityBin bin = (TileEntityBin)world.getBlockTileEntity(x, y, z); - - if(bin.getItemCount() < bin.MAX_STORAGE) - { - if(bin.addTicks == 0) - { - if(entityplayer.getCurrentEquippedItem() != null) - { - ItemStack remain = bin.add(entityplayer.getCurrentEquippedItem()); - entityplayer.setCurrentItemOrArmor(0, remain); - bin.addTicks = 5; - } - } - else { - ItemStack[] inv = entityplayer.inventory.mainInventory; - - for(int i = 0; i < inv.length; i++) - { - if(bin.getItemCount() == bin.MAX_STORAGE) - { - break; - } - - if(inv[i] != null) - { - ItemStack remain = bin.add(inv[i]); - inv[i] = remain; - } - - ((EntityPlayerMP)entityplayer).sendContainerAndContentsToPlayer(entityplayer.openContainer, entityplayer.openContainer.getInventory()); - } - } - } - - return true; - } - else if(metadata == 9 || metadata == 10 || metadata == 11) - { + + if(world.isRemote) + { + return true; + } + + if(metadata == 6) + { + TileEntityBin bin = (TileEntityBin)world.getBlockTileEntity(x, y, z); + + if(bin.getItemCount() < bin.MAX_STORAGE) + { + if(bin.addTicks == 0) + { + if(entityplayer.getCurrentEquippedItem() != null) + { + ItemStack remain = bin.add(entityplayer.getCurrentEquippedItem()); + entityplayer.setCurrentItemOrArmor(0, remain); + bin.addTicks = 5; + } + } + else { + ItemStack[] inv = entityplayer.inventory.mainInventory; + + for(int i = 0; i < inv.length; i++) + { + if(bin.getItemCount() == bin.MAX_STORAGE) + { + break; + } + + if(inv[i] != null) + { + ItemStack remain = bin.add(inv[i]); + inv[i] = remain; + } + + ((EntityPlayerMP)entityplayer).sendContainerAndContentsToPlayer(entityplayer.openContainer, entityplayer.openContainer.getInventory()); + } + } + } + + return true; + } + else if(metadata == 9 || metadata == 10 || metadata == 11) + { if(!entityplayer.isSneaking() && ((TileEntityDynamicTank)world.getBlockTileEntity(x, y, z)).structure != null) { TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)world.getBlockTileEntity(x, y, z); - + if(!manageInventory(entityplayer, tileEntity)) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList()))); @@ -426,25 +426,25 @@ public class BlockBasic extends Block entityplayer.inventory.onInventoryChanged(); tileEntity.sendPacketToRenderer(); } - + return true; } - } - } - - return false; - } - + } + } + + return false; + } + @Override public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) { return !(blockID == Mekanism.basicBlockID && world.getBlockMetadata(x, y, z) == 10); } - + private boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity) { ItemStack itemStack = player.getCurrentEquippedItem(); - + if(itemStack != null && tileEntity.structure != null) { if(FluidContainerRegistry.isEmptyContainer(itemStack)) @@ -452,21 +452,21 @@ public class BlockBasic extends Block if(tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount >= FluidContainerRegistry.BUCKET_VOLUME) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(tileEntity.structure.fluidStored, itemStack); - + if(filled != null) { if(player.capabilities.isCreativeMode) { tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - + if(tileEntity.structure.fluidStored.amount == 0) { tileEntity.structure.fluidStored = null; } - + return true; } - + if(itemStack.stackSize > 1) { for(int i = 0; i < player.inventory.mainInventory.length; i++) @@ -475,14 +475,14 @@ public class BlockBasic extends Block { player.inventory.mainInventory[i] = filled; itemStack.stackSize--; - + tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - + if(tileEntity.structure.fluidStored.amount == 0) { tileEntity.structure.fluidStored = null; } - + return true; } else if(player.inventory.mainInventory[i].isItemEqual(filled)) @@ -491,14 +491,14 @@ public class BlockBasic extends Block { player.inventory.mainInventory[i].stackSize++; itemStack.stackSize--; - + tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - + if(tileEntity.structure.fluidStored.amount == 0) { tileEntity.structure.fluidStored = null; } - + return true; } } @@ -507,14 +507,14 @@ public class BlockBasic extends Block else if(itemStack.stackSize == 1) { player.setCurrentItemOrArmor(0, filled); - + tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - + if(tileEntity.structure.fluidStored.amount == 0) { tileEntity.structure.fluidStored = null; } - + return true; } } @@ -524,7 +524,7 @@ public class BlockBasic extends Block { FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(itemStack); int max = tileEntity.structure.volume*TankUpdateProtocol.FLUID_PER_TANK; - + if(tileEntity.structure.fluidStored == null || (tileEntity.structure.fluidStored.isFluidEqual(itemFluid) && (tileEntity.structure.fluidStored.amount+itemFluid.amount <= max))) { if(FluidContainerRegistry.isBucket(itemStack)) @@ -536,12 +536,12 @@ public class BlockBasic extends Block else { tileEntity.structure.fluidStored.amount += itemFluid.amount; } - + if(!player.capabilities.isCreativeMode) { player.setCurrentItemOrArmor(0, new ItemStack(Item.bucketEmpty)); } - + return true; } else { @@ -549,12 +549,12 @@ public class BlockBasic extends Block { itemStack.stackSize--; } - + if(itemStack.stackSize == 0) { player.setCurrentItemOrArmor(0, null); } - + if(tileEntity.structure.fluidStored == null) { tileEntity.structure.fluidStored = itemFluid; @@ -562,41 +562,41 @@ public class BlockBasic extends Block else { tileEntity.structure.fluidStored.amount += itemFluid.amount; } - + return true; } } } } - + return false; } - + @Override public boolean renderAsNormalBlock() { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override @SideOnly(Side.CLIENT) public int getRenderType() { return ClientProxy.BASIC_RENDER_ID; } - + @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); - + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + if(tileEntity instanceof IActiveState) { if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate()) @@ -604,23 +604,23 @@ public class BlockBasic extends Block return 15; } } - + if(blockID == Mekanism.basicBlockID) { - switch(metadata) - { - case 2: - return 8; - case 4: - return 15; - case 7: - return 12; - } + switch(metadata) + { + case 2: + return 8; + case 4: + return 15; + case 7: + return 12; + } } - - return 0; - } - + + return 0; + } + @Override public boolean hasTileEntity(int metadata) { @@ -632,10 +632,10 @@ public class BlockBasic extends Block { return metadata == 0; } - + return false; } - + @Override public TileEntity createTileEntity(World world, int metadata) { @@ -665,137 +665,137 @@ public class BlockBasic extends Block return new TileEntitySalinationTank(); } } - + return null; } - + @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) { if(world.getBlockTileEntity(x, y, z) instanceof TileEntityBasicBlock) { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - int side = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); - int change = 3; - - if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) - { - if(height >= 65) - { - change = 1; - } - else if(height <= -65) - { - change = 0; - } - } - - if(change != 0 && change != 1) - { - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - } - - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onPlace(); - } + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + int side = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int height = Math.round(entityliving.rotationPitch); + int change = 3; + + if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) + { + if(height >= 65) + { + change = 1; + } + else if(height <= -65) + { + change = 0; + } + } + + if(change != 0 && change != 1) + { + switch(side) + { + case 0: change = 2; break; + case 1: change = 5; break; + case 2: change = 3; break; + case 3: change = 4; break; + } + } + + tileEntity.setFacing((short)change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + + if(tileEntity instanceof IBoundingBlock) + { + ((IBoundingBlock)tileEntity).onPlace(); + } } - + world.markBlockForRenderUpdate(x, y, z); world.updateAllLightTypes(x, y, z); - + if(!world.isRemote && world.getBlockTileEntity(x, y, z) != null) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof TileEntityDynamicTank) { ((TileEntityDynamicTank)tileEntity).update(); } } } - + @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { ItemStack ret = new ItemStack(blockID, 1, world.getBlockMetadata(x, y, z)); - + if(blockID == Mekanism.basicBlockID) { if(ret.getItemDamage() == 6) { TileEntityBin tileEntity = (TileEntityBin)world.getBlockTileEntity(x, y, z); InventoryBin inv = new InventoryBin(ret); - + inv.setItemCount(tileEntity.getItemCount()); - + if(tileEntity.getItemCount() > 0) { inv.setItemType(tileEntity.itemType); } } } - + return ret; } - - @Override - public int idDropped(int i, Random random, int j) - { - return 0; - } - - @Override - public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); - - world.spawnEntityInWorld(entityItem); - } - - return world.setBlockToAir(x, y, z); - } - - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) + + @Override + public int idDropped(int i, Random random, int j) + { + return 0; + } + + @Override + public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) + { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); + + world.spawnEntityInWorld(entityItem); + } + + return world.setBlockToAir(x, y, z); + } + + public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { ItemStack itemStack = getPickBlock(null, world, x, y, z); - - world.setBlockToAir(x, y, z); - - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - - return itemStack; + + world.setBlockToAir(x, y, z); + + if(!returnBlock) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; } - + @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) diff --git a/common/mekanism/common/block/BlockBounding.java b/common/mekanism/common/block/BlockBounding.java index 09c5820de..5260f83c3 100644 --- a/common/mekanism/common/block/BlockBounding.java +++ b/common/mekanism/common/block/BlockBounding.java @@ -23,7 +23,7 @@ public class BlockBounding extends Block setHardness(3.5F); setResistance(8F); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} @@ -38,7 +38,7 @@ public class BlockBounding extends Block return false; } } - + @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { @@ -49,7 +49,7 @@ public class BlockBounding extends Block return null; } } - + @Override public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) { @@ -60,9 +60,9 @@ public class BlockBounding extends Block return false; } } - + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { try { TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z); @@ -76,12 +76,12 @@ public class BlockBounding extends Block { return 0; } - - @Override - public int idDropped(int i, Random random, int j) - { - return 0; - } + + @Override + public int idDropped(int i, Random random, int j) + { + return 0; + } @Override public int getRenderType() @@ -100,7 +100,7 @@ public class BlockBounding extends Block { return false; } - + @Override public boolean hasTileEntity(int metadata) { @@ -118,7 +118,7 @@ public class BlockBounding extends Block { return new TileEntityAdvancedBoundingBlock(); } - + return null; } } diff --git a/common/mekanism/common/block/BlockCardboardBox.java b/common/mekanism/common/block/BlockCardboardBox.java index b0e8346ac..6d1364db8 100644 --- a/common/mekanism/common/block/BlockCardboardBox.java +++ b/common/mekanism/common/block/BlockCardboardBox.java @@ -23,7 +23,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockCardboardBox extends BlockContainer { public Icon[] icons = new Icon[6]; - + public BlockCardboardBox(int id) { super(id, Material.cloth); @@ -31,7 +31,7 @@ public class BlockCardboardBox extends BlockContainer setHardness(0.5F); setResistance(1F); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) @@ -40,7 +40,7 @@ public class BlockCardboardBox extends BlockContainer icons[1] = register.registerIcon("mekanism:CardboardBoxSide"); icons[2] = register.registerIcon("mekanism:CardboardBoxSideStorage"); } - + @Override @SideOnly(Side.CLIENT) public Icon getIcon(int side, int meta) @@ -53,117 +53,117 @@ public class BlockCardboardBox extends BlockContainer return meta == 0 ? icons[1] : icons[2]; } } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float hitX, float hitY, float hitZ) - { - if(!world.isRemote && entityplayer.isSneaking()) - { - ItemStack itemStack = new ItemStack(Mekanism.CardboardBox); - TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getBlockTileEntity(x, y, z); - - if(tileEntity.storedData != null) - { - BlockData data = tileEntity.storedData; - - if(Block.blocksList[data.id] != null) - { - data.meta = Block.blocksList[data.id].onBlockPlaced(world, x, y, z, facing, hitX, hitY, hitZ, data.meta); - } - - world.setBlock(x, y, z, data.id, data.meta, 3); - - if(data.tileTag != null && world.getBlockTileEntity(x, y, z) != null) - { - data.updateLocation(x, y, z); - world.getBlockTileEntity(x, y, z).readFromNBT(data.tileTag); - } - - if(Block.blocksList[data.id] != null) - { - Block.blocksList[data.id].onBlockPlacedBy(world, x, y, z, entityplayer, new ItemStack(data.id, 1, data.meta)); - Block.blocksList[data.id].onPostBlockPlaced(world, x, y, z, data.meta); - } - - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - } - - return false; - } - + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float hitX, float hitY, float hitZ) + { + if(!world.isRemote && entityplayer.isSneaking()) + { + ItemStack itemStack = new ItemStack(Mekanism.CardboardBox); + TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getBlockTileEntity(x, y, z); + + if(tileEntity.storedData != null) + { + BlockData data = tileEntity.storedData; + + if(Block.blocksList[data.id] != null) + { + data.meta = Block.blocksList[data.id].onBlockPlaced(world, x, y, z, facing, hitX, hitY, hitZ, data.meta); + } + + world.setBlock(x, y, z, data.id, data.meta, 3); + + if(data.tileTag != null && world.getBlockTileEntity(x, y, z) != null) + { + data.updateLocation(x, y, z); + world.getBlockTileEntity(x, y, z).readFromNBT(data.tileTag); + } + + if(Block.blocksList[data.id] != null) + { + Block.blocksList[data.id].onBlockPlacedBy(world, x, y, z, entityplayer, new ItemStack(data.id, 1, data.meta)); + Block.blocksList[data.id].onPostBlockPlaced(world, x, y, z, data.meta); + } + + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + } + + return false; + } + @Override public TileEntity createNewTileEntity(World world) { return new TileEntityCardboardBox(); } - - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = getPickBlock(null, world, x, y, z); - world.setBlockToAir(x, y, z); - - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - - return itemStack; + public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) + { + ItemStack itemStack = getPickBlock(null, world, x, y, z); + + world.setBlockToAir(x, y, z); + + if(!returnBlock) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; } - + @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getBlockTileEntity(x, y, z); - - ItemStack itemStack = new ItemStack(Mekanism.CardboardBox, 1, world.getBlockMetadata(x, y, z)); - + + ItemStack itemStack = new ItemStack(Mekanism.CardboardBox, 1, world.getBlockMetadata(x, y, z)); + if(itemStack.getItemDamage() == 1) { - if(tileEntity.storedData != null) - { - ((ItemBlockCardboardBox)itemStack.getItem()).setBlockData(itemStack, tileEntity.storedData); - } + if(tileEntity.storedData != null) + { + ((ItemBlockCardboardBox)itemStack.getItem()).setBlockData(itemStack, tileEntity.storedData); + } } - + return itemStack; } - - @Override - public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); - - world.spawnEntityInWorld(entityItem); - } - - return world.setBlockToAir(x, y, z); - } - + @Override - public int quantityDropped(Random random) + public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); + + world.spawnEntityInWorld(entityItem); + } + + return world.setBlockToAir(x, y, z); + } + + @Override + public int quantityDropped(Random random) { return 0; } @@ -173,22 +173,22 @@ public class BlockCardboardBox extends BlockContainer { return 0; } - + public static class BlockData { public int id; public int meta; public NBTTagCompound tileTag; - + public BlockData(int i, int j, NBTTagCompound nbtTags) { id = i; meta = j; tileTag = nbtTags; } - + public BlockData() {} - + public void updateLocation(int x, int y, int z) { if(tileTag != null) @@ -198,32 +198,32 @@ public class BlockCardboardBox extends BlockContainer tileTag.setInteger("z", z); } } - + public NBTTagCompound write(NBTTagCompound nbtTags) { nbtTags.setInteger("id", id); nbtTags.setInteger("meta", meta); - + if(tileTag != null) { nbtTags.setCompoundTag("tileTag", tileTag); } - + return nbtTags; } - + public static BlockData read(NBTTagCompound nbtTags) { BlockData data = new BlockData(); - + data.id = nbtTags.getInteger("id"); data.meta = nbtTags.getInteger("meta"); - + if(nbtTags.hasKey("tileTag")) { data.tileTag = nbtTags.getCompoundTag("tileTag"); } - + return data; } } diff --git a/common/mekanism/common/block/BlockEnergyCube.java b/common/mekanism/common/block/BlockEnergyCube.java index 930062b53..41cf85d24 100644 --- a/common/mekanism/common/block/BlockEnergyCube.java +++ b/common/mekanism/common/block/BlockEnergyCube.java @@ -41,7 +41,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** - * Block class for handling multiple energy cube block IDs. + * Block class for handling multiple energy cube block IDs. * 0: Basic Energy Cube * 1: Advanced Energy Cube * 2: Elite Energy Cube @@ -51,7 +51,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockEnergyCube extends BlockContainer { public Icon[][] icons = new Icon[256][256]; - + public BlockEnergyCube(int id) { super(id, Material.iron); @@ -59,67 +59,67 @@ public class BlockEnergyCube extends BlockContainer setResistance(4F); setCreativeTab(Mekanism.tabMekanism); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} - + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { if(!world.isRemote) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock)tileEntity).onNeighborChange(id); } } } - + @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); - int change = 3; - - if(height >= 65) - { - change = 1; - } - else if(height <= -65) - { - change = 0; - } - else { - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - } - - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - } - - @Override - public int quantityDropped(Random random) - { - return 0; - } - - @Override - public int idDropped(int i, Random random, int j) - { - return 0; - } - + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) + { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int height = Math.round(entityliving.rotationPitch); + int change = 3; + + if(height >= 65) + { + change = 1; + } + else if(height <= -65) + { + change = 0; + } + else { + switch(side) + { + case 0: change = 2; break; + case 1: change = 5; break; + case 2: change = 3; break; + case 3: change = 4; break; + } + } + + tileEntity.setFacing((short)change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + } + + @Override + public int quantityDropped(Random random) + { + return 0; + } + + @Override + public int idDropped(int i, Random random, int j) + { + return 0; + } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(int i, CreativeTabs creativetabs, List list) @@ -136,142 +136,142 @@ public class BlockEnergyCube extends BlockContainer list.add(charged); }; } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) - { + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) + { if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) { return false; } - - if(world.isRemote) - { - return true; - } - else { - TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); - - if(entityplayer.getCurrentEquippedItem() != null) - { - Item tool = entityplayer.getCurrentEquippedItem().getItem(); - - if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) - { - if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) - { - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - return true; - } - - ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); - - int change = 0; - - switch(tileEntity.facing) - { - case 3: - change = 5; - break; - case 5: - change = 2; - break; - case 2: - change = 4; - break; - case 4: - change = 1; - break; - case 1: - change = 0; - break; - case 0: - change = 3; - break; - } - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, blockID); - return true; - } - } - } - - if(tileEntity != null) - { - if(!entityplayer.isSneaking()) - { - entityplayer.openGui(Mekanism.instance, 8, world, x, y, z); - return true; - } - } - } - return false; - } - - @Override - public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); - - world.spawnEntityInWorld(entityItem); - } - - return world.setBlockToAir(x, y, z); - } - + + if(world.isRemote) + { + return true; + } + else { + TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + + if(entityplayer.getCurrentEquippedItem() != null) + { + Item tool = entityplayer.getCurrentEquippedItem().getItem(); + + if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) + { + if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) + { + if(entityplayer.isSneaking()) + { + dismantleBlock(world, x, y, z, false); + return true; + } + + ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); + + int change = 0; + + switch(tileEntity.facing) + { + case 3: + change = 5; + break; + case 5: + change = 2; + break; + case 2: + change = 4; + break; + case 4: + change = 1; + break; + case 1: + change = 0; + break; + case 0: + change = 3; + break; + } + + tileEntity.setFacing((short)change); + world.notifyBlocksOfNeighborChange(x, y, z, blockID); + return true; + } + } + } + + if(tileEntity != null) + { + if(!entityplayer.isSneaking()) + { + entityplayer.openGui(Mekanism.instance, 8, world, x, y, z); + return true; + } + } + } + return false; + } + + @Override + public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); + + world.spawnEntityInWorld(entityItem); + } + + return world.setBlockToAir(x, y, z); + } + @Override public TileEntity createNewTileEntity(World world) { return new TileEntityEnergyCube(); } - + @Override public boolean renderAsNormalBlock() { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override public int getRenderType() { return -1; } - + @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); - ItemStack itemStack = new ItemStack(Mekanism.EnergyCube); - - IEnergyCube energyCube = (IEnergyCube)itemStack.getItem(); - energyCube.setEnergyCubeTier(itemStack, tileEntity.tier); - - IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); - energizedItem.setEnergy(itemStack, tileEntity.electricityStored); - - ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); - inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); - - return itemStack; + TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); + ItemStack itemStack = new ItemStack(Mekanism.EnergyCube); + + IEnergyCube energyCube = (IEnergyCube)itemStack.getItem(); + energyCube.setEnergyCubeTier(itemStack, tileEntity.tier); + + IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); + energizedItem.setEnergy(itemStack, tileEntity.electricityStored); + + ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); + inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + + return itemStack; } - + @Override public void onBlockAdded(World world, int x, int y, int z) { @@ -283,39 +283,39 @@ public class BlockEnergyCube extends BlockContainer } } - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) + public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { ItemStack itemStack = getPickBlock(null, world, x, y, z); - - world.setBlockToAir(x, y, z); - - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - - return itemStack; + + world.setBlockToAir(x, y, z); + + if(!returnBlock) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; } - - @Override - public boolean hasComparatorInputOverride() - { - return true; - } @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int par5) - { - TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); - return tileEntity.getRedstoneLevel(); - } + public boolean hasComparatorInputOverride() + { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int par5) + { + TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); + return tileEntity.getRedstoneLevel(); + } @Override public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) diff --git a/common/mekanism/common/block/BlockGasTank.java b/common/mekanism/common/block/BlockGasTank.java index b251d78a3..9ae9ff1ef 100644 --- a/common/mekanism/common/block/BlockGasTank.java +++ b/common/mekanism/common/block/BlockGasTank.java @@ -28,7 +28,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockGasTank extends BlockContainer { public Random machineRand = new Random(); - + public BlockGasTank(int id) { super(id, Material.iron); @@ -37,154 +37,154 @@ public class BlockGasTank extends BlockContainer setResistance(8F); setCreativeTab(Mekanism.tabMekanism); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} - + @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - - int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int change = 3; - - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - } - + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) + { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + + int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int change = 3; + + switch(side) + { + case 0: change = 2; break; + case 1: change = 5; break; + case 2: change = 3; break; + case 3: change = 4; break; + } + + tileEntity.setFacing((short)change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + } + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { if(!world.isRemote) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock)tileEntity).onNeighborChange(id); } } } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) - { + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) + { if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) { return false; } - - if(world.isRemote) - { - return true; - } - - TileEntityGasTank tileEntity = (TileEntityGasTank)world.getBlockTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); - - if(entityplayer.getCurrentEquippedItem() != null) - { - Item tool = entityplayer.getCurrentEquippedItem().getItem(); - - if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) - { - if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) - { - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - return true; - } - - ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); - - int change = 0; - - switch(tileEntity.facing) - { - case 3: - change = 5; - break; - case 5: - change = 2; - break; - case 2: - change = 4; - break; - case 4: - change = 3; - break; - } - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, blockID); - return true; - } - } - } - - if(tileEntity != null) - { - if(!entityplayer.isSneaking()) - { - entityplayer.openGui(Mekanism.instance, 10, world, x, y, z); - return true; - } - } - return false; - } - - @Override - public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); - - world.spawnEntityInWorld(entityItem); - } - - return world.setBlockToAir(x, y, z); - } - - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = getPickBlock(null, world, x, y, z); - world.setBlockToAir(x, y, z); - - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - - return itemStack; + if(world.isRemote) + { + return true; + } + + TileEntityGasTank tileEntity = (TileEntityGasTank)world.getBlockTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + + if(entityplayer.getCurrentEquippedItem() != null) + { + Item tool = entityplayer.getCurrentEquippedItem().getItem(); + + if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) + { + if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) + { + if(entityplayer.isSneaking()) + { + dismantleBlock(world, x, y, z, false); + return true; + } + + ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); + + int change = 0; + + switch(tileEntity.facing) + { + case 3: + change = 5; + break; + case 5: + change = 2; + break; + case 2: + change = 4; + break; + case 4: + change = 3; + break; + } + + tileEntity.setFacing((short)change); + world.notifyBlocksOfNeighborChange(x, y, z, blockID); + return true; + } + } + } + + if(tileEntity != null) + { + if(!entityplayer.isSneaking()) + { + entityplayer.openGui(Mekanism.instance, 10, world, x, y, z); + return true; + } + } + return false; } - + @Override - public int quantityDropped(Random random) + public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); + + world.spawnEntityInWorld(entityItem); + } + + return world.setBlockToAir(x, y, z); + } + + public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) + { + ItemStack itemStack = getPickBlock(null, world, x, y, z); + + world.setBlockToAir(x, y, z); + + if(!returnBlock) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; + } + + @Override + public int quantityDropped(Random random) { return 0; } @@ -194,43 +194,43 @@ public class BlockGasTank extends BlockContainer { return 0; } - + @Override public boolean renderAsNormalBlock() { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override public int getRenderType() { return -1; } - + @Override public TileEntity createNewTileEntity(World world) { return new TileEntityGasTank(); } - + @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { TileEntityGasTank tileEntity = (TileEntityGasTank)world.getBlockTileEntity(x, y, z); - ItemStack itemStack = new ItemStack(Mekanism.GasTank); - - IGasItem storageTank = (IGasItem)itemStack.getItem(); - storageTank.setGas(itemStack, tileEntity.gasTank.getGas()); - - ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); - inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); - + ItemStack itemStack = new ItemStack(Mekanism.GasTank); + + IGasItem storageTank = (IGasItem)itemStack.getItem(); + storageTank.setGas(itemStack, tileEntity.gasTank.getGas()); + + ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); + inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + return itemStack; } } diff --git a/common/mekanism/common/block/BlockMachine.java b/common/mekanism/common/block/BlockMachine.java index 28e994c8a..a59ee8553 100644 --- a/common/mekanism/common/block/BlockMachine.java +++ b/common/mekanism/common/block/BlockMachine.java @@ -117,7 +117,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds { public Icon[][] icons = new Icon[16][16]; public Random machineRand = new Random(); - + public BlockMachine(int id) { super(id, Material.iron); @@ -125,7 +125,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds setResistance(8F); setCreativeTab(Mekanism.tabMekanism); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) @@ -174,71 +174,71 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds icons[5][2] = register.registerIcon("mekanism:SteelCasing"); } } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - int side = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); - int change = 3; - - if(tileEntity == null) - { - return; - } - - if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) - { - if(height >= 65) - { - change = 1; - } - else if(height <= -65) - { - change = 0; - } - } - - if(change != 0 && change != 1) - { - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - } - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter transporter = (TileEntityLogisticalSorter)tileEntity; - - if(!transporter.hasInventory()) - { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = Coord4D.get(transporter).getFromSide(dir).getTileEntity(world); - if(tile instanceof IInventory) - { - change = dir.getOpposite().ordinal(); - break; - } - } - } - } - - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onPlace(); - } - } - + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) + { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + int side = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int height = Math.round(entityliving.rotationPitch); + int change = 3; + + if(tileEntity == null) + { + return; + } + + if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) + { + if(height >= 65) + { + change = 1; + } + else if(height <= -65) + { + change = 0; + } + } + + if(change != 0 && change != 1) + { + switch(side) + { + case 0: change = 2; break; + case 1: change = 5; break; + case 2: change = 3; break; + case 3: change = 4; break; + } + } + + if(tileEntity instanceof TileEntityLogisticalSorter) + { + TileEntityLogisticalSorter transporter = (TileEntityLogisticalSorter)tileEntity; + + if(!transporter.hasInventory()) + { + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { + TileEntity tile = Coord4D.get(transporter).getFromSide(dir).getTileEntity(world); + + if(tile instanceof IInventory) + { + change = dir.getOpposite().ordinal(); + break; + } + } + } + } + + tileEntity.setFacing((short)change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + + if(tileEntity instanceof IBoundingBlock) + { + ((IBoundingBlock)tileEntity).onPlace(); + } + } + @Override public void breakBlock(World world, int x, int y, int z, int i1, int i2) { @@ -251,56 +251,56 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds super.breakBlock(world, x, y, z, i1, i2); } - - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random random) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - - if(MekanismUtils.isActive(world, x, y, z) && ((IActiveState)tileEntity).renderUpdate() && Mekanism.machineEffects) - { - float xRandom = (float)x + 0.5F; - float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F; - float zRandom = (float)z + 0.5F; - float iRandom = 0.52F; - float jRandom = random.nextFloat() * 0.6F - 0.3F; - - int side = tileEntity.facing; - - if(tileEntity instanceof TileEntityMetallurgicInfuser) - { - side = ForgeDirection.getOrientation(side).getOpposite().ordinal(); - } - if(side == 4) - { - world.spawnParticle("smoke", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 5) - { - world.spawnParticle("smoke", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 2) - { - world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 3) - { - world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); - } - } - } - + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random random) + { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + + if(MekanismUtils.isActive(world, x, y, z) && ((IActiveState)tileEntity).renderUpdate() && Mekanism.machineEffects) + { + float xRandom = (float)x + 0.5F; + float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F; + float zRandom = (float)z + 0.5F; + float iRandom = 0.52F; + float jRandom = random.nextFloat() * 0.6F - 0.3F; + + int side = tileEntity.facing; + + if(tileEntity instanceof TileEntityMetallurgicInfuser) + { + side = ForgeDirection.getOrientation(side).getOpposite().ordinal(); + } + + if(side == 4) + { + world.spawnParticle("smoke", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle("reddust", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); + } + else if(side == 5) + { + world.spawnParticle("smoke", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle("reddust", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); + } + else if(side == 2) + { + world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); + } + else if(side == 3) + { + world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); + } + } + } + @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(Mekanism.machineEffects && tileEntity instanceof IActiveState) { if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate()) @@ -308,122 +308,122 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds return 15; } } - + return 0; } - + @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int side, int meta) - { + public Icon getIcon(int side, int meta) + { if(blockID == Mekanism.machineBlockID) { - if(meta == 0) - { - if(side == 3) - { - return icons[0][0]; - } - else { - return icons[0][2]; - } - } - else if(meta == 1) - { - if(side == 3) - { - return icons[1][0]; - } - else { - return icons[1][2]; - } - } - else if(meta == 2) - { - if(side == 3) - { - return icons[2][0]; - } - else { - return icons[2][2]; - } - } - else if(meta == 3) - { - if(side == 3) - { - return icons[3][0]; - } - else { - return icons[3][2]; - } - } - else if(meta == 5) - { - if(side == 3) - { - return icons[5][0]; - } - else if(side == 0 || side == 1) - { - return icons[5][2]; - } - else { - return icons[5][1]; - } - } - else if(meta == 6) - { - if(side == 3) - { - return icons[6][0]; - } - else if(side == 0 || side == 1) - { - return icons[6][2]; - } - else { - return icons[6][1]; - } - } - else if(meta == 7) - { - if(side == 3) - { - return icons[7][0]; - } - else if(side == 0 || side == 1) - { - return icons[7][2]; - } - else { - return icons[7][1]; - } - } - else if(meta == 9) - { - if(side == 3) - { - return icons[9][0]; - } - else { - return icons[9][2]; - } - } - else if(meta == 10) - { - if(side == 3) - { - return icons[10][0]; - } - else { - return icons[10][2]; - } - } - else if(meta == 11) - { - return icons[11][0]; - } + if(meta == 0) + { + if(side == 3) + { + return icons[0][0]; + } + else { + return icons[0][2]; + } + } + else if(meta == 1) + { + if(side == 3) + { + return icons[1][0]; + } + else { + return icons[1][2]; + } + } + else if(meta == 2) + { + if(side == 3) + { + return icons[2][0]; + } + else { + return icons[2][2]; + } + } + else if(meta == 3) + { + if(side == 3) + { + return icons[3][0]; + } + else { + return icons[3][2]; + } + } + else if(meta == 5) + { + if(side == 3) + { + return icons[5][0]; + } + else if(side == 0 || side == 1) + { + return icons[5][2]; + } + else { + return icons[5][1]; + } + } + else if(meta == 6) + { + if(side == 3) + { + return icons[6][0]; + } + else if(side == 0 || side == 1) + { + return icons[6][2]; + } + else { + return icons[6][1]; + } + } + else if(meta == 7) + { + if(side == 3) + { + return icons[7][0]; + } + else if(side == 0 || side == 1) + { + return icons[7][2]; + } + else { + return icons[7][1]; + } + } + else if(meta == 9) + { + if(side == 3) + { + return icons[9][0]; + } + else { + return icons[9][2]; + } + } + else if(meta == 10) + { + if(side == 3) + { + return icons[10][0]; + } + else { + return icons[10][2]; + } + } + else if(meta == 11) + { + return icons[11][0]; + } } else if(blockID == Mekanism.machineBlock2ID) { @@ -438,149 +438,149 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds } } } - - return null; - } - + + return null; + } + @Override - @SideOnly(Side.CLIENT) - public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) - { - int metadata = world.getBlockMetadata(x, y, z); - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - - if(blockID == Mekanism.machineBlockID) - { - if(metadata == 0) - { - if(side == tileEntity.facing) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[0][1] : icons[0][0]; - } - else { - return icons[0][2]; - } - } - else if(metadata == 1) - { - if(side == tileEntity.facing) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[1][1] : icons[1][0]; - } - else { - return icons[1][2]; - } - } - else if(metadata == 2) - { - if(side == tileEntity.facing) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[2][1] : icons[2][0]; - } - else { - return icons[2][2]; - } - } - else if(metadata == 3) - { - if(side == tileEntity.facing) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[3][1] : icons[3][0]; - } - else { - return icons[3][2]; - } - } - else if(metadata == 5) - { - if(side == tileEntity.facing) - { - return icons[5][0]; - } - else if(side == 0 || side == 1) - { - return icons[5][2]; - } - else { - return icons[5][1]; - } - } - else if(metadata == 6) - { - if(side == tileEntity.facing) - { - return icons[6][0]; - } - else if(side == 0 || side == 1) - { - return icons[6][2]; - } - else { - return icons[6][1]; - } - } - else if(metadata == 7) - { - if(side == tileEntity.facing) - { - return icons[7][0]; - } - else if(side == 0 || side == 1) - { - return icons[7][2]; - } - else { - return icons[7][1]; - } - } - else if(metadata == 9) - { - if(side == tileEntity.facing) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[9][1] : icons[9][0]; - } - else { - return icons[9][2]; - } - } - else if(metadata == 10) - { - if(side == tileEntity.facing) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[10][1] : icons[10][0]; - } - else { - return icons[10][2]; - } - } - else if(metadata == 11) - { - return icons[11][0]; - } - } - else if(blockID == Mekanism.machineBlock2ID) - { - if(metadata == 3 || metadata == 5) - { - if(side == tileEntity.facing) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[metadata][1] : icons[metadata][0]; - } - else { - return icons[metadata][2]; - } - } - } - - return null; - } - + @SideOnly(Side.CLIENT) + public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) + { + int metadata = world.getBlockMetadata(x, y, z); + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + + if(blockID == Mekanism.machineBlockID) + { + if(metadata == 0) + { + if(side == tileEntity.facing) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[0][1] : icons[0][0]; + } + else { + return icons[0][2]; + } + } + else if(metadata == 1) + { + if(side == tileEntity.facing) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[1][1] : icons[1][0]; + } + else { + return icons[1][2]; + } + } + else if(metadata == 2) + { + if(side == tileEntity.facing) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[2][1] : icons[2][0]; + } + else { + return icons[2][2]; + } + } + else if(metadata == 3) + { + if(side == tileEntity.facing) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[3][1] : icons[3][0]; + } + else { + return icons[3][2]; + } + } + else if(metadata == 5) + { + if(side == tileEntity.facing) + { + return icons[5][0]; + } + else if(side == 0 || side == 1) + { + return icons[5][2]; + } + else { + return icons[5][1]; + } + } + else if(metadata == 6) + { + if(side == tileEntity.facing) + { + return icons[6][0]; + } + else if(side == 0 || side == 1) + { + return icons[6][2]; + } + else { + return icons[6][1]; + } + } + else if(metadata == 7) + { + if(side == tileEntity.facing) + { + return icons[7][0]; + } + else if(side == 0 || side == 1) + { + return icons[7][2]; + } + else { + return icons[7][1]; + } + } + else if(metadata == 9) + { + if(side == tileEntity.facing) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[9][1] : icons[9][0]; + } + else { + return icons[9][2]; + } + } + else if(metadata == 10) + { + if(side == tileEntity.facing) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[10][1] : icons[10][0]; + } + else { + return icons[10][2]; + } + } + else if(metadata == 11) + { + return icons[11][0]; + } + } + else if(blockID == Mekanism.machineBlock2ID) + { + if(metadata == 3 || metadata == 5) + { + if(side == tileEntity.facing) + { + return MekanismUtils.isActive(world, x, y, z) ? icons[metadata][1] : icons[metadata][0]; + } + else { + return icons[metadata][2]; + } + } + } + + return null; + } + @Override - public int damageDropped(int i) - { - return i; - } - + public int damageDropped(int i) + { + return i; + } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(int i, CreativeTabs creativetabs, List list) @@ -604,160 +604,160 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds } } } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float posX, float posY, float posZ) - { + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float posX, float posY, float posZ) + { if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) { return false; } - - if(world.isRemote) - { - return true; - } - - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); - - if(entityplayer.getCurrentEquippedItem() != null) - { - Item tool = entityplayer.getCurrentEquippedItem().getItem(); - - if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) - { - if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) - { - if(entityplayer.isSneaking() && metadata != 13) - { - dismantleBlock(world, x, y, z, false); - return true; - } - - ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); - - int change = 0; - - switch(tileEntity.facing) - { - case 3: - change = 5; - break; - case 5: - change = 2; - break; - case 2: - change = 4; - break; - case 4: - change = 3; - break; - } - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - if(!((TileEntityLogisticalSorter)tileEntity).hasInventory()) - { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + + if(world.isRemote) + { + return true; + } + + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + + if(entityplayer.getCurrentEquippedItem() != null) + { + Item tool = entityplayer.getCurrentEquippedItem().getItem(); + + if(tool instanceof IToolWrench && !tool.getUnlocalizedName().contains("omniwrench")) + { + if(((IToolWrench)tool).canWrench(entityplayer, x, y, z)) + { + if(entityplayer.isSneaking() && metadata != 13) + { + dismantleBlock(world, x, y, z, false); + return true; + } + + ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); + + int change = 0; + + switch(tileEntity.facing) + { + case 3: + change = 5; + break; + case 5: + change = 2; + break; + case 2: + change = 4; + break; + case 4: + change = 3; + break; + } + + if(tileEntity instanceof TileEntityLogisticalSorter) + { + if(!((TileEntityLogisticalSorter)tileEntity).hasInventory()) + { + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = Coord4D.get(tileEntity).getFromSide(dir).getTileEntity(world); - + if(tileEntity instanceof IInventory) { change = dir.getOpposite().ordinal(); break; } } - } - } - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, blockID); - return true; - } - } - } - - if(tileEntity != null) - { - if(metadata == MachineType.ELECTRIC_CHEST.meta) - { - TileEntityElectricChest electricChest = (TileEntityElectricChest)tileEntity; - - if(!entityplayer.isSneaking()) - { - if(electricChest.canAccess()) - { - MekanismUtils.openElectricChestGui((EntityPlayerMP)entityplayer, electricChest, null, true); - } - else if(!electricChest.authenticated) - { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 2, 0, true, Coord4D.get(electricChest)), entityplayer); - } - else { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 1, 0, true, Coord4D.get(electricChest)), entityplayer); - } - - return true; - } - } - else if(metadata == MachineType.LOGISTICAL_SORTER.meta) - { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; - PacketLogisticalSorterGui.openServerGui(SorterGuiPacket.SERVER, 0, world, (EntityPlayerMP)entityplayer, Coord4D.get(tileEntity), -1); - return true; - } - else { - if(!entityplayer.isSneaking() && MachineType.get(blockID, metadata).guiId != -1) - { - entityplayer.openGui(Mekanism.instance, MachineType.get(blockID, metadata).guiId, world, x, y, z); - return true; - } - } - } - return false; - } - - @Override - public TileEntity createTileEntity(World world, int metadata) - { - if(MachineType.get(blockID, metadata) == null) - { - return null; - } - - return MachineType.get(blockID, metadata).create(); - } - - @Override + } + } + + tileEntity.setFacing((short)change); + world.notifyBlocksOfNeighborChange(x, y, z, blockID); + return true; + } + } + } + + if(tileEntity != null) + { + if(metadata == MachineType.ELECTRIC_CHEST.meta) + { + TileEntityElectricChest electricChest = (TileEntityElectricChest)tileEntity; + + if(!entityplayer.isSneaking()) + { + if(electricChest.canAccess()) + { + MekanismUtils.openElectricChestGui((EntityPlayerMP)entityplayer, electricChest, null, true); + } + else if(!electricChest.authenticated) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 2, 0, true, Coord4D.get(electricChest)), entityplayer); + } + else { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 1, 0, true, Coord4D.get(electricChest)), entityplayer); + } + + return true; + } + } + else if(metadata == MachineType.LOGISTICAL_SORTER.meta) + { + TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; + PacketLogisticalSorterGui.openServerGui(SorterGuiPacket.SERVER, 0, world, (EntityPlayerMP)entityplayer, Coord4D.get(tileEntity), -1); + return true; + } + else { + if(!entityplayer.isSneaking() && MachineType.get(blockID, metadata).guiId != -1) + { + entityplayer.openGui(Mekanism.instance, MachineType.get(blockID, metadata).guiId, world, x, y, z); + return true; + } + } + } + return false; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) + { + if(MachineType.get(blockID, metadata) == null) + { + return null; + } + + return MachineType.get(blockID, metadata).create(); + } + + @Override public TileEntity createNewTileEntity(World world) { return null; } - + @Override public boolean renderAsNormalBlock() { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override @SideOnly(Side.CLIENT) public int getRenderType() { return ClientProxy.MACHINE_RENDER_ID; } - + @Override - public float getBlockHardness(World world, int x, int y, int z) - { + public float getBlockHardness(World world, int x, int y, int z) + { if(world.getBlockMetadata(x, y, z) != 13) { return blockHardness; @@ -766,305 +766,305 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds TileEntityElectricChest tileEntity = (TileEntityElectricChest)world.getBlockTileEntity(x, y, z); return tileEntity.canAccess() ? 3.5F : -1; } - } - - @Override - public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); - - world.spawnEntityInWorld(entityItem); - } - - return world.setBlockToAir(x, y, z); - } - - @Override - public int idDropped(int i, Random random, int j) - { - return 0; - } - + } + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) + public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) + { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); + + world.spawnEntityInWorld(entityItem); + } + + return world.setBlockToAir(x, y, z); + } + + @Override + public int idDropped(int i, Random random, int j) + { + return 0; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { if(!world.isRemote) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock)tileEntity).onNeighborChange(id); } - + if(tileEntity instanceof TileEntityLogisticalSorter) { TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; - - if(!sorter.hasInventory()) - { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + + if(!sorter.hasInventory()) + { + for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = Coord4D.get(tileEntity).getFromSide(dir).getTileEntity(world); - + if(tile instanceof IInventory) { sorter.setFacing((short)dir.getOpposite().ordinal()); return; } } - } - } + } + } } } - + @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - ItemStack itemStack = new ItemStack(blockID, 1, world.getBlockMetadata(x, y, z)); - - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - if(((IUpgradeManagement)itemStack.getItem()).supportsUpgrades(itemStack)) - { - IUpgradeManagement upgrade = (IUpgradeManagement)itemStack.getItem(); - - upgrade.setEnergyMultiplier(((IUpgradeManagement)tileEntity).getEnergyMultiplier(), itemStack); - upgrade.setSpeedMultiplier(((IUpgradeManagement)tileEntity).getSpeedMultiplier(), itemStack); - } - - if(tileEntity instanceof IInvConfiguration) - { - IInvConfiguration config = (IInvConfiguration)tileEntity; - - itemStack.stackTagCompound.setBoolean("hasSideData", true); - - itemStack.stackTagCompound.setBoolean("ejecting", config.getEjector().isEjecting()); - - for(int i = 0; i < 6; i++) - { - itemStack.stackTagCompound.setByte("config"+i, config.getConfiguration()[i]); - } - } - - if(tileEntity instanceof TileEntityDigitalMiner) - { - TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity; - - itemStack.stackTagCompound.setBoolean("hasMinerConfig", true); - - itemStack.stackTagCompound.setInteger("radius", miner.radius); - itemStack.stackTagCompound.setInteger("minY", miner.minY); - itemStack.stackTagCompound.setInteger("maxY", miner.maxY); - itemStack.stackTagCompound.setBoolean("doEject", miner.doEject); - itemStack.stackTagCompound.setBoolean("doPull", miner.doPull); - itemStack.stackTagCompound.setBoolean("silkTouch", miner.silkTouch); - - if(miner.replaceStack != null) - { - itemStack.stackTagCompound.setCompoundTag("replaceStack", miner.replaceStack.writeToNBT(new NBTTagCompound())); - } - - NBTTagList filterTags = new NBTTagList(); - - for(MinerFilter filter : miner.filters) - { - filterTags.appendTag(filter.write(new NBTTagCompound())); - } - - if(filterTags.tagCount() != 0) - { - itemStack.stackTagCompound.setTag("filters", filterTags); - } - } - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; - - itemStack.stackTagCompound.setBoolean("hasSorterConfig", true); - - if(sorter.color != null) - { - itemStack.stackTagCompound.setInteger("color", TransporterUtils.colors.indexOf(sorter.color)); - } - - itemStack.stackTagCompound.setBoolean("autoEject", sorter.autoEject); - itemStack.stackTagCompound.setBoolean("roundRobin", sorter.roundRobin); - - NBTTagList filterTags = new NBTTagList(); - - for(TransporterFilter filter : sorter.filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } - - if(filterTags.tagCount() != 0) - { - itemStack.stackTagCompound.setTag("filters", filterTags); - } - } - - if(tileEntity instanceof IRedstoneControl) - { - IRedstoneControl control = (IRedstoneControl)tileEntity; - itemStack.stackTagCompound.setInteger("controlType", control.getControlType().ordinal()); - } - - if(tileEntity instanceof TileEntityElectricBlock) - { - IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); - energizedItem.setEnergy(itemStack, ((TileEntityElectricBlock)tileEntity).electricityStored); - } - - if(tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock)tileEntity).inventory.length > 0) - { - ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); - inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); - } - - if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) - { - if(tileEntity instanceof ISustainedTank) - { - if(((ISustainedTank)tileEntity).getFluidStack() != null) - { - ((ISustainedTank)itemStack.getItem()).setFluidStack(((ISustainedTank)tileEntity).getFluidStack(), itemStack); - } - } - } - - if(tileEntity instanceof TileEntityElectricChest) - { - IElectricChest electricChest = (IElectricChest)itemStack.getItem(); - electricChest.setAuthenticated(itemStack, ((TileEntityElectricChest)tileEntity).authenticated); - electricChest.setLocked(itemStack, ((TileEntityElectricChest)tileEntity).locked); - electricChest.setPassword(itemStack, ((TileEntityElectricChest)tileEntity).password); - } - - if(tileEntity instanceof TileEntityFactory) - { - IFactory factoryItem = (IFactory)itemStack.getItem(); - factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack); - } - - if(tileEntity instanceof TileEntityRotaryCondensentrator) - { - TileEntityRotaryCondensentrator condensentrator = (TileEntityRotaryCondensentrator)tileEntity; - - if(condensentrator.gasTank.getGas() != null) - { - itemStack.stackTagCompound.setCompoundTag("gasStack", condensentrator.gasTank.getGas().write(new NBTTagCompound())); - } - } - - if(tileEntity instanceof TileEntityChemicalOxidizer) - { - TileEntityChemicalOxidizer formulator = (TileEntityChemicalOxidizer)tileEntity; - - if(formulator.gasTank.getGas() != null) - { - itemStack.stackTagCompound.setCompoundTag("gasTank", formulator.gasTank.getGas().write(new NBTTagCompound())); - } - } - - if(tileEntity instanceof TileEntityChemicalInfuser) - { - TileEntityChemicalInfuser infuser = (TileEntityChemicalInfuser)tileEntity; - - if(infuser.leftTank.getGas() != null) - { - itemStack.stackTagCompound.setCompoundTag("leftTank", infuser.leftTank.getGas().write(new NBTTagCompound())); - } - - if(infuser.rightTank.getGas() != null) - { - itemStack.stackTagCompound.setCompoundTag("rightTank", infuser.rightTank.getGas().write(new NBTTagCompound())); - } - - if(infuser.centerTank.getGas() != null) - { - itemStack.stackTagCompound.setCompoundTag("leftTank", infuser.centerTank.getGas().write(new NBTTagCompound())); - } - } - - return itemStack; + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + ItemStack itemStack = new ItemStack(blockID, 1, world.getBlockMetadata(x, y, z)); + + if(itemStack.stackTagCompound == null) + { + itemStack.setTagCompound(new NBTTagCompound()); + } + + if(((IUpgradeManagement)itemStack.getItem()).supportsUpgrades(itemStack)) + { + IUpgradeManagement upgrade = (IUpgradeManagement)itemStack.getItem(); + + upgrade.setEnergyMultiplier(((IUpgradeManagement)tileEntity).getEnergyMultiplier(), itemStack); + upgrade.setSpeedMultiplier(((IUpgradeManagement)tileEntity).getSpeedMultiplier(), itemStack); + } + + if(tileEntity instanceof IInvConfiguration) + { + IInvConfiguration config = (IInvConfiguration)tileEntity; + + itemStack.stackTagCompound.setBoolean("hasSideData", true); + + itemStack.stackTagCompound.setBoolean("ejecting", config.getEjector().isEjecting()); + + for(int i = 0; i < 6; i++) + { + itemStack.stackTagCompound.setByte("config"+i, config.getConfiguration()[i]); + } + } + + if(tileEntity instanceof TileEntityDigitalMiner) + { + TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity; + + itemStack.stackTagCompound.setBoolean("hasMinerConfig", true); + + itemStack.stackTagCompound.setInteger("radius", miner.radius); + itemStack.stackTagCompound.setInteger("minY", miner.minY); + itemStack.stackTagCompound.setInteger("maxY", miner.maxY); + itemStack.stackTagCompound.setBoolean("doEject", miner.doEject); + itemStack.stackTagCompound.setBoolean("doPull", miner.doPull); + itemStack.stackTagCompound.setBoolean("silkTouch", miner.silkTouch); + + if(miner.replaceStack != null) + { + itemStack.stackTagCompound.setCompoundTag("replaceStack", miner.replaceStack.writeToNBT(new NBTTagCompound())); + } + + NBTTagList filterTags = new NBTTagList(); + + for(MinerFilter filter : miner.filters) + { + filterTags.appendTag(filter.write(new NBTTagCompound())); + } + + if(filterTags.tagCount() != 0) + { + itemStack.stackTagCompound.setTag("filters", filterTags); + } + } + + if(tileEntity instanceof TileEntityLogisticalSorter) + { + TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; + + itemStack.stackTagCompound.setBoolean("hasSorterConfig", true); + + if(sorter.color != null) + { + itemStack.stackTagCompound.setInteger("color", TransporterUtils.colors.indexOf(sorter.color)); + } + + itemStack.stackTagCompound.setBoolean("autoEject", sorter.autoEject); + itemStack.stackTagCompound.setBoolean("roundRobin", sorter.roundRobin); + + NBTTagList filterTags = new NBTTagList(); + + for(TransporterFilter filter : sorter.filters) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } + + if(filterTags.tagCount() != 0) + { + itemStack.stackTagCompound.setTag("filters", filterTags); + } + } + + if(tileEntity instanceof IRedstoneControl) + { + IRedstoneControl control = (IRedstoneControl)tileEntity; + itemStack.stackTagCompound.setInteger("controlType", control.getControlType().ordinal()); + } + + if(tileEntity instanceof TileEntityElectricBlock) + { + IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); + energizedItem.setEnergy(itemStack, ((TileEntityElectricBlock)tileEntity).electricityStored); + } + + if(tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock)tileEntity).inventory.length > 0) + { + ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); + inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + } + + if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) + { + if(tileEntity instanceof ISustainedTank) + { + if(((ISustainedTank)tileEntity).getFluidStack() != null) + { + ((ISustainedTank)itemStack.getItem()).setFluidStack(((ISustainedTank)tileEntity).getFluidStack(), itemStack); + } + } + } + + if(tileEntity instanceof TileEntityElectricChest) + { + IElectricChest electricChest = (IElectricChest)itemStack.getItem(); + electricChest.setAuthenticated(itemStack, ((TileEntityElectricChest)tileEntity).authenticated); + electricChest.setLocked(itemStack, ((TileEntityElectricChest)tileEntity).locked); + electricChest.setPassword(itemStack, ((TileEntityElectricChest)tileEntity).password); + } + + if(tileEntity instanceof TileEntityFactory) + { + IFactory factoryItem = (IFactory)itemStack.getItem(); + factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack); + } + + if(tileEntity instanceof TileEntityRotaryCondensentrator) + { + TileEntityRotaryCondensentrator condensentrator = (TileEntityRotaryCondensentrator)tileEntity; + + if(condensentrator.gasTank.getGas() != null) + { + itemStack.stackTagCompound.setCompoundTag("gasStack", condensentrator.gasTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityChemicalOxidizer) + { + TileEntityChemicalOxidizer formulator = (TileEntityChemicalOxidizer)tileEntity; + + if(formulator.gasTank.getGas() != null) + { + itemStack.stackTagCompound.setCompoundTag("gasTank", formulator.gasTank.getGas().write(new NBTTagCompound())); + } + } + + if(tileEntity instanceof TileEntityChemicalInfuser) + { + TileEntityChemicalInfuser infuser = (TileEntityChemicalInfuser)tileEntity; + + if(infuser.leftTank.getGas() != null) + { + itemStack.stackTagCompound.setCompoundTag("leftTank", infuser.leftTank.getGas().write(new NBTTagCompound())); + } + + if(infuser.rightTank.getGas() != null) + { + itemStack.stackTagCompound.setCompoundTag("rightTank", infuser.rightTank.getGas().write(new NBTTagCompound())); + } + + if(infuser.centerTank.getGas() != null) + { + itemStack.stackTagCompound.setCompoundTag("leftTank", infuser.centerTank.getGas().write(new NBTTagCompound())); + } + } + + return itemStack; } - - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) + + public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { ItemStack itemStack = getPickBlock(null, world, x, y, z); - - world.setBlockToAir(x, y, z); - - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - - return itemStack; + + world.setBlockToAir(x, y, z); + + if(!returnBlock) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) - { - int metadata = world.getBlockMetadata(x, y, z); - - if(metadata == MachineType.CHARGEPAD.meta) - { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F); - } - else { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) - { - if(world.getBlockTileEntity(x, y, z) instanceof TileEntityChargepad) - { - return null; - } - - return super.getCollisionBoundingBoxFromPool(world, x, y, z); - } - - @Override - public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) - { - int metadata = world.getBlockMetadata(x, y, z); - - if(metadata != MachineType.CHARGEPAD.meta) - { - return true; - } - - return false; - } - + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + + if(metadata == MachineType.CHARGEPAD.meta) + { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F); + } + else { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) + { + if(world.getBlockTileEntity(x, y, z) instanceof TileEntityChargepad) + { + return null; + } + + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } + + @Override + public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) + { + int metadata = world.getBlockMetadata(x, y, z); + + if(metadata != MachineType.CHARGEPAD.meta) + { + return true; + } + + return false; + } + @Override public void onBlockAdded(World world, int x, int y, int z) { @@ -1075,7 +1075,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds ((TileEntityElectricBlock)tileEntity).register(); } } - + public static enum MachineType { ENRICHMENT_CHAMBER(Mekanism.machineBlockID, 0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, false, true), @@ -1112,7 +1112,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds public Class tileEntityClass; public boolean hasModel; public boolean supportsUpgrades; - + private MachineType(int id, int i, String s, int j, double k, Class tileClass, boolean model, boolean upgrades) { typeId = id; @@ -1124,7 +1124,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds hasModel = model; supportsUpgrades = upgrades; } - + public static MachineType get(int id, int meta) { for(MachineType type : values()) @@ -1134,10 +1134,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds return type; } } - + return null; } - + public TileEntity create() { try { @@ -1148,22 +1148,22 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds return null; } } - + public String getDescription() { return MekanismUtils.localize("tooltip." + name); } - + public ItemStack getStack() { return new ItemStack(typeId, 1, meta); } - + public static MachineType get(ItemStack stack) { return get(stack.itemID, stack.getItemDamage()); } - + @Override public String toString() { @@ -1175,7 +1175,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds public void setRenderBounds(Block block, int metadata) {} @Override - public boolean doDefaultBoundSetting(int metadata) + public boolean doDefaultBoundSetting(int metadata) { return false; } diff --git a/common/mekanism/common/block/BlockObsidianTNT.java b/common/mekanism/common/block/BlockObsidianTNT.java index a3593248d..7e45378c9 100644 --- a/common/mekanism/common/block/BlockObsidianTNT.java +++ b/common/mekanism/common/block/BlockObsidianTNT.java @@ -20,122 +20,122 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockObsidianTNT extends Block { public Icon[] icons = new Icon[256]; - - public BlockObsidianTNT(int id) - { - super(id, Material.tnt); - setCreativeTab(Mekanism.tabMekanism); - } - + + public BlockObsidianTNT(int id) + { + super(id, Material.tnt); + setCreativeTab(Mekanism.tabMekanism); + } + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - super.onBlockAdded(world, x, y, z); + @Override + public void onBlockAdded(World world, int x, int y, int z) + { + super.onBlockAdded(world, x, y, z); - if(world.isBlockIndirectlyGettingPowered(x, y, z)) - { - explode(world, x, y, z); - world.setBlockToAir(x, y, z); - } - } + if(world.isBlockIndirectlyGettingPowered(x, y, z)) + { + explode(world, x, y, z); + world.setBlockToAir(x, y, z); + } + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) - { - if(world.isBlockIndirectlyGettingPowered(x, y, z)) - { - explode(world, x, y, z); - world.setBlockToAir(x, y, z); - } - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) + { + if(world.isBlockIndirectlyGettingPowered(x, y, z)) + { + explode(world, x, y, z); + world.setBlockToAir(x, y, z); + } + } - @Override - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) - { - if(!world.isRemote) - { - EntityObsidianTNT entity = new EntityObsidianTNT(world, x + 0.5F, y + 0.5F, z + 0.5F); - entity.fuse = world.rand.nextInt(entity.fuse / 4) + entity.fuse / 8; - world.spawnEntityInWorld(entity); - } - } + @Override + public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) + { + if(!world.isRemote) + { + EntityObsidianTNT entity = new EntityObsidianTNT(world, x + 0.5F, y + 0.5F, z + 0.5F); + entity.fuse = world.rand.nextInt(entity.fuse / 4) + entity.fuse / 8; + world.spawnEntityInWorld(entity); + } + } - public void explode(World world, int x, int y, int z) - { - if(!world.isRemote) - { - EntityObsidianTNT entity = new EntityObsidianTNT(world, x + 0.5F, y + 0.5F, z + 0.5F); - world.spawnEntityInWorld(entity); - world.playSoundAtEntity(entity, "random.fuse", 1.0F, 1.0F); - } - } + public void explode(World world, int x, int y, int z) + { + if(!world.isRemote) + { + EntityObsidianTNT entity = new EntityObsidianTNT(world, x + 0.5F, y + 0.5F, z + 0.5F); + world.spawnEntityInWorld(entity); + world.playSoundAtEntity(entity, "random.fuse", 1.0F, 1.0F); + } + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) - { - if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.itemID) - { - explode(world, x, y, z); - world.setBlockToAir(x, y, z); - return true; - } - else { - return super.onBlockActivated(world, x, y, z, entityplayer, i1, f1, f2, f3); - } - } - - @Override - public boolean canDropFromExplosion(Explosion explosion) - { - return false; - } - - @Override + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) + { + if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.itemID) + { + explode(world, x, y, z); + world.setBlockToAir(x, y, z); + return true; + } + else { + return super.onBlockActivated(world, x, y, z, entityplayer, i1, f1, f2, f3); + } + } + + @Override + public boolean canDropFromExplosion(Explosion explosion) + { + return false; + } + + @Override public boolean hasTileEntity(int metadata) { return true; } - + @Override public TileEntity createTileEntity(World world, int metadata) { return new TileEntityObsidianTNT(); } - + @Override public boolean renderAsNormalBlock() { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override public int getRenderType() { return -1; } - - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) - { - if(entity instanceof EntityArrow && !world.isRemote) - { - EntityArrow entityarrow = (EntityArrow)entity; - if(entityarrow.isBurning()) - { - explode(world, x, y, z); - world.setBlockToAir(x, y, z); - } - } - } + @Override + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) + { + if(entity instanceof EntityArrow && !world.isRemote) + { + EntityArrow entityarrow = (EntityArrow)entity; + + if(entityarrow.isBurning()) + { + explode(world, x, y, z); + world.setBlockToAir(x, y, z); + } + } + } } diff --git a/common/mekanism/common/block/BlockOre.java b/common/mekanism/common/block/BlockOre.java index fc5646399..7191f7d84 100644 --- a/common/mekanism/common/block/BlockOre.java +++ b/common/mekanism/common/block/BlockOre.java @@ -13,7 +13,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; /** - * Block class for handling multiple ore block IDs. + * Block class for handling multiple ore block IDs. * 0: Osmium Ore * 1: Copper Ore * 2: Tin Ore @@ -23,7 +23,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockOre extends Block { public Icon[] icons = new Icon[256]; - + public BlockOre(int id) { super(id, Material.rock); @@ -31,7 +31,7 @@ public class BlockOre extends Block setResistance(5F); setCreativeTab(Mekanism.tabMekanism); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) @@ -40,20 +40,20 @@ public class BlockOre extends Block icons[1] = register.registerIcon("mekanism:CopperOre"); icons[2] = register.registerIcon("mekanism:TinOre"); } - + @Override @SideOnly(Side.CLIENT) public Icon getIcon(int side, int meta) { return icons[meta]; } - + @Override public int damageDropped(int i) { return i; } - + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(int i, CreativeTabs creativetabs, List list) diff --git a/common/mekanism/common/classloading/ClassEnumerator.java b/common/mekanism/common/classloading/ClassEnumerator.java index 6cc2143be..1c425109a 100644 --- a/common/mekanism/common/classloading/ClassEnumerator.java +++ b/common/mekanism/common/classloading/ClassEnumerator.java @@ -22,24 +22,24 @@ public class ClassEnumerator private static void processDir(File directory, String pkgname, ArrayList> classes) { String[] files = directory.list(); - + for(int i = 0; i < files.length; i++) { String fileName = files[i]; String className = null; - + if(fileName.endsWith(".class")) { className = pkgname + '.' + fileName.substring(0, fileName.length() - 6); } - + if(className != null) { classes.add(loadClass(className)); } - + File subdir = new File(directory, fileName); - + if(subdir.isDirectory()) { processDir(subdir, pkgname + '.' + fileName, classes); @@ -52,28 +52,28 @@ public class ClassEnumerator String relPath = pkgname.replace('.', '/'); String resPath = resource.getPath(); String jarPath = resPath.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", ""); - + JarFile jarFile; - + try { jarFile = new JarFile(jarPath); } catch(IOException e) { throw new RuntimeException("Unexpected IOException reading JAR File '" + jarPath + "'", e); } - + Enumeration entries = jarFile.entries(); - + while(entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); String entryName = entry.getName(); String className = null; - + if(entryName.endsWith(".class") && entryName.startsWith(relPath) && entryName.length() > (relPath.length() + "/".length())) { className = entryName.replace('/', '.').replace('\\', '.').replace(".class", ""); } - + if(className != null) { classes.add(loadClass(className)); @@ -88,16 +88,16 @@ public class ClassEnumerator try { String pkgname = pkg.getName(); String relPath = pkgname.replace('.', '/'); - + URL resource = ClassLoader.getSystemClassLoader().getResource(relPath); - + if(resource == null) { throw new RuntimeException("Unexpected problem: No resource for " + relPath); } - + resource.getPath(); - + if(resource.toString().startsWith("jar:")) { processJar(resource, pkgname, classes); diff --git a/common/mekanism/common/entity/EntityBalloon.java b/common/mekanism/common/entity/EntityBalloon.java index be6dca705..413d92199 100644 --- a/common/mekanism/common/entity/EntityBalloon.java +++ b/common/mekanism/common/entity/EntityBalloon.java @@ -27,235 +27,235 @@ import cpw.mods.fml.relauncher.SideOnly; public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData { public EnumColor color = EnumColor.DARK_BLUE; - + public Coord4D latched; public EntityLivingBase latchedEntity; - + /* server-only */ public boolean hasCachedEntity; - + public UUID cachedEntityUUID; - + public EntityBalloon(World world) { super(world); - + ignoreFrustumCheck = true; - preventEntitySpawning = true; + preventEntitySpawning = true; setPosition(posX + 0.5F, posY + 3F, posZ + 0.5F); yOffset = height / 2.0F; - setSize(0.25F, 0.25F); - motionY = 0.04; - - dataWatcher.addObject(2, new Byte((byte)0)); /* Is latched */ + setSize(0.25F, 0.25F); + motionY = 0.04; + + dataWatcher.addObject(2, new Byte((byte)0)); /* Is latched */ dataWatcher.addObject(3, new Integer(0)); /* Latched X */ dataWatcher.addObject(4, new Integer(0)); /* Latched Y */ dataWatcher.addObject(5, new Integer(0)); /* Latched Z */ dataWatcher.addObject(6, new Integer(-1)); /* Latched entity ID */ } - - public EntityBalloon(World world, double x, double y, double z, EnumColor c) - { - this(world); - - setPosition(x + 0.5F, y + 3F, z + 0.5F); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - color = c; - } - - public EntityBalloon(EntityLivingBase entity, EnumColor c) - { - this(entity.worldObj); - - latchedEntity = entity; - setPosition(latchedEntity.posX, latchedEntity.posY + latchedEntity.height + 1.7F, latchedEntity.posZ); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - color = c; - - dataWatcher.updateObject(2, new Byte((byte)2)); /* Is latched */ + + public EntityBalloon(World world, double x, double y, double z, EnumColor c) + { + this(world); + + setPosition(x + 0.5F, y + 3F, z + 0.5F); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + color = c; + } + + public EntityBalloon(EntityLivingBase entity, EnumColor c) + { + this(entity.worldObj); + + latchedEntity = entity; + setPosition(latchedEntity.posX, latchedEntity.posY + latchedEntity.height + 1.7F, latchedEntity.posZ); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + color = c; + + dataWatcher.updateObject(2, new Byte((byte)2)); /* Is latched */ dataWatcher.updateObject(3, new Integer(0)); /* Latched X */ dataWatcher.updateObject(4, new Integer(0)); /* Latched Y */ dataWatcher.updateObject(5, new Integer(0)); /* Latched Z */ dataWatcher.updateObject(6, new Integer(entity.entityId)); /* Latched entity ID */ - } - - public EntityBalloon(World world, Coord4D obj, EnumColor c) - { - this(world); - - latched = obj; - setPosition(latched.xCoord + 0.5F, latched.yCoord + 2.8F, latched.zCoord + 0.5F); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - color = c; - - dataWatcher.updateObject(2, new Byte((byte)1)); /* Is latched */ + } + + public EntityBalloon(World world, Coord4D obj, EnumColor c) + { + this(world); + + latched = obj; + setPosition(latched.xCoord + 0.5F, latched.yCoord + 2.8F, latched.zCoord + 0.5F); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + color = c; + + dataWatcher.updateObject(2, new Byte((byte)1)); /* Is latched */ dataWatcher.updateObject(3, new Integer(latched != null ? latched.xCoord : 0)); /* Latched X */ dataWatcher.updateObject(4, new Integer(latched != null ? latched.yCoord : 0)); /* Latched Y */ dataWatcher.updateObject(5, new Integer(latched != null ? latched.zCoord : 0)); /* Latched Z */ dataWatcher.updateObject(6, new Integer(-1)); /* Latched entity ID */ - } - - @Override - public void onUpdate() - { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - if(posY > 255) - { - pop(); - return; - } - - if(worldObj.isRemote) - { - if(dataWatcher.getWatchableObjectByte(2) == 1) - { - latched = new Coord4D(dataWatcher.getWatchableObjectInt(3), dataWatcher.getWatchableObjectInt(4), dataWatcher.getWatchableObjectInt(5), worldObj.provider.dimensionId); - } - else { - latched = null; - } - - if(dataWatcher.getWatchableObjectByte(2) == 2) - { - latchedEntity = (EntityLivingBase)worldObj.getEntityByID(dataWatcher.getWatchableObjectInt(6)); - } - else { - latchedEntity = null; - } - } - else { - if(hasCachedEntity) - { - findCachedEntity(); - cachedEntityUUID = null; - hasCachedEntity = false; - } - - if(ticksExisted == 1) - { - dataWatcher.updateObject(2, new Byte(latched != null ? (byte)1 : (latchedEntity != null ? (byte)2 : (byte)0))); /* Is latched */ - dataWatcher.updateObject(3, new Integer(latched != null ? latched.xCoord : 0)); /* Latched X */ - dataWatcher.updateObject(4, new Integer(latched != null ? latched.yCoord : 0)); /* Latched Y */ - dataWatcher.updateObject(5, new Integer(latched != null ? latched.zCoord : 0)); /* Latched Z */ - dataWatcher.updateObject(6, new Integer(latchedEntity != null ? latchedEntity.entityId : -1)); /* Latched entity ID */ - } - } - - if(!worldObj.isRemote) - { - if(latched != null && (latched.exists(worldObj) && latched.isAirBlock(worldObj))) - { - latched = null; - - dataWatcher.updateObject(2, (byte)0); /* Is latched */ - } - - if(latchedEntity != null && (latchedEntity.getHealth() <= 0 || latchedEntity.isDead || !worldObj.loadedEntityList.contains(latchedEntity))) - { - latchedEntity = null; - - dataWatcher.updateObject(2, (byte)0); /* Is latched */ - } - } - - if(!isLatched()) - { - motionY = Math.min(motionY*1.02F, 0.2F); - - moveEntity(motionX, motionY, motionZ); - - motionX *= 0.98; - motionZ *= 0.98; - - if(onGround) - { - motionX *= 0.7; - motionZ *= 0.7; - } - - if(motionY == 0) - { - motionY = 0.04; - } - } - else if(latched != null) - { - motionX = 0; - motionY = 0; - motionZ = 0; - } - else if(latchedEntity != null && latchedEntity.getHealth() > 0) - { - int floor = getFloor(latchedEntity); - - if(latchedEntity.posY-(floor+1) < -0.1) - { - latchedEntity.motionY = Math.max(0.04, latchedEntity.motionY*1.015); - } - else if(latchedEntity.posY-(floor+1) > 0.1) - { - latchedEntity.motionY = Math.min(-0.04, latchedEntity.motionY*1.015); - } - else { - latchedEntity.motionY = 0; - } - - setPosition(latchedEntity.posX, latchedEntity.posY + latchedEntity.height + 1.7F, latchedEntity.posZ); - } - } - - private int getFloor(EntityLivingBase entity) - { - int xPos = MathHelper.floor_double(entity.posX); - int yPos = MathHelper.floor_double(entity.posY); - int zPos = MathHelper.floor_double(entity.posZ); - - for(int i = yPos; i > 0; i--) - { - if(i < 256 && !worldObj.isAirBlock(xPos, i, zPos)) - { - return i+1; - } - } - - return -1; - } - - private void findCachedEntity() - { - for(Object obj : worldObj.loadedEntityList) - { - if(obj instanceof EntityLivingBase) - { - EntityLivingBase entity = (EntityLivingBase)obj; - - if(entity.getUniqueID().equals(cachedEntityUUID)) - { - latchedEntity = entity; - } - } - } - } - - private void pop() - { + } + + @Override + public void onUpdate() + { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if(posY > 255) + { + pop(); + return; + } + + if(worldObj.isRemote) + { + if(dataWatcher.getWatchableObjectByte(2) == 1) + { + latched = new Coord4D(dataWatcher.getWatchableObjectInt(3), dataWatcher.getWatchableObjectInt(4), dataWatcher.getWatchableObjectInt(5), worldObj.provider.dimensionId); + } + else { + latched = null; + } + + if(dataWatcher.getWatchableObjectByte(2) == 2) + { + latchedEntity = (EntityLivingBase)worldObj.getEntityByID(dataWatcher.getWatchableObjectInt(6)); + } + else { + latchedEntity = null; + } + } + else { + if(hasCachedEntity) + { + findCachedEntity(); + cachedEntityUUID = null; + hasCachedEntity = false; + } + + if(ticksExisted == 1) + { + dataWatcher.updateObject(2, new Byte(latched != null ? (byte)1 : (latchedEntity != null ? (byte)2 : (byte)0))); /* Is latched */ + dataWatcher.updateObject(3, new Integer(latched != null ? latched.xCoord : 0)); /* Latched X */ + dataWatcher.updateObject(4, new Integer(latched != null ? latched.yCoord : 0)); /* Latched Y */ + dataWatcher.updateObject(5, new Integer(latched != null ? latched.zCoord : 0)); /* Latched Z */ + dataWatcher.updateObject(6, new Integer(latchedEntity != null ? latchedEntity.entityId : -1)); /* Latched entity ID */ + } + } + + if(!worldObj.isRemote) + { + if(latched != null && (latched.exists(worldObj) && latched.isAirBlock(worldObj))) + { + latched = null; + + dataWatcher.updateObject(2, (byte)0); /* Is latched */ + } + + if(latchedEntity != null && (latchedEntity.getHealth() <= 0 || latchedEntity.isDead || !worldObj.loadedEntityList.contains(latchedEntity))) + { + latchedEntity = null; + + dataWatcher.updateObject(2, (byte)0); /* Is latched */ + } + } + + if(!isLatched()) + { + motionY = Math.min(motionY*1.02F, 0.2F); + + moveEntity(motionX, motionY, motionZ); + + motionX *= 0.98; + motionZ *= 0.98; + + if(onGround) + { + motionX *= 0.7; + motionZ *= 0.7; + } + + if(motionY == 0) + { + motionY = 0.04; + } + } + else if(latched != null) + { + motionX = 0; + motionY = 0; + motionZ = 0; + } + else if(latchedEntity != null && latchedEntity.getHealth() > 0) + { + int floor = getFloor(latchedEntity); + + if(latchedEntity.posY-(floor+1) < -0.1) + { + latchedEntity.motionY = Math.max(0.04, latchedEntity.motionY*1.015); + } + else if(latchedEntity.posY-(floor+1) > 0.1) + { + latchedEntity.motionY = Math.min(-0.04, latchedEntity.motionY*1.015); + } + else { + latchedEntity.motionY = 0; + } + + setPosition(latchedEntity.posX, latchedEntity.posY + latchedEntity.height + 1.7F, latchedEntity.posZ); + } + } + + private int getFloor(EntityLivingBase entity) + { + int xPos = MathHelper.floor_double(entity.posX); + int yPos = MathHelper.floor_double(entity.posY); + int zPos = MathHelper.floor_double(entity.posZ); + + for(int i = yPos; i > 0; i--) + { + if(i < 256 && !worldObj.isAirBlock(xPos, i, zPos)) + { + return i+1; + } + } + + return -1; + } + + private void findCachedEntity() + { + for(Object obj : worldObj.loadedEntityList) + { + if(obj instanceof EntityLivingBase) + { + EntityLivingBase entity = (EntityLivingBase)obj; + + if(entity.getUniqueID().equals(cachedEntityUUID)) + { + latchedEntity = entity; + } + } + } + } + + private void pop() + { worldObj.playSoundAtEntity(this, "mekanism:etc.Pop", 1, 1); - + if(worldObj.isRemote) { for(int i = 0; i < 10; i++) @@ -265,38 +265,38 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData } catch(Throwable t) {} } } - + setDead(); - } - - @SideOnly(Side.CLIENT) - private void doParticle() - { + } + + @SideOnly(Side.CLIENT) + private void doParticle() + { Pos3D pos = new Pos3D(posX + (rand.nextFloat()*.6 - 0.3), posY - 0.8 + (rand.nextFloat()*.6 - 0.3), posZ + (rand.nextFloat()*.6 - 0.3)); - + EntityFX fx = new EntityReddustFX(worldObj, pos.xPos, pos.yPos, pos.zPos, 1, 0, 0, 0); fx.setRBGColorF(color.getColor(0), color.getColor(1), color.getColor(2)); - + Minecraft.getMinecraft().effectRenderer.addEffect(fx); - } - - @Override - public boolean canBePushed() - { - return latched == null; - } - - @Override - public boolean canBeCollidedWith() - { - return !isDead; - } - - @Override - protected boolean canTriggerWalking() - { - return false; - } + } + + @Override + public boolean canBePushed() + { + return latched == null; + } + + @Override + public boolean canBeCollidedWith() + { + return !isDead; + } + + @Override + protected boolean canTriggerWalking() + { + return false; + } @Override protected void entityInit() {} @@ -305,12 +305,12 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData protected void readEntityFromNBT(NBTTagCompound nbtTags) { color = EnumColor.values()[nbtTags.getInteger("color")]; - + if(nbtTags.hasKey("latched")) { latched = Coord4D.read(nbtTags.getCompoundTag("latched")); } - + if(nbtTags.hasKey("idMost")) { hasCachedEntity = true; @@ -322,19 +322,19 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData protected void writeEntityToNBT(NBTTagCompound nbtTags) { nbtTags.setInteger("color", color.ordinal()); - + if(latched != null) { nbtTags.setCompoundTag("latched", latched.write(new NBTTagCompound())); } - + if(latchedEntity != null) { nbtTags.setLong("idMost", latchedEntity.getUniqueID().getMostSignificantBits()); nbtTags.setLong("idLeast", latchedEntity.getUniqueID().getLeastSignificantBits()); } } - + @Override public boolean hitByEntity(Entity entity) { @@ -348,13 +348,13 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData data.writeDouble(posX); data.writeDouble(posY); data.writeDouble(posZ); - + data.writeInt(color.ordinal()); - + if(latched != null) { data.writeByte((byte)1); - + data.writeInt(latched.xCoord); data.writeInt(latched.yCoord); data.writeInt(latched.zCoord); @@ -374,11 +374,11 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData public void readSpawnData(ByteArrayDataInput data) { setPosition(data.readDouble(), data.readDouble(), data.readDouble()); - + color = EnumColor.values()[data.readInt()]; - + byte type = data.readByte(); - + if(type == 1) { latched = Coord4D.read(data); @@ -391,50 +391,50 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData latched = null; } } - + @Override public void setDead() { super.setDead(); - + if(latchedEntity != null) { latchedEntity.isAirBorne = false; } } - + @Override public boolean isInRangeToRenderDist(double dist) { return dist <= 64; } - + @Override - public boolean isInRangeToRenderVec3D(Vec3 par1Vec3) - { + public boolean isInRangeToRenderVec3D(Vec3 par1Vec3) + { return true; - } - - @Override - public boolean attackEntityFrom(DamageSource dmgSource, float damage) - { - if(isEntityInvulnerable()) - { - return false; - } - else { - setBeenAttacked(); - - if(dmgSource != DamageSource.magic && dmgSource != DamageSource.drown && dmgSource != DamageSource.fall) - { - pop(); - return true; - } - - return false; - } - } - + } + + @Override + public boolean attackEntityFrom(DamageSource dmgSource, float damage) + { + if(isEntityInvulnerable()) + { + return false; + } + else { + setBeenAttacked(); + + if(dmgSource != DamageSource.magic && dmgSource != DamageSource.drown && dmgSource != DamageSource.fall) + { + pop(); + return true; + } + + return false; + } + } + public boolean isLatched() { if(!worldObj.isRemote) @@ -445,7 +445,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData return dataWatcher.getWatchableObjectByte(2) > 0; } } - + public boolean isLatchedToEntity() { return dataWatcher.getWatchableObjectByte(2) == 2 && latchedEntity != null; diff --git a/common/mekanism/common/entity/EntityObsidianTNT.java b/common/mekanism/common/entity/EntityObsidianTNT.java index 14b4a2cd8..84c71aff4 100644 --- a/common/mekanism/common/entity/EntityObsidianTNT.java +++ b/common/mekanism/common/entity/EntityObsidianTNT.java @@ -7,126 +7,126 @@ import net.minecraft.world.World; public class EntityObsidianTNT extends Entity { - /** How long the fuse is */ - public int fuse; - - /** Whether or not the TNT has exploded */ - private boolean hasExploded = false; + /** How long the fuse is */ + public int fuse; - public EntityObsidianTNT(World world) - { - super(world); - fuse = 0; - preventEntitySpawning = true; - setSize(0.98F, 0.98F); - yOffset = height / 2.0F; - } + /** Whether or not the TNT has exploded */ + private boolean hasExploded = false; - public EntityObsidianTNT(World world, double x, double y, double z) - { - this(world); - - setPosition(x, y, z); - - float randPi = (float)(Math.random()*Math.PI*2); - - motionX = -(Math.sin(randPi))*0.02F; - motionY = 0.2; - motionZ = -(Math.cos(randPi))*0.02F; - - fuse = Mekanism.obsidianTNTDelay; - - prevPosX = x; - prevPosY = y; - prevPosZ = z; - } + public EntityObsidianTNT(World world) + { + super(world); + fuse = 0; + preventEntitySpawning = true; + setSize(0.98F, 0.98F); + yOffset = height / 2.0F; + } - @Override - protected void entityInit() {} + public EntityObsidianTNT(World world, double x, double y, double z) + { + this(world); - @Override - protected boolean canTriggerWalking() - { - return false; - } + setPosition(x, y, z); - @Override - public boolean canBeCollidedWith() - { - return !isDead; - } - - @Override - public boolean canBePushed() - { - return true; - } - - @Override - public void onUpdate() - { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - motionY -= 0.04; - - moveEntity(motionX, motionY, motionZ); - - motionX *= 0.98; - motionY *= 0.98; - motionZ *= 0.98; + float randPi = (float)(Math.random()*Math.PI*2); - if(onGround) - { - motionX *= 0.7; - motionZ *= 0.7; - motionY *= -0.5; - } + motionX = -(Math.sin(randPi))*0.02F; + motionY = 0.2; + motionZ = -(Math.cos(randPi))*0.02F; - if(fuse-- <= 0) - { - if(!worldObj.isRemote) - { - setDead(); - explode(); - } - else { - if(hasExploded) - { - setDead(); - } - else { - worldObj.spawnParticle("lava", posX, posY + 0.5, posZ, 0, 0, 0); - } - } - } - else { - worldObj.spawnParticle("lava", posX, posY + 0.5, posZ, 0, 0, 0); - } - } + fuse = Mekanism.obsidianTNTDelay; - private void explode() - { - worldObj.createExplosion(null, posX, posY, posZ, Mekanism.obsidianTNTBlastRadius, true); - hasExploded = true; - } + prevPosX = x; + prevPosY = y; + prevPosZ = z; + } - @Override - protected void writeEntityToNBT(NBTTagCompound nbtTags) - { - nbtTags.setByte("Fuse", (byte)fuse); - } + @Override + protected void entityInit() {} - @Override - protected void readEntityFromNBT(NBTTagCompound nbtTags) - { - fuse = nbtTags.getByte("Fuse"); - } + @Override + protected boolean canTriggerWalking() + { + return false; + } - @Override - public float getShadowSize() - { - return 0; - } + @Override + public boolean canBeCollidedWith() + { + return !isDead; + } + + @Override + public boolean canBePushed() + { + return true; + } + + @Override + public void onUpdate() + { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + motionY -= 0.04; + + moveEntity(motionX, motionY, motionZ); + + motionX *= 0.98; + motionY *= 0.98; + motionZ *= 0.98; + + if(onGround) + { + motionX *= 0.7; + motionZ *= 0.7; + motionY *= -0.5; + } + + if(fuse-- <= 0) + { + if(!worldObj.isRemote) + { + setDead(); + explode(); + } + else { + if(hasExploded) + { + setDead(); + } + else { + worldObj.spawnParticle("lava", posX, posY + 0.5, posZ, 0, 0, 0); + } + } + } + else { + worldObj.spawnParticle("lava", posX, posY + 0.5, posZ, 0, 0, 0); + } + } + + private void explode() + { + worldObj.createExplosion(null, posX, posY, posZ, Mekanism.obsidianTNTBlastRadius, true); + hasExploded = true; + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbtTags) + { + nbtTags.setByte("Fuse", (byte)fuse); + } + + @Override + protected void readEntityFromNBT(NBTTagCompound nbtTags) + { + fuse = nbtTags.getByte("Fuse"); + } + + @Override + public float getShadowSize() + { + return 0; + } } diff --git a/common/mekanism/common/entity/EntityRobit.java b/common/mekanism/common/entity/EntityRobit.java index 620718706..270ffdbda 100644 --- a/common/mekanism/common/entity/EntityRobit.java +++ b/common/mekanism/common/entity/EntityRobit.java @@ -42,86 +42,86 @@ import cofh.api.energy.IEnergyContainerItem; public class EntityRobit extends EntityCreature implements IInventory, ISustainedInventory, IEntityBreathable { public double MAX_ELECTRICITY = 100000; - + public Coord4D homeLocation; - + public ItemStack[] inventory = new ItemStack[31]; - - public int furnaceBurnTime = 0; - public int currentItemBurnTime = 0; - public int furnaceCookTime = 0; - - public boolean texTick; - - public EntityRobit(World world) + + public int furnaceBurnTime = 0; + public int currentItemBurnTime = 0; + public int furnaceCookTime = 0; + + public boolean texTick; + + public EntityRobit(World world) { super(world); - + setSize(0.5F, 0.5F); - + getNavigator().setAvoidsWater(true); - + tasks.addTask(1, new RobitAIPickup(this, 1.0F)); tasks.addTask(2, new RobitAIFollow(this, 1.0F, 4.0F, 2.0F)); tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); tasks.addTask(3, new EntityAILookIdle(this)); tasks.addTask(4, new EntityAISwimming(this)); - + setAlwaysRenderNameTag(true); } - + public EntityRobit(World world, double x, double y, double z) { this(world); - + setPosition(x, y, z); - - prevPosX = x; + + prevPosX = x; prevPosY = y; prevPosZ = z; } - + @Override - protected void applyEntityAttributes() - { - super.applyEntityAttributes(); - - getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.3); - getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(1); - } - + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.3); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(1); + } + @Override public boolean isAIEnabled() { return true; } - + @Override protected boolean canDespawn() { return false; } - + @Override protected void updateAITick() {} - + @Override protected void entityInit() { super.entityInit(); - + dataWatcher.addObject(12, new String("")); /* Electricity */ dataWatcher.addObject(13, new String("")); /* Owner */ dataWatcher.addObject(14, new Byte((byte)0)); /* Follow */ dataWatcher.addObject(15, new String("")); /* Name */ dataWatcher.addObject(16, new Byte((byte)0)); /* Drop Pickup */ } - + public double getRoundedTravelEnergy() { return new BigDecimal(getDistance(prevPosX, prevPosY, prevPosZ)*1.5).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); } - + @Override public void onEntityUpdate() { @@ -132,36 +132,36 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine setEnergy(getEnergy() - getRoundedTravelEnergy()); } } - + super.onEntityUpdate(); - + if(!worldObj.isRemote) { if(getDropPickup()) { collectItems(); } - + if(homeLocation == null) { setDead(); - + return; } - + if(!(homeLocation.getTileEntity(MinecraftServer.getServer().worldServerForDimension(homeLocation.dimensionId)) instanceof TileEntityChargepad)) { drop(); setDead(); - + return; } - + if(getEnergy() == 0 && !isOnChargepad()) { goHome(); } - + if(inventory[27] != null && getEnergy() < MAX_ELECTRICITY) { if(inventory[27].getItem() instanceof IEnergizedItem) @@ -171,7 +171,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine else if(Mekanism.hooks.IC2Loaded && inventory[27].getItem() instanceof IElectricItem) { IElectricItem item = (IElectricItem)inventory[27].getItem(); - + if(item.canProvideEnergy(inventory[27])) { double gain = ElectricItem.manager.discharge(inventory[27], (int)((MAX_ELECTRICITY - getEnergy())*Mekanism.TO_IC2), 4, true, false)*Mekanism.FROM_IC2; @@ -182,70 +182,70 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine { ItemStack itemStack = inventory[27]; IEnergyContainerItem item = (IEnergyContainerItem)inventory[27].getItem(); - + int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getEnergyStored(itemStack))); int toTransfer = (int)Math.round(Math.min(itemEnergy, ((MAX_ELECTRICITY - getEnergy())*Mekanism.TO_TE))); - + setEnergy(getEnergy() + (item.extractEnergy(itemStack, toTransfer, false)*Mekanism.FROM_TE)); } else if(inventory[27].itemID == Item.redstone.itemID && getEnergy()+Mekanism.ENERGY_PER_REDSTONE <= MAX_ELECTRICITY) { setEnergy(getEnergy() + Mekanism.ENERGY_PER_REDSTONE); inventory[27].stackSize--; - - if(inventory[27].stackSize <= 0) - { - inventory[27] = null; - } + + if(inventory[27].stackSize <= 0) + { + inventory[27] = null; + } } } - if(furnaceBurnTime > 0) - { - furnaceBurnTime--; - } + if(furnaceBurnTime > 0) + { + furnaceBurnTime--; + } - if(!worldObj.isRemote) - { - if(furnaceBurnTime == 0 && canSmelt()) - { - currentItemBurnTime = furnaceBurnTime = TileEntityFurnace.getItemBurnTime(inventory[29]); + if(!worldObj.isRemote) + { + if(furnaceBurnTime == 0 && canSmelt()) + { + currentItemBurnTime = furnaceBurnTime = TileEntityFurnace.getItemBurnTime(inventory[29]); - if(furnaceBurnTime > 0) - { - if(inventory[29] != null) - { - inventory[29].stackSize--; + if(furnaceBurnTime > 0) + { + if(inventory[29] != null) + { + inventory[29].stackSize--; - if(inventory[29].stackSize == 0) - { - inventory[29] = inventory[29].getItem().getContainerItemStack(inventory[29]); - } - } - } - } + if(inventory[29].stackSize == 0) + { + inventory[29] = inventory[29].getItem().getContainerItemStack(inventory[29]); + } + } + } + } - if(furnaceBurnTime > 0 && canSmelt()) - { - furnaceCookTime++; + if(furnaceBurnTime > 0 && canSmelt()) + { + furnaceCookTime++; - if(furnaceCookTime == 200) - { - furnaceCookTime = 0; - smeltItem(); - } - } - else { - furnaceCookTime = 0; - } - } + if(furnaceCookTime == 200) + { + furnaceCookTime = 0; + smeltItem(); + } + } + else { + furnaceCookTime = 0; + } + } } } - + private void collectItems() { List items = worldObj.getEntitiesWithinAABB(EntityItem.class, boundingBox.expand(1.5, 1.5, 1.5)); - + if(items != null && !items.isEmpty()) { for(EntityItem item : items) @@ -254,131 +254,131 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine { continue; } - + for(int i = 0; i < 27; i++) { ItemStack itemStack = inventory[i]; - + if(itemStack == null) { inventory[i] = item.getEntityItem(); onItemPickup(item, item.getEntityItem().stackSize); item.setDead(); - + playSound("random.pop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - + break; } else if(itemStack.isItemEqual(item.getEntityItem()) && itemStack.stackSize < itemStack.getMaxStackSize()) { int needed = itemStack.getMaxStackSize() - itemStack.stackSize; int toAdd = Math.min(needed, item.getEntityItem().stackSize); - + itemStack.stackSize += toAdd; item.getEntityItem().stackSize -= toAdd; - + onItemPickup(item, toAdd); - + if(item.getEntityItem().stackSize == 0) { item.setDead(); } - + playSound("random.pop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - + break; } } } } } - + public void goHome() { setFollowing(false); - + if(worldObj.provider.dimensionId != homeLocation.dimensionId) { travelToDimension(homeLocation.dimensionId); } - + setPositionAndUpdate(homeLocation.xCoord+0.5, homeLocation.yCoord+0.3, homeLocation.zCoord+0.5); - + motionX = 0; motionY = 0; motionZ = 0; } - private boolean canSmelt() - { - if(inventory[28] == null) - { - return false; - } - else { - ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); - if(itemstack == null) return false; - if(inventory[30] == null) return true; - if(!inventory[30].isItemEqual(itemstack)) return false; - int result = inventory[30].stackSize + itemstack.stackSize; - return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); - } - } + private boolean canSmelt() + { + if(inventory[28] == null) + { + return false; + } + else { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); + if(itemstack == null) return false; + if(inventory[30] == null) return true; + if(!inventory[30].isItemEqual(itemstack)) return false; + int result = inventory[30].stackSize + itemstack.stackSize; + return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); + } + } - public void smeltItem() - { - if(canSmelt()) - { - ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); + public void smeltItem() + { + if(canSmelt()) + { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); - if(inventory[30] == null) - { - inventory[30] = itemstack.copy(); - } - else if(inventory[30].isItemEqual(itemstack)) - { - inventory[30].stackSize += itemstack.stackSize; - } + if(inventory[30] == null) + { + inventory[30] = itemstack.copy(); + } + else if(inventory[30].isItemEqual(itemstack)) + { + inventory[30].stackSize += itemstack.stackSize; + } - inventory[28].stackSize--; + inventory[28].stackSize--; + + if(inventory[28].stackSize <= 0) + { + inventory[28] = null; + } + } + } - if(inventory[28].stackSize <= 0) - { - inventory[28] = null; - } - } - } - public boolean isOnChargepad() { int x = MathHelper.floor_double(posX); int y = MathHelper.floor_double(posY); int z = MathHelper.floor_double(posZ); - + if(worldObj.getBlockTileEntity(x, y, z) instanceof TileEntityChargepad) { return true; } - + return false; } - + @Override public boolean interact(EntityPlayer entityplayer) { if(entityplayer.isSneaking()) { ItemStack itemStack = entityplayer.getCurrentEquippedItem(); - + if(itemStack != null && itemStack.getItem() instanceof ItemConfigurator) { if(!worldObj.isRemote) { drop(); } - + setDead(); - + entityplayer.swingItem(); return true; } @@ -386,180 +386,180 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine else { entityplayer.openGui(Mekanism.instance, 21, worldObj, entityId, 0, 0); } - + return false; } - + public void drop() { EntityItem entityItem = new EntityItem(worldObj, posX, posY+0.3, posZ, new ItemStack(Mekanism.Robit)); - + ItemRobit item = (ItemRobit)entityItem.getEntityItem().getItem(); item.setEnergy(entityItem.getEntityItem(), getEnergy()); item.setInventory(getInventory(), entityItem.getEntityItem()); item.setName(entityItem.getEntityItem(), getTranslatedEntityName()); - - float k = 0.05F; - entityItem.motionX = 0; - entityItem.motionY = rand.nextGaussian() * k + 0.2F; - entityItem.motionZ = 0; - - worldObj.spawnEntityInWorld(entityItem); + + float k = 0.05F; + entityItem.motionX = 0; + entityItem.motionY = rand.nextGaussian() * k + 0.2F; + entityItem.motionZ = 0; + + worldObj.spawnEntityInWorld(entityItem); } @Override - public void writeEntityToNBT(NBTTagCompound nbtTags) - { - super.writeEntityToNBT(nbtTags); - - nbtTags.setDouble("electricityStored", getEnergy()); - - nbtTags.setString("name", getName()); - - if(getOwnerName() != null) - { - nbtTags.setString("owner", getOwnerName()); - } - - nbtTags.setBoolean("follow", getFollowing()); - - nbtTags.setBoolean("dropPickup", getDropPickup()); - - homeLocation.write(nbtTags); - - NBTTagList tagList = new NBTTagList(); + public void writeEntityToNBT(NBTTagCompound nbtTags) + { + super.writeEntityToNBT(nbtTags); - for(int slotCount = 0; slotCount < inventory.length; slotCount++) - { - if(inventory[slotCount] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - inventory[slotCount].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } + nbtTags.setDouble("electricityStored", getEnergy()); - nbtTags.setTag("Items", tagList); - } + nbtTags.setString("name", getName()); + + if(getOwnerName() != null) + { + nbtTags.setString("owner", getOwnerName()); + } + + nbtTags.setBoolean("follow", getFollowing()); + + nbtTags.setBoolean("dropPickup", getDropPickup()); + + homeLocation.write(nbtTags); + + NBTTagList tagList = new NBTTagList(); + + for(int slotCount = 0; slotCount < inventory.length; slotCount++) + { + if(inventory[slotCount] != null) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte)slotCount); + inventory[slotCount].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + nbtTags.setTag("Items", tagList); + } @Override - public void readEntityFromNBT(NBTTagCompound nbtTags) - { - super.readEntityFromNBT(nbtTags); - - setEnergy(nbtTags.getDouble("electricityStored")); - - setName(nbtTags.getString("name")); - - if(nbtTags.hasKey("owner")) - { - setOwner(nbtTags.getString("owner")); - } - - setFollowing(nbtTags.getBoolean("follow")); - - setDropPickup(nbtTags.getBoolean("dropPickup")); - - homeLocation = Coord4D.read(nbtTags); - - NBTTagList tagList = nbtTags.getTagList("Items"); - inventory = new ItemStack[getSizeInventory()]; + public void readEntityFromNBT(NBTTagCompound nbtTags) + { + super.readEntityFromNBT(nbtTags); - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); + setEnergy(nbtTags.getDouble("electricityStored")); + + setName(nbtTags.getString("name")); + + if(nbtTags.hasKey("owner")) + { + setOwner(nbtTags.getString("owner")); + } + + setFollowing(nbtTags.getBoolean("follow")); + + setDropPickup(nbtTags.getBoolean("dropPickup")); + + homeLocation = Coord4D.read(nbtTags); + + NBTTagList tagList = nbtTags.getTagList("Items"); + inventory = new ItemStack[getSizeInventory()]; + + for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) + { + NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); + + if(slotID >= 0 && slotID < inventory.length) + { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + } - if(slotID >= 0 && slotID < inventory.length) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - } - @Override - protected void damageEntity(DamageSource damageSource, float amount) - { - amount = ForgeHooks.onLivingHurt(this, damageSource, amount); - - if(amount <= 0) - { - return; - } - - amount = applyArmorCalculations(damageSource, amount); - amount = applyPotionDamageCalculations(damageSource, amount); - float j = getHealth(); - - setEnergy(Math.max(0, getEnergy() - (amount*1000))); - func_110142_aN().func_94547_a(damageSource, j, amount); - } - + protected void damageEntity(DamageSource damageSource, float amount) + { + amount = ForgeHooks.onLivingHurt(this, damageSource, amount); + + if(amount <= 0) + { + return; + } + + amount = applyArmorCalculations(damageSource, amount); + amount = applyPotionDamageCalculations(damageSource, amount); + float j = getHealth(); + + setEnergy(Math.max(0, getEnergy() - (amount*1000))); + func_110142_aN().func_94547_a(damageSource, j, amount); + } + @Override protected void onDeathUpdate() {} - + public void setHome(Coord4D home) { homeLocation = home; } - + @Override public boolean canBePushed() { return getEnergy() > 0; } - + public double getEnergy() { return Double.parseDouble(dataWatcher.getWatchableObjectString(12)); } - + public void setEnergy(double energy) { dataWatcher.updateObject(12, Double.toString(Math.max(Math.min(energy, MAX_ELECTRICITY), 0))); } - + public EntityPlayer getOwner() { return worldObj.getPlayerEntityByName(getOwnerName()); } - + public String getOwnerName() { return dataWatcher.getWatchableObjectString(13); } - + public void setOwner(String username) { dataWatcher.updateObject(13, username); } - + public boolean getFollowing() { return dataWatcher.getWatchableObjectByte(14) == 1; } - + public void setFollowing(boolean follow) { dataWatcher.updateObject(14, follow ? (byte)1 : (byte)0); } - + public String getName() { return dataWatcher.getWatchableObjectString(15); } - + public void setName(String name) { dataWatcher.updateObject(15, name); } - + public boolean getDropPickup() { return dataWatcher.getWatchableObjectByte(16) == 1; } - + public void setDropPickup(boolean pickup) { dataWatcher.updateObject(16, pickup ? (byte)1 : (byte)0); @@ -572,7 +572,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine } @Override - public ItemStack getStackInSlot(int slotID) + public ItemStack getStackInSlot(int slotID) { return inventory[slotID]; } @@ -581,70 +581,70 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public ItemStack decrStackSize(int slotID, int amount) { if(getStackInSlot(slotID) != null) - { - ItemStack tempStack; + { + ItemStack tempStack; - if(getStackInSlot(slotID).stackSize <= amount) - { - tempStack = getStackInSlot(slotID); - setInventorySlotContents(slotID, null); - return tempStack; - } - else { - tempStack = getStackInSlot(slotID).splitStack(amount); + if(getStackInSlot(slotID).stackSize <= amount) + { + tempStack = getStackInSlot(slotID); + setInventorySlotContents(slotID, null); + return tempStack; + } + else { + tempStack = getStackInSlot(slotID).splitStack(amount); - if(getStackInSlot(slotID).stackSize == 0) - { - setInventorySlotContents(slotID, null); - } + if(getStackInSlot(slotID).stackSize == 0) + { + setInventorySlotContents(slotID, null); + } - return tempStack; - } - } - else { - return null; - } + return tempStack; + } + } + else { + return null; + } } @Override - public ItemStack getStackInSlotOnClosing(int slotID) + public ItemStack getStackInSlotOnClosing(int slotID) { - if(getStackInSlot(slotID) != null) - { - ItemStack tempStack = getStackInSlot(slotID); - setInventorySlotContents(slotID, null); - return tempStack; - } - else { - return null; - } + if(getStackInSlot(slotID) != null) + { + ItemStack tempStack = getStackInSlot(slotID); + setInventorySlotContents(slotID, null); + return tempStack; + } + else { + return null; + } } @Override - public void setInventorySlotContents(int slotID, ItemStack itemstack) - { - inventory[slotID] = itemstack; + public void setInventorySlotContents(int slotID, ItemStack itemstack) + { + inventory[slotID] = itemstack; - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } + if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + } @Override - public String getInvName() + public String getInvName() { return "Robit"; } @Override - public boolean isInvNameLocalized() + public boolean isInvNameLocalized() { return true; } @Override - public int getInventoryStackLimit() + public int getInventoryStackLimit() { return 64; } @@ -653,7 +653,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public void onInventoryChanged() {} @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) + public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } @@ -665,66 +665,66 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public void closeChest() {} @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) + public boolean isItemValidForSlot(int i, ItemStack itemstack) { return true; } - + @Override - public void setInventory(NBTTagList nbtTags, Object... data) + public void setInventory(NBTTagList nbtTags, Object... data) { if(nbtTags == null || nbtTags.tagCount() == 0) { return; } - - inventory = new ItemStack[getSizeInventory()]; - for(int slots = 0; slots < nbtTags.tagCount(); slots++) - { - NBTTagCompound tagCompound = (NBTTagCompound)nbtTags.tagAt(slots); - byte slotID = tagCompound.getByte("Slot"); + inventory = new ItemStack[getSizeInventory()]; - if(slotID >= 0 && slotID < inventory.length) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } + for(int slots = 0; slots < nbtTags.tagCount(); slots++) + { + NBTTagCompound tagCompound = (NBTTagCompound)nbtTags.tagAt(slots); + byte slotID = tagCompound.getByte("Slot"); + + if(slotID >= 0 && slotID < inventory.length) + { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } } @Override public NBTTagList getInventory(Object... data) { - NBTTagList tagList = new NBTTagList(); + NBTTagList tagList = new NBTTagList(); - for(int slots = 0; slots < inventory.length; slots++) - { - if(inventory[slots] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slots); - inventory[slots].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } + for(int slots = 0; slots < inventory.length; slots++) + { + if(inventory[slots] != null) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte)slots); + inventory[slots].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } - return tagList; + return tagList; } - + @Override public String getTranslatedEntityName() { return getName().isEmpty() ? "Robit" : getName(); } - - @Override - public float getShadowSize() - { - return 0.25F; - } @Override - public boolean canBreath() + public float getShadowSize() + { + return 0.25F; + } + + @Override + public boolean canBreath() { return true; } diff --git a/common/mekanism/common/integration/IC2ItemManager.java b/common/mekanism/common/integration/IC2ItemManager.java index 02568a81a..be347b5c4 100644 --- a/common/mekanism/common/integration/IC2ItemManager.java +++ b/common/mekanism/common/integration/IC2ItemManager.java @@ -9,15 +9,15 @@ import net.minecraft.item.ItemStack; public class IC2ItemManager implements IElectricItemManager { public IEnergizedItem energizedItem; - + public static IC2ItemManager getManager(IEnergizedItem item) { IC2ItemManager manager = new IC2ItemManager(); manager.energizedItem = item; - + return manager; } - + @Override public int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) { @@ -25,18 +25,18 @@ public class IC2ItemManager implements IElectricItemManager { double energyNeeded = energizedItem.getMaxEnergy(itemStack)-energizedItem.getEnergy(itemStack); double energyToStore = Math.min(Math.min(amount*Mekanism.FROM_IC2, energizedItem.getMaxEnergy(itemStack)*0.01), energyNeeded); - + if(!simulate) { energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) + energyToStore); } - + return (int)Math.round(energyToStore*Mekanism.TO_IC2); } - + return 0; } - + @Override public int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) { @@ -44,15 +44,15 @@ public class IC2ItemManager implements IElectricItemManager { double energyWanted = amount*Mekanism.FROM_IC2; double energyToGive = Math.min(Math.min(energyWanted, energizedItem.getMaxEnergy(itemStack)*0.01), energizedItem.getEnergy(itemStack)); - + if(!simulate) { energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) - energyToGive); } - + return (int)Math.round(energyToGive*Mekanism.TO_IC2); } - + return 0; } @@ -63,7 +63,7 @@ public class IC2ItemManager implements IElectricItemManager } @Override - public int getCharge(ItemStack itemStack) + public int getCharge(ItemStack itemStack) { return (int)Math.round(energizedItem.getEnergy(itemStack)*Mekanism.TO_IC2); } @@ -75,9 +75,9 @@ public class IC2ItemManager implements IElectricItemManager } @Override - public void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity) + public void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity) { - + } @Override diff --git a/common/mekanism/common/integration/MekanismHooks.java b/common/mekanism/common/integration/MekanismHooks.java index fce0483b8..c4dc833df 100644 --- a/common/mekanism/common/integration/MekanismHooks.java +++ b/common/mekanism/common/integration/MekanismHooks.java @@ -25,21 +25,21 @@ import cpw.mods.fml.common.event.FMLInterModComms; * @author AidanBrady * */ -public final class MekanismHooks +public final class MekanismHooks { private Class BasicComponents; - + private Class BuildCraftEnergy; - + public boolean IC2Loaded = false; public boolean RailcraftLoaded = false; public boolean BasicComponentsLoaded = false; public boolean BuildCraftLoaded = false; public boolean TELoaded = false; - + public boolean MetallurgyCoreLoaded = false; public boolean MetallurgyBaseLoaded = false; - + public void hook() { if(Loader.isModLoaded("IC2")) IC2Loaded = true; @@ -47,14 +47,14 @@ public final class MekanismHooks if(Loader.isModLoaded("BasicComponents")) BasicComponentsLoaded = true; if(Loader.isModLoaded("BuildCraft|Energy")) BuildCraftLoaded = true; if(Loader.isModLoaded("ThermalExpansion")) TELoaded = true; - + if(Loader.isModLoaded("Metallurgy3Core")) { MetallurgyCoreLoaded = true; - + if(Loader.isModLoaded("Metallurgy3Base")) MetallurgyBaseLoaded = true; } - + if(IC2Loaded) { for(Map.Entry entry : Recipes.macerator.getRecipes().entrySet()) @@ -62,17 +62,17 @@ public final class MekanismHooks if(!entry.getKey().getInputs().isEmpty()) { List names = MekanismUtils.getOreDictName(entry.getKey().getInputs().get(0)); - + for(String name : names) { boolean did = false; - + if(name.startsWith("ingot")) { RecipeHandler.addCrusherRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0)); did = true; } - + if(did) { break; @@ -80,18 +80,18 @@ public final class MekanismHooks } } } - + try { Recipes.macerator.addRecipe(new RecipeInputOreDict("oreOsmium"), null, new ItemStack(Mekanism.Dust, 2, 2)); } catch(Exception e) {} - + try { Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotOsmium"), null, new ItemStack(Mekanism.Dust, 1, 2)); Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedObsidian"), null, new ItemStack(Mekanism.Dust, 1, 3)); Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedGlowstone"), null, new ItemStack(Item.glowstone)); Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotSteel"), null, new ItemStack(Mekanism.Dust, 1, 5)); } catch(Exception e) {} - + try { Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpIron"), null, new ItemStack(Mekanism.DirtyDust, 1, 0)); Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpGold"), null, new ItemStack(Mekanism.DirtyDust, 1, 1)); @@ -102,16 +102,16 @@ public final class MekanismHooks Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpObsidian"), null, new ItemStack(Mekanism.DirtyDust, 1, 6)); Recipes.macerator.addRecipe(new RecipeInputOreDict("clumpLead"), null, new ItemStack(Mekanism.DirtyDust, 1, 7)); } catch(Exception e) {} - + NBTTagCompound tag = new NBTTagCompound(); - + tag.setInteger("amplification", 50000); - + Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(Mekanism.EnrichedAlloy), 1), tag); - + System.out.println("[Mekanism] Hooked into IC2 successfully."); } - + if(BasicComponentsLoaded) { if(Mekanism.disableBCSteelCrafting) @@ -119,40 +119,40 @@ public final class MekanismHooks MekanismUtils.removeRecipes(getBasicComponentsItem("itemSteelDust")); MekanismUtils.removeRecipes(getBasicComponentsItem("itemSteelIngot")); } - + if(Mekanism.disableBCBronzeCrafting) { MekanismUtils.removeRecipes(getBasicComponentsItem("itemBronzeDust")); MekanismUtils.removeRecipes(getBasicComponentsItem("itemBronzeIngot")); } - + System.out.println("[Mekanism] Hooked into BasicComponents successfully."); } - + if(BuildCraftLoaded) { System.out.println("[Mekanism] Hooked into BuildCraft successfully."); } } - + public void addPulverizerRecipe(ItemStack input, ItemStack output, int energy) { NBTTagCompound nbtTags = new NBTTagCompound(); - + nbtTags.setInteger("energy", energy); nbtTags.setCompoundTag("input", input.writeToNBT(new NBTTagCompound())); nbtTags.setCompoundTag("primaryOutput", output.writeToNBT(new NBTTagCompound())); - + FMLInterModComms.sendMessage("mekanism", "PulverizerRecipe", nbtTags); } - + public ItemStack getBuildCraftItem(String name) { try { if(BuildCraftEnergy == null) BuildCraftEnergy = Class.forName("buildcraft.BuildCraftEnergy"); if(BuildCraftEnergy == null) BuildCraftEnergy = Class.forName("net.minecraft.src.buildcraft.BuildCraftEnergy"); Object ret = BuildCraftEnergy.getField(name).get(null); - + if(ret instanceof Item) { return new ItemStack((Item)ret); @@ -169,14 +169,14 @@ public final class MekanismHooks return null; } } - + public ItemStack getBasicComponentsItem(String name) { try { if(BasicComponents == null) BasicComponents = Class.forName("basiccomponents.common.BasicComponents"); if(BasicComponents == null) BasicComponents = Class.forName("net.minecraft.src.basiccomponents.common.BasicComponents"); Object ret = BasicComponents.getField(name).get(null); - + if(ret instanceof Item) { return new ItemStack((Item)ret); diff --git a/common/mekanism/common/integration/OreDictManager.java b/common/mekanism/common/integration/OreDictManager.java index 0639748fd..4f8e7061f 100644 --- a/common/mekanism/common/integration/OreDictManager.java +++ b/common/mekanism/common/integration/OreDictManager.java @@ -32,13 +32,13 @@ public final class OreDictManager public static void init() { addLogRecipes(); - + for(ItemStack ore : OreDictionary.getOres("plankWood")) { if(ore.getHasSubtypes()) { ItemStack wildStack = new ItemStack(ore.itemID, 1, OreDictionary.WILDCARD_VALUE); - + if(!Recipe.PRECISION_SAWMILL.containsRecipe(wildStack)) { RecipeHandler.addPrecisionSawmillRecipe(wildStack, new ChanceOutput(new ItemStack(Item.stick, 6), new ItemStack(Mekanism.Sawdust), 0.25)); @@ -48,12 +48,12 @@ public final class OreDictManager RecipeHandler.addPrecisionSawmillRecipe(StackUtils.size(ore, 1), new ChanceOutput(new ItemStack(Item.stick, 6), new ItemStack(Mekanism.Sawdust), 0.25)); } } - + for(ItemStack ore : OreDictionary.getOres("oreNetherSteel")) { RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 4, 5)); } - + if(OreDictionary.getOres("itemRubber").size() > 0) { for(ItemStack ore : OreDictionary.getOres("woodRubber")) @@ -61,173 +61,173 @@ public final class OreDictManager RecipeHandler.addPrecisionSawmillRecipe(MekanismUtils.size(ore, 1), new ChanceOutput(new ItemStack(Block.planks, 4), MekanismUtils.size(OreDictionary.getOres("itemRubber").get(0), 1), 1F)); } } - + for(ItemStack ore : OreDictionary.getOres("dustSulfur")) { RecipeHandler.addChemicalOxidizerRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 100)); } - + for(ItemStack ore : OreDictionary.getOres("dustRefinedObsidian")) { RecipeHandler.addOsmiumCompressorRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Ingot, 1, 0)); RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 6)); } - - for(ItemStack ore : OreDictionary.getOres("clumpIron")) - { - RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 0)); - } - - for(ItemStack ore : OreDictionary.getOres("clumpGold")) - { - RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 1)); - } - - for(ItemStack ore : OreDictionary.getOres("clumpOsmium")) - { - RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 2)); - } - - for(ItemStack ore : OreDictionary.getOres("clumpCopper")) - { - RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 3)); - } - - for(ItemStack ore : OreDictionary.getOres("clumpTin")) - { - RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 4)); - } - - for(ItemStack ore : OreDictionary.getOres("clumpSilver")) - { - RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 5)); - } - - for(ItemStack ore : OreDictionary.getOres("clumpObsidian")) - { - RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 6)); - } - - for(ItemStack ore : OreDictionary.getOres("clumpLead")) - { - RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 7)); - } - + + for(ItemStack ore : OreDictionary.getOres("clumpIron")) + { + RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 0)); + } + + for(ItemStack ore : OreDictionary.getOres("clumpGold")) + { + RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 1)); + } + + for(ItemStack ore : OreDictionary.getOres("clumpOsmium")) + { + RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 2)); + } + + for(ItemStack ore : OreDictionary.getOres("clumpCopper")) + { + RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 3)); + } + + for(ItemStack ore : OreDictionary.getOres("clumpTin")) + { + RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 4)); + } + + for(ItemStack ore : OreDictionary.getOres("clumpSilver")) + { + RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 5)); + } + + for(ItemStack ore : OreDictionary.getOres("clumpObsidian")) + { + RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 6)); + } + + for(ItemStack ore : OreDictionary.getOres("clumpLead")) + { + RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.DirtyDust, 1, 7)); + } + for(ItemStack ore : OreDictionary.getOres("shardIron")) { RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 1, 0)); } - + for(ItemStack ore : OreDictionary.getOres("shardGold")) { RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 1, 1)); } - + for(ItemStack ore : OreDictionary.getOres("shardOsmium")) { RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 1, 2)); } - + for(ItemStack ore : OreDictionary.getOres("shardCopper")) { RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 1, 3)); } - + for(ItemStack ore : OreDictionary.getOres("shardTin")) { RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 1, 4)); } - + for(ItemStack ore : OreDictionary.getOres("shardSilver")) { RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 1, 5)); } - + for(ItemStack ore : OreDictionary.getOres("shardObsidian")) { RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 1, 6)); } - + for(ItemStack ore : OreDictionary.getOres("shardLead")) { RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 1, 7)); } - + for(ItemStack ore : OreDictionary.getOres("crystalIron")) { RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 1, 0)); } - + for(ItemStack ore : OreDictionary.getOres("crystalGold")) { RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 1, 1)); } - + for(ItemStack ore : OreDictionary.getOres("crystalOsmium")) { RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 1, 2)); } - + for(ItemStack ore : OreDictionary.getOres("crystalCopper")) { RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 1, 3)); } - + for(ItemStack ore : OreDictionary.getOres("crystalTin")) { RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 1, 4)); } - + for(ItemStack ore : OreDictionary.getOres("crystalSilver")) { RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 1, 5)); } - + for(ItemStack ore : OreDictionary.getOres("crystalObsidian")) { RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 1, 6)); } - + for(ItemStack ore : OreDictionary.getOres("crystalLead")) { RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 1, 7)); } - + for(ItemStack ore : OreDictionary.getOres("dustDirtyIron")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 0)); } - + for(ItemStack ore : OreDictionary.getOres("dustDirtyGold")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 1)); } - + for(ItemStack ore : OreDictionary.getOres("dustDirtyOsmium")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 2)); } - + for(ItemStack ore : OreDictionary.getOres("dustDirtyCopper")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 6)); } - + for(ItemStack ore : OreDictionary.getOres("dustDirtyTin")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 7)); } - + for(ItemStack ore : OreDictionary.getOres("dustDirtySilver")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 8)); } - + for(ItemStack ore : OreDictionary.getOres("dustDirtyLead")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 9)); } - + for(ItemStack ore : OreDictionary.getOres("oreCopper")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 6)); @@ -235,7 +235,7 @@ public final class OreDictManager RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 3)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("copper"), 1000)); } - + for(ItemStack ore : OreDictionary.getOres("oreTin")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 7)); @@ -243,7 +243,7 @@ public final class OreDictManager RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 4)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("tin"), 1000)); } - + for(ItemStack ore : OreDictionary.getOres("oreOsmium")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 2)); @@ -251,23 +251,23 @@ public final class OreDictManager RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 2)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("osmium"), 1000)); } - + for(ItemStack ore : OreDictionary.getOres("oreIron")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 0)); - RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 0)); + RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 0)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 0)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("iron"), 1000)); } - + for(ItemStack ore : OreDictionary.getOres("oreGold")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 1)); - RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 1)); + RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 1)); RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 1)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("gold"), 1000)); } - + for(ItemStack ore : OreDictionary.getOres("oreSilver")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 8)); @@ -275,7 +275,7 @@ public final class OreDictManager RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 5)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("silver"), 1000)); } - + for(ItemStack ore : OreDictionary.getOres("oreLead")) { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 9)); @@ -283,160 +283,160 @@ public final class OreDictManager RecipeHandler.addChemicalInjectionChamberRecipe(new AdvancedInput(MekanismUtils.size(ore, 1), GasRegistry.getGas("hydrogenChloride")), new ItemStack(Mekanism.Shard, 4, 7)); RecipeHandler.addChemicalDissolutionChamberRecipe(MekanismUtils.size(ore, 1), new GasStack(GasRegistry.getGas("lead"), 1000)); } - + for(ItemStack ore : OreDictionary.getOres("oreNickel")) { try { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dustNickel").get(0), 2)); } catch(Exception e) {} } - + for(ItemStack ore : OreDictionary.getOres("oreYellorite")) { try { RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dustYellorite").get(0), 2)); } catch(Exception e) {} } - + for(ItemStack ore : OreDictionary.getOres("ingotCopper")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 6)); } - + for(ItemStack ore : OreDictionary.getOres("ingotTin")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 7)); } - + for(ItemStack ore : OreDictionary.getOres("ingotLead")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 9)); } - + for(ItemStack ore : OreDictionary.getOres("ingotSilver")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 8)); } - + for(ItemStack ore : OreDictionary.getOres("ingotRefinedObsidian")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 3)); } - + for(ItemStack ore : OreDictionary.getOres("ingotOsmium")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 2)); } - + for(ItemStack ore : OreDictionary.getOres("ingotRedstone")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Item.redstone)); } - + for(ItemStack ore : OreDictionary.getOres("ingotRefinedGlowstone")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Item.glowstone)); } - + for(ItemStack ore : OreDictionary.getOres("ingotNickel")) { try { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dustNickel").get(0), 1)); } catch(Exception e) {} } - + try { RecipeHandler.addCrusherRecipe(new ItemStack(Mekanism.Ingot, 1, 2), MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); - + if(Mekanism.hooks.IC2Loaded) { Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); } } catch(Exception e) {} - + try { FurnaceRecipes.smelting().addSmelting(Mekanism.Dust.itemID, 8, MekanismUtils.size(OreDictionary.getOres("ingotSilver").get(0), 1), 0.0F); } catch(Exception e) {} - + try { FurnaceRecipes.smelting().addSmelting(Mekanism.Dust.itemID, 9, MekanismUtils.size(OreDictionary.getOres("ingotLead").get(0), 1), 0.0F); } catch(Exception e) {} - + try { RecipeHandler.addCrusherRecipe(new ItemStack(Item.coal), MekanismUtils.size(OreDictionary.getOres("dustCoal").get(0), 1)); } catch(Exception e) {} - + try { RecipeHandler.addCrusherRecipe(new ItemStack(Item.coal, 1, 1), MekanismUtils.size(OreDictionary.getOres("dustCharcoal").get(0), 1)); } catch(Exception e) {} - + try { for(ItemStack ore : OreDictionary.getOres("ingotSilver")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 8)); } } catch(Exception e) {} - + for(ItemStack ore : OreDictionary.getOres("dustIron")) { RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 8), new ItemStack(Block.oreIron)); } - + for(ItemStack ore : OreDictionary.getOres("ingotSteel")) { RecipeHandler.addCrusherRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 1, 5)); } - + for(ItemStack ore : OreDictionary.getOres("dustGold")) { RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 8), new ItemStack(Block.oreGold)); } - + for(ItemStack ore : OreDictionary.getOres("dustLapisLazuli")) { RecipeHandler.addCrusherRecipe(new ItemStack(Item.dyePowder, 1, 4), MekanismUtils.size(ore, 1)); } - + for(ItemStack ore : OreDictionary.getOres("dustObsidian")) { RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 4), new ItemStack(Block.obsidian)); RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("DIAMOND"), 10, MekanismUtils.size(ore, 1)), new ItemStack(Mekanism.Dust, 1, 3)); } - + for(ItemStack ore : OreDictionary.getOres("dustOsmium")) { RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 8), new ItemStack(Mekanism.OreBlock, 1, 0)); } - + for(ItemStack ore : OreDictionary.getOres("dustDiamond")) { InfuseRegistry.registerInfuseObject(ore, new InfuseObject(InfuseRegistry.get("DIAMOND"), 80)); RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Item.diamond)); } - + for(ItemStack ore : OreDictionary.getOres("dustCopper")) { RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 8), new ItemStack(Mekanism.OreBlock, 1, 1)); } - + for(ItemStack ore : OreDictionary.getOres("ingotCopper")) { RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("TIN"), 10, MekanismUtils.size(ore, 1)), new ItemStack(Mekanism.Ingot, 1, 2)); } - + for(ItemStack ore : OreDictionary.getOres("dustTin")) { RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 8), new ItemStack(Mekanism.OreBlock, 1, 2)); InfuseRegistry.registerInfuseObject(ore, new InfuseObject(InfuseRegistry.get("TIN"), 50)); } - + try { for(ItemStack ore : OreDictionary.getOres("dustLead")) { RecipeHandler.addCombinerRecipe(MekanismUtils.size(ore, 8), MekanismUtils.size(OreDictionary.getOres("oreLead").get(0), 1)); } } catch(Exception e) {} - + try { for(ItemStack ore : OreDictionary.getOres("dustSilver")) { @@ -444,7 +444,7 @@ public final class OreDictManager } } catch(Exception e) {} } - + /** * Handy method for retrieving all log items, finding their corresponding planks, and making recipes with them. Taken from CofhCore. */ @@ -456,7 +456,7 @@ public final class OreDictManager return false; } }; - + InventoryCrafting tempCrafting = new InventoryCrafting(tempContainer, 3, 3); ArrayList recipeList = (ArrayList)CraftingManager.getInstance().getRecipeList(); @@ -466,7 +466,7 @@ public final class OreDictManager } ArrayList registeredOres = OreDictionary.getOres("logWood"); - + for(int i = 0; i < registeredOres.size(); i++) { ItemStack logEntry = (ItemStack)registeredOres.get(i); diff --git a/common/mekanism/common/inventory/InventoryBin.java b/common/mekanism/common/inventory/InventoryBin.java index 3773d1136..d280a15fa 100644 --- a/common/mekanism/common/inventory/InventoryBin.java +++ b/common/mekanism/common/inventory/InventoryBin.java @@ -4,43 +4,43 @@ import mekanism.common.item.ItemBlockBasic; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class InventoryBin +public class InventoryBin { public final int MAX_STORAGE = 4096; - + public ItemStack bin; - + public InventoryBin(ItemStack stack) { bin = stack; } - + public ItemStack getStack() { if(getItemCount() > 0) { ItemStack ret = getItemType().copy(); ret.stackSize = Math.min(getItemType().getMaxStackSize(), getItemCount()); - + return ret; } - + return null; } - + public ItemStack removeStack() { ItemStack stack = getStack(); - + if(stack == null) { return null; } - + setItemCount(getItemCount() - stack.stackSize); return stack.copy(); } - + public ItemStack add(ItemStack stack) { if(isValid(stack) && getItemCount() != MAX_STORAGE) @@ -49,7 +49,7 @@ public class InventoryBin { setItemType(stack); } - + if(getItemCount() + stack.stackSize <= MAX_STORAGE) { setItemCount(getItemCount() + stack.stackSize); @@ -58,107 +58,107 @@ public class InventoryBin else { ItemStack rejects = getItemType().copy(); rejects.stackSize = (getItemCount()+stack.stackSize) - MAX_STORAGE; - + setItemCount(MAX_STORAGE); - + return rejects; } } - + return stack; } - + public boolean isValid(ItemStack stack) { if(stack == null || stack.stackSize <= 0) { return false; } - + if(stack.isItemStackDamageable() && stack.isItemDamaged()) { return false; } - + if(stack.getItem() instanceof ItemBlockBasic && stack.getItemDamage() == 6) { return false; } - + if(getItemType() == null) { return true; } - + if(!stack.isItemEqual(getItemType()) || !ItemStack.areItemStackTagsEqual(stack, getItemType())) { return false; } - + return true; } - + public int getItemCount() { if(bin.stackTagCompound == null) { return 0; } - + return bin.stackTagCompound.getInteger("itemCount"); } - + public void setItemCount(int count) { if(bin.stackTagCompound == null) { bin.setTagCompound(new NBTTagCompound()); } - + bin.stackTagCompound.setInteger("itemCount", Math.max(0, count)); - + if(getItemCount() == 0) { setItemType(null); } } - + public ItemStack getItemType() { if(bin.stackTagCompound == null || getItemCount() == 0) { return null; } - + int id = bin.stackTagCompound.getInteger("itemID"); int meta = bin.stackTagCompound.getInteger("itemMeta"); - + if(getItemCount() == 0 || id == 0) { setItemType(null); return null; } - + return new ItemStack(id, 1, meta); } - + public void setItemType(ItemStack stack) { if(bin.stackTagCompound == null) { bin.setTagCompound(new NBTTagCompound()); } - + if(stack == null) { bin.stackTagCompound.removeTag("itemID"); bin.stackTagCompound.removeTag("itemMeta"); return; } - + ItemStack ret = stack.copy(); ret.stackSize = 1; - + bin.stackTagCompound.setInteger("itemID", stack.itemID); bin.stackTagCompound.setInteger("itemMeta", stack.getItemDamage()); } diff --git a/common/mekanism/common/inventory/InventoryElectricChest.java b/common/mekanism/common/inventory/InventoryElectricChest.java index 9e1bca772..790af82f2 100644 --- a/common/mekanism/common/inventory/InventoryElectricChest.java +++ b/common/mekanism/common/inventory/InventoryElectricChest.java @@ -12,96 +12,96 @@ public class InventoryElectricChest extends InventoryBasic { public EntityPlayer entityPlayer; public ItemStack itemStack; - + public boolean reading; - + public InventoryElectricChest(EntityPlayer player) { super("Electric Chest", false, 55); entityPlayer = player; - + read(); } - + public InventoryElectricChest(ItemStack stack) { super("Electric Chest", false, 55); itemStack = stack; - + read(); } - - @Override - public void onInventoryChanged() - { - super.onInventoryChanged(); - - if(!reading) - { - write(); - } - } - - @Override - public void openChest() - { - read(); - ((IElectricChest)getStack().getItem()).setOpen(getStack(), true); - } @Override - public void closeChest() - { - write(); - ((IElectricChest)getStack().getItem()).setOpen(getStack(), false); - } - + public void onInventoryChanged() + { + super.onInventoryChanged(); + + if(!reading) + { + write(); + } + } + + @Override + public void openChest() + { + read(); + ((IElectricChest)getStack().getItem()).setOpen(getStack(), true); + } + + @Override + public void closeChest() + { + write(); + ((IElectricChest)getStack().getItem()).setOpen(getStack(), false); + } + public void write() { - NBTTagList tagList = new NBTTagList(); + NBTTagList tagList = new NBTTagList(); - for(int slotCount = 0; slotCount < getSizeInventory(); slotCount++) - { - if(getStackInSlot(slotCount) != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - getStackInSlot(slotCount).writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } - - ((ISustainedInventory)getStack().getItem()).setInventory(tagList, getStack()); + for(int slotCount = 0; slotCount < getSizeInventory(); slotCount++) + { + if(getStackInSlot(slotCount) != null) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte)slotCount); + getStackInSlot(slotCount).writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + ((ISustainedInventory)getStack().getItem()).setInventory(tagList, getStack()); } - + public void read() { if(reading) { return; } - - reading = true; - - NBTTagList tagList = ((ISustainedInventory)getStack().getItem()).getInventory(getStack()); - if(tagList != null) - { - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); - - if(slotID >= 0 && slotID < getSizeInventory()) - { - setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); - } - } - } - - reading = false; + reading = true; + + NBTTagList tagList = ((ISustainedInventory)getStack().getItem()).getInventory(getStack()); + + if(tagList != null) + { + for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) + { + NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); + + if(slotID >= 0 && slotID < getSizeInventory()) + { + setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); + } + } + } + + reading = false; } - + public ItemStack getStack() { return itemStack != null ? itemStack : entityPlayer.getCurrentEquippedItem(); diff --git a/common/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java b/common/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java index bb5781523..05f4d88ca 100644 --- a/common/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java +++ b/common/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java @@ -18,185 +18,185 @@ import net.minecraft.item.ItemStack; public class ContainerAdvancedElectricMachine extends Container { - private TileEntityAdvancedElectricMachine tileEntity; + private TileEntityAdvancedElectricMachine tileEntity; - public ContainerAdvancedElectricMachine(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 56, 17)); - addSlotToContainer(new Slot(tentity, 1, 56, 53)); - addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - addSlotToContainer(new SlotDischarge(tentity, 3, 31, 35)); - addSlotToContainer(new SlotMachineUpgrade(tentity, 4, 180, 11)); - - int slotX; + public ContainerAdvancedElectricMachine(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 56, 17)); + addSlotToContainer(new Slot(tentity, 1, 56, 53)); + addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); + addSlotToContainer(new SlotDischarge(tentity, 3, 31, 35)); + addSlotToContainer(new SlotMachineUpgrade(tentity, 4, 180, 11)); - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + int slotX; - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotID == 2) - { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(tileEntity.getItemGas(slotStack) != null) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(isInputItem(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof ItemMachineUpgrade) - { - if(slotID != 4) - { - if(!mergeItemStack(slotStack, 4, 5, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 5 && slotID <= 31) - { - if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 31) - { - if(!mergeItemStack(slotStack, 5, 31, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotID == 2) + { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 3) + { + if(!mergeItemStack(slotStack, 3, 4, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(tileEntity.getItemGas(slotStack) != null) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(isInputItem(slotStack)) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof ItemMachineUpgrade) + { + if(slotID != 4) + { + if(!mergeItemStack(slotStack, 4, 5, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 5 && slotID <= 31) + { + if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 31) + { + if(!mergeItemStack(slotStack, 5, 31, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } - return stack; - } - - private boolean isInputItem(ItemStack itemstack) - { - for(Map.Entry entry : ((Map)tileEntity.getRecipes()).entrySet()) - { - if(entry.getKey().itemStack.isItemEqual(itemstack)) - { - return true; - } - } - - return false; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + private boolean isInputItem(ItemStack itemstack) + { + for(Map.Entry entry : ((Map)tileEntity.getRecipes()).entrySet()) + { + if(entry.getKey().itemStack.isItemEqual(itemstack)) + { + return true; + } + } + + return false; + } } diff --git a/common/mekanism/common/inventory/container/ContainerChanceMachine.java b/common/mekanism/common/inventory/container/ContainerChanceMachine.java index 88a12f88c..a55e79091 100644 --- a/common/mekanism/common/inventory/container/ContainerChanceMachine.java +++ b/common/mekanism/common/inventory/container/ContainerChanceMachine.java @@ -15,156 +15,156 @@ import net.minecraft.item.ItemStack; public class ContainerChanceMachine extends Container { - private TileEntityChanceMachine tileEntity; + private TileEntityChanceMachine tileEntity; - public ContainerChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 56, 17)); - addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); - addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11)); - addSlotToContainer(new SlotOutput(tentity, 4, 132, 35)); - int slotX; + public ContainerChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 56, 17)); + addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); + addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); + addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11)); + addSlotToContainer(new SlotOutput(tentity, 4, 132, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotID == 2 || slotID == 4) - { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(RecipeHandler.getChanceOutput(slotStack, false, tileEntity.getRecipes()) != null) - { - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof ItemMachineUpgrade) - { - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 5 && slotID <= 31) - { - if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 31) - { - if(!mergeItemStack(slotStack, 5, 31, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotID == 2 || slotID == 4) + { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(RecipeHandler.getChanceOutput(slotStack, false, tileEntity.getRecipes()) != null) + { + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof ItemMachineUpgrade) + { + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) + { + if(!mergeItemStack(slotStack, 3, 4, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 5 && slotID <= 31) + { + if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 31) + { + if(!mergeItemStack(slotStack, 5, 31, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } - return stack; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerChemicalCrystalizer.java b/common/mekanism/common/inventory/container/ContainerChemicalCrystalizer.java index ccce71ea0..784855090 100644 --- a/common/mekanism/common/inventory/container/ContainerChemicalCrystalizer.java +++ b/common/mekanism/common/inventory/container/ContainerChemicalCrystalizer.java @@ -18,137 +18,137 @@ public class ContainerChemicalCrystalizer extends Container { private TileEntityChemicalCrystalizer tileEntity; - public ContainerChemicalCrystalizer(InventoryPlayer inventory, TileEntityChemicalCrystalizer tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 6, 65)); - addSlotToContainer(new SlotOutput(tentity, 1, 131, 57)); - addSlotToContainer(new SlotDischarge(tentity, 2, 155, 5)); - - int slotY; + public ContainerChemicalCrystalizer(InventoryPlayer inventory, TileEntityChemicalCrystalizer tentity) + { + tileEntity = tentity; + addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 6, 65)); + addSlotToContainer(new SlotOutput(tentity, 1, 131, 57)); + addSlotToContainer(new SlotDischarge(tentity, 2, 155, 5)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotY = 0; slotY < 3; slotY++) + { + for(int slotX = 0; slotX < 9; slotX++) + { + addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); + } + } + + for(slotY = 0; slotY < 9; slotY++) + { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 3) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else if(slotID == 3) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if(slotStack.getItem() instanceof IGasItem) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 3) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + else if(slotID == 3) + { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 3 && slotID <= 29) + { + if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 30) + { + if(!mergeItemStack(slotStack, 3, 29, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java b/common/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java index 71e1de061..e1cccf64c 100644 --- a/common/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java +++ b/common/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java @@ -15,152 +15,152 @@ import net.minecraft.item.ItemStack; public class ContainerChemicalDissolutionChamber extends Container { - private TileEntityChemicalDissolutionChamber tileEntity; + private TileEntityChemicalDissolutionChamber tileEntity; - public ContainerChemicalDissolutionChamber(InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 6, 65)); - addSlotToContainer(new Slot(tentity, 1, 26, 36)); - addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 155, 25)); - addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - - int slotY; + public ContainerChemicalDissolutionChamber(InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tentity) + { + tileEntity = tentity; + addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 6, 65)); + addSlotToContainer(new Slot(tentity, 1, 26, 36)); + addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 155, 25)); + addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotY = 0; slotY < 3; slotY++) + { + for(int slotX = 0; slotX < 9; slotX++) + { + addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); + } + } + + for(slotY = 0; slotY < 9; slotY++) + { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(RecipeHandler.getItemToGasOutput(slotStack, false, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()) != null) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, true)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else if(slotID == 3) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 2) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 31) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(RecipeHandler.getItemToGasOutput(slotStack, false, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()) != null) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, true)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 3) + { + if(!mergeItemStack(slotStack, 3, 4, false)) + { + return null; + } + } + else if(slotID == 3) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof IGasItem) + { + if(slotID != 0 && slotID != 2) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 4 && slotID <= 30) + { + if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 31) + { + if(!mergeItemStack(slotStack, 4, 30, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } - return stack; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerChemicalInfuser.java b/common/mekanism/common/inventory/container/ContainerChemicalInfuser.java index bc41adb89..6ede69ca5 100644 --- a/common/mekanism/common/inventory/container/ContainerChemicalInfuser.java +++ b/common/mekanism/common/inventory/container/ContainerChemicalInfuser.java @@ -14,133 +14,133 @@ import net.minecraft.item.ItemStack; public class ContainerChemicalInfuser extends Container { - private TileEntityChemicalInfuser tileEntity; + private TileEntityChemicalInfuser tileEntity; - public ContainerChemicalInfuser(InventoryPlayer inventory, TileEntityChemicalInfuser tentity) - { - tileEntity = tentity; + public ContainerChemicalInfuser(InventoryPlayer inventory, TileEntityChemicalInfuser tentity) + { + tileEntity = tentity; addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 5, 56)); - addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 155, 56)); + addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 155, 56)); addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 80, 65)); - addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - - int slotX; + addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - for(slotX = 0; slotX < 3; slotX++) - { - for(int slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + int slotX; - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 3; slotX++) + { + for(int slotY = 0; slotY < 9; slotY++) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else if(slotID == 3) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1 && slotID != 2) - { - if(!mergeItemStack(slotStack, 0, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 3) + { + if(!mergeItemStack(slotStack, 3, 4, false)) + { + return null; + } + } + else if(slotID == 3) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof IGasItem) + { + if(slotID != 0 && slotID != 1 && slotID != 2) + { + if(!mergeItemStack(slotStack, 0, 3, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 4 && slotID <= 30) + { + if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 30) + { + if(!mergeItemStack(slotStack, 4, 30, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } - return stack; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerChemicalOxidizer.java b/common/mekanism/common/inventory/container/ContainerChemicalOxidizer.java index 3735c09fe..7e5397e19 100644 --- a/common/mekanism/common/inventory/container/ContainerChemicalOxidizer.java +++ b/common/mekanism/common/inventory/container/ContainerChemicalOxidizer.java @@ -15,139 +15,139 @@ import net.minecraft.item.ItemStack; public class ContainerChemicalOxidizer extends Container { - private TileEntityChemicalOxidizer tileEntity; + private TileEntityChemicalOxidizer tileEntity; - public ContainerChemicalOxidizer(InventoryPlayer inventory, TileEntityChemicalOxidizer tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 26, 36)); - addSlotToContainer(new SlotDischarge(tentity, 1, 155, 5)); - addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 155, 25)); - - int slotX; + public ContainerChemicalOxidizer(InventoryPlayer inventory, TileEntityChemicalOxidizer tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 26, 36)); + addSlotToContainer(new SlotDischarge(tentity, 1, 155, 5)); + addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 155, 25)); - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + int slotX; - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(RecipeHandler.getItemToGasOutput(slotStack, false, Recipe.CHEMICAL_OXIDIZER.get()) != null) - { - if(!mergeItemStack(slotStack, 0, 1, true)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1 && slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(RecipeHandler.getItemToGasOutput(slotStack, false, Recipe.CHEMICAL_OXIDIZER.get()) != null) + { + if(!mergeItemStack(slotStack, 0, 1, true)) + { + return null; + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof IGasItem) + { + if(slotID != 0 && slotID != 1 && slotID != 2) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 3 && slotID <= 29) + { + if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 30) + { + if(!mergeItemStack(slotStack, 3, 29, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } - return stack; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerChemicalWasher.java b/common/mekanism/common/inventory/container/ContainerChemicalWasher.java index 058f21033..cac25a0b4 100644 --- a/common/mekanism/common/inventory/container/ContainerChemicalWasher.java +++ b/common/mekanism/common/inventory/container/ContainerChemicalWasher.java @@ -16,156 +16,156 @@ import net.minecraftforge.fluids.FluidRegistry; public class ContainerChemicalWasher extends Container { - private TileEntityChemicalWasher tileEntity; + private TileEntityChemicalWasher tileEntity; - public ContainerChemicalWasher(InventoryPlayer inventory, TileEntityChemicalWasher tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, -20, 9)); - addSlotToContainer(new SlotOutput(tentity, 1, -20, 40)); - addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 155, 56)); - addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - - int slotY; + public ContainerChemicalWasher(InventoryPlayer inventory, TileEntityChemicalWasher tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, -20, 9)); + addSlotToContainer(new SlotOutput(tentity, 1, -20, 40)); + addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 155, 56)); + addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotY = 0; slotY < 3; slotY++) + { + for(int slotX = 0; slotX < 9; slotX++) + { + addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); + } + } + + for(slotY = 0; slotY < 9; slotY++) + { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotID == 1) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - else if(FluidContainerRegistry.isFilledContainer(slotStack) && FluidContainerRegistry.getFluidForFilledItem(slotStack).getFluid() == FluidRegistry.WATER) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else if(slotID == 3) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 31) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotID == 1) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + else if(FluidContainerRegistry.isFilledContainer(slotStack) && FluidContainerRegistry.getFluidForFilledItem(slotStack).getFluid() == FluidRegistry.WATER) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof IGasItem) + { + if(slotID != 2) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 3) + { + if(!mergeItemStack(slotStack, 3, 4, false)) + { + return null; + } + } + else if(slotID == 3) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 4 && slotID <= 30) + { + if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 31) + { + if(!mergeItemStack(slotStack, 4, 30, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } - return stack; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerDictionary.java b/common/mekanism/common/inventory/container/ContainerDictionary.java index 158ccee2e..f2ea6dc83 100644 --- a/common/mekanism/common/inventory/container/ContainerDictionary.java +++ b/common/mekanism/common/inventory/container/ContainerDictionary.java @@ -8,78 +8,78 @@ import net.minecraft.item.ItemStack; public class ContainerDictionary extends Container { - public ContainerDictionary(InventoryPlayer inventory) - { - int slotX; - - for(slotX = 0; slotX < 3; slotX++) - { - for(int slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } - - for(slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - } - - @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public ContainerDictionary(InventoryPlayer inventory) { - return true; - } - + int slotX; + + for(slotX = 0; slotX < 3; slotX++) + { + for(int slotY = 0; slotY < 9; slotY++) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; slotX++) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + } + @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + public boolean canInteractWith(EntityPlayer entityplayer) + { + return true; + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotID >= 0 && slotID <= 26) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 26) - { - if(!mergeItemStack(slotStack, 0, 26, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) - { - return null; - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(slotID >= 0 && slotID <= 26) + { + if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 26) + { + if(!mergeItemStack(slotStack, 0, 26, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) + { + return null; + } + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - return stack; - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerDigitalMiner.java b/common/mekanism/common/inventory/container/ContainerDigitalMiner.java index 2feba9ce2..f0e4b9875 100644 --- a/common/mekanism/common/inventory/container/ContainerDigitalMiner.java +++ b/common/mekanism/common/inventory/container/ContainerDigitalMiner.java @@ -15,131 +15,131 @@ import net.minecraft.item.ItemStack; public class ContainerDigitalMiner extends Container { - private TileEntityDigitalMiner tileEntity; + private TileEntityDigitalMiner tileEntity; - public ContainerDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity) - { - tileEntity = tentity; - - for(int slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(tentity, slotX + slotY * 9, 8 + slotX * 18, 80 + slotY * 18)); - } - } + public ContainerDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity) + { + tileEntity = tentity; - addSlotToContainer(new SlotDischarge(tentity, 27, 152, 6)); - addSlotToContainer(new SlotMachineUpgrade(tentity, 28, 180, 11)); - - int slotX; + for(int slotY = 0; slotY < 3; slotY++) + { + for(int slotX = 0; slotX < 9; slotX++) + { + addSlotToContainer(new Slot(tentity, slotX + slotY * 9, 8 + slotX * 18, 80 + slotY * 18)); + } + } - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18)); - } - } + addSlotToContainer(new SlotDischarge(tentity, 27, 152, 6)); + addSlotToContainer(new SlotMachineUpgrade(tentity, 28, 180, 11)); - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); - + tileEntity.close(entityplayer); tileEntity.closeChest(); - } + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { return tileEntity.isUseableByPlayer(entityplayer); - } + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 27) - { - if(!mergeItemStack(slotStack, 27, 28, false)) - { - return null; - } - } - else if(slotID == 27) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof ItemMachineUpgrade) - { - if(slotID != 27 && slotID != 28) - { - if(!mergeItemStack(slotStack, 28, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID < 27) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), true)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 0, 27, false)) - { - return null; - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 27) + { + if(!mergeItemStack(slotStack, 27, 28, false)) + { + return null; + } + } + else if(slotID == 27) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof ItemMachineUpgrade) + { + if(slotID != 27 && slotID != 28) + { + if(!mergeItemStack(slotStack, 28, 29, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID < 27) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), true)) + { + return null; + } + } + else if(!mergeItemStack(slotStack, 0, 27, false)) + { + return null; + } + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - return stack; - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerDynamicTank.java b/common/mekanism/common/inventory/container/ContainerDynamicTank.java index baaeb0392..85404cf93 100644 --- a/common/mekanism/common/inventory/container/ContainerDynamicTank.java +++ b/common/mekanism/common/inventory/container/ContainerDynamicTank.java @@ -11,113 +11,113 @@ import net.minecraftforge.fluids.FluidContainerRegistry; public class ContainerDynamicTank extends Container { - private TileEntityDynamicTank tileEntity; + private TileEntityDynamicTank tileEntity; - public ContainerDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 146, 20)); - addSlotToContainer(new SlotOutput(tentity, 1, 146, 51)); - int slotX; + public ContainerDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 146, 20)); + addSlotToContainer(new SlotOutput(tentity, 1, 146, 51)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack)) - { - if(slotID != 0 && slotID != 1) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 8) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack)) + { + if(slotID != 0 && slotID != 1) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 2 && slotID <= 8) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 28) + { + if(!mergeItemStack(slotStack, 2, 28, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerElectricChest.java b/common/mekanism/common/inventory/container/ContainerElectricChest.java index 2f5a5d82d..8f44b23a9 100644 --- a/common/mekanism/common/inventory/container/ContainerElectricChest.java +++ b/common/mekanism/common/inventory/container/ContainerElectricChest.java @@ -15,67 +15,67 @@ import net.minecraft.item.ItemStack; public class ContainerElectricChest extends Container { - private TileEntityElectricChest tileEntity; - private IInventory itemInventory; - private boolean isBlock; + private TileEntityElectricChest tileEntity; + private IInventory itemInventory; + private boolean isBlock; - public ContainerElectricChest(InventoryPlayer inventory, TileEntityElectricChest tentity, IInventory inv, boolean b) - { - tileEntity = tentity; - itemInventory = inv; - isBlock = b; - - if(isBlock) - { - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - else { - itemInventory.openChest(); - } - - for(int slotY = 0; slotY < 6; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new SlotElectricChest(getInv(), slotX + slotY * 9, 8 + slotX * 18, 26 + slotY * 18)); - } - } + public ContainerElectricChest(InventoryPlayer inventory, TileEntityElectricChest tentity, IInventory inv, boolean b) + { + tileEntity = tentity; + itemInventory = inv; + isBlock = b; - addSlotToContainer(new SlotDischarge(getInv(), 54, 180, 11)); - - int slotX; + if(isBlock) + { + tileEntity.open(inventory.player); + tileEntity.openChest(); + } + else { + itemInventory.openChest(); + } - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new SlotElectricChest(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18)); - } - } + for(int slotY = 0; slotY < 6; slotY++) + { + for(int slotX = 0; slotX < 9; slotX++) + { + addSlotToContainer(new SlotElectricChest(getInv(), slotX + slotY * 9, 8 + slotX * 18, 26 + slotY * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new SlotElectricChest(inventory, slotX, 8 + slotX * 18, 206)); - } - } - - public IInventory getInv() - { - if(isBlock) - { - return tileEntity; - } - else { - return itemInventory; - } - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + addSlotToContainer(new SlotDischarge(getInv(), 54, 180, 11)); + + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new SlotElectricChest(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new SlotElectricChest(inventory, slotX, 8 + slotX * 18, 206)); + } + } + + public IInventory getInv() + { + if(isBlock) + { + return tileEntity; + } + else { + return itemInventory; + } + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); - + if(isBlock) { tileEntity.close(entityplayer); @@ -84,96 +84,96 @@ public class ContainerElectricChest extends Container else { itemInventory.closeChest(); } - } + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - if(isBlock) - { - return tileEntity.isUseableByPlayer(entityplayer); - } - - return true; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + if(isBlock) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + return true; + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 54) - { - if(!mergeItemStack(slotStack, 54, 55, false)) - { - return null; - } - } - else if(slotID == 54) - { - if(!mergeItemStack(slotStack, 55, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID < 54) - { - if(!mergeItemStack(slotStack, 55, inventorySlots.size(), true)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 0, 54, false)) - { - return null; - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 54) + { + if(!mergeItemStack(slotStack, 54, 55, false)) + { + return null; + } + } + else if(slotID == 54) + { + if(!mergeItemStack(slotStack, 55, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID < 54) + { + if(!mergeItemStack(slotStack, 55, inventorySlots.size(), true)) + { + return null; + } + } + else if(!mergeItemStack(slotStack, 0, 54, false)) + { + return null; + } + } - return stack; - } - - @Override - public ItemStack slotClick(int slotNumber, int destSlot, int modifier, EntityPlayer player) - { - if(modifier == 2 && destSlot >= 0 && destSlot < 9) - { - ItemStack itemStack = player.inventory.getStackInSlot(destSlot); - if(itemStack != null && itemStack.getItem() instanceof IElectricChest) - { - if(MachineType.get(itemStack) == MachineType.ELECTRIC_CHEST) - { - return null; - } - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - } - - return super.slotClick(slotNumber, destSlot, modifier, player); - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + @Override + public ItemStack slotClick(int slotNumber, int destSlot, int modifier, EntityPlayer player) + { + if(modifier == 2 && destSlot >= 0 && destSlot < 9) + { + ItemStack itemStack = player.inventory.getStackInSlot(destSlot); + if(itemStack != null && itemStack.getItem() instanceof IElectricChest) + { + if(MachineType.get(itemStack) == MachineType.ELECTRIC_CHEST) + { + return null; + } + } + + } + + return super.slotClick(slotNumber, destSlot, modifier, player); + } } diff --git a/common/mekanism/common/inventory/container/ContainerElectricMachine.java b/common/mekanism/common/inventory/container/ContainerElectricMachine.java index 4b8e09168..1e090c5ce 100644 --- a/common/mekanism/common/inventory/container/ContainerElectricMachine.java +++ b/common/mekanism/common/inventory/container/ContainerElectricMachine.java @@ -15,155 +15,155 @@ import net.minecraft.item.ItemStack; public class ContainerElectricMachine extends Container { - private TileEntityElectricMachine tileEntity; + private TileEntityElectricMachine tileEntity; - public ContainerElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 56, 17)); - addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); - addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11)); - int slotX; + public ContainerElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 56, 17)); + addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); + addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); + addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotID == 2) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - else if(RecipeHandler.getOutput(slotStack, false, tileEntity.getRecipes()) != null) - { - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof ItemMachineUpgrade) - { - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotID == 2) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + else if(RecipeHandler.getOutput(slotStack, false, tileEntity.getRecipes()) != null) + { + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof ItemMachineUpgrade) + { + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) + { + if(!mergeItemStack(slotStack, 3, 4, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 4 && slotID <= 30) + { + if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 30) + { + if(!mergeItemStack(slotStack, 4, 30, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } - return stack; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerElectricPump.java b/common/mekanism/common/inventory/container/ContainerElectricPump.java index 22778525c..ad381bde4 100644 --- a/common/mekanism/common/inventory/container/ContainerElectricPump.java +++ b/common/mekanism/common/inventory/container/ContainerElectricPump.java @@ -13,138 +13,138 @@ import net.minecraftforge.fluids.FluidContainerRegistry; public class ContainerElectricPump extends Container { - private TileEntityElectricPump tileEntity; + private TileEntityElectricPump tileEntity; - public ContainerElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 28, 20)); - addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); - addSlotToContainer(new SlotDischarge(tentity, 2, 143, 35)); - int slotX; + public ContainerElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 28, 20)); + addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); + addSlotToContainer(new SlotDischarge(tentity, 2, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(FluidContainerRegistry.isEmptyContainer(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 29) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 2) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(FluidContainerRegistry.isEmptyContainer(slotStack)) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(slotID == 0) + { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + else { + if(slotID >= 3 && slotID <= 29) + { + if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 29) + { + if(!mergeItemStack(slotStack, 3, 29, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java b/common/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java index bd3aaa2a7..e6b4bffaf 100644 --- a/common/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java +++ b/common/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java @@ -15,157 +15,157 @@ import net.minecraft.item.ItemStack; public class ContainerElectrolyticSeparator extends Container { - private TileEntityElectrolyticSeparator tileEntity; + private TileEntityElectrolyticSeparator tileEntity; - public ContainerElectrolyticSeparator(InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 26, 35)); - addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 59, 52)); - addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 101, 52)); - addSlotToContainer(new SlotDischarge(tentity, 3, 143, 35)); - int slotX; + public ContainerElectrolyticSeparator(InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 26, 35)); + addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 59, 52)); + addSlotToContainer(new SlotStorageTank(tentity, null, true, 2, 101, 52)); + addSlotToContainer(new SlotDischarge(tentity, 3, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.openChest(); - tileEntity.open(inventory.player); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.closeChest(); - tileEntity.close(entityplayer); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.openChest(); + tileEntity.open(inventory.player); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.closeChest(); + tileEntity.close(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) - { - if(isCorrectFluid(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(((IGasItem)slotStack.getItem()).getGas(slotStack) != null) - { - if(((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("hydrogen")) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("oxygen")) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - } - else if(((IGasItem)slotStack.getItem()).getGas(slotStack) == null) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) + { + if(isCorrectFluid(slotStack)) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(slotStack.getItem() instanceof IGasItem) + { + if(((IGasItem)slotStack.getItem()).getGas(slotStack) != null) + { + if(((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("hydrogen")) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("oxygen")) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + } + else if(((IGasItem)slotStack.getItem()).getGas(slotStack) == null) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(!mergeItemStack(slotStack, 3, 4, false)) + { + return null; + } + } + else { + if(slotID >= 4 && slotID <= 30) + { + if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 30) + { + if(!mergeItemStack(slotStack, 4, 30, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } - return stack; - } - - public boolean isCorrectFluid(ItemStack itemStack) - { - return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemStack); - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + public boolean isCorrectFluid(ItemStack itemStack) + { + return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemStack); + } } diff --git a/common/mekanism/common/inventory/container/ContainerEnergyCube.java b/common/mekanism/common/inventory/container/ContainerEnergyCube.java index 5ac24717a..87a3c3566 100644 --- a/common/mekanism/common/inventory/container/ContainerEnergyCube.java +++ b/common/mekanism/common/inventory/container/ContainerEnergyCube.java @@ -15,170 +15,170 @@ import net.minecraft.item.ItemStack; public class ContainerEnergyCube extends Container { private TileEntityEnergyCube tileEntity; - + public ContainerEnergyCube(InventoryPlayer inventory, TileEntityEnergyCube unit) { tileEntity = unit; addSlotToContainer(new SlotCharge(unit, 0, 8, 8)); addSlotToContainer(new SlotDischarge(unit, 1, 8, 40)); - - int slotX; - - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } + @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); - + tileEntity.close(entityplayer); tileEntity.closeChest(); - } - + } + @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } - + return tileEntity.isUseableByPlayer(entityplayer); + } + @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeCharged(slotStack) || ChargeUtils.canBeDischarged(slotStack)) - { - if(slotStack.itemID == Item.redstone.itemID) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID != 1 && slotID != 0) - { - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - } - else if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if(ChargeUtils.canBeCharged(slotStack) || ChargeUtils.canBeDischarged(slotStack)) + { + if(slotStack.itemID == Item.redstone.itemID) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID != 1 && slotID != 0) + { + if(ChargeUtils.canBeDischarged(slotStack)) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + if(canTransfer(slotStack)) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + } + } + else if(canTransfer(slotStack)) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + } + else if(slotID == 1) + { + if(canTransfer(slotStack)) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotID == 0) + { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + } + else { + if(slotID >= 2 && slotID <= 28) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 28) + { + if(!mergeItemStack(slotStack, 2, 28, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } - return stack; - } - private boolean canTransfer(ItemStack slotStack) { return slotStack.getItem() instanceof IElectricItem; diff --git a/common/mekanism/common/inventory/container/ContainerFactory.java b/common/mekanism/common/inventory/container/ContainerFactory.java index 4e58c5ae5..caaa6dc6d 100644 --- a/common/mekanism/common/inventory/container/ContainerFactory.java +++ b/common/mekanism/common/inventory/container/ContainerFactory.java @@ -19,280 +19,280 @@ import net.minecraft.item.ItemStack; public class ContainerFactory extends Container { - private TileEntityFactory tileEntity; + private TileEntityFactory tileEntity; - public ContainerFactory(InventoryPlayer inventory, TileEntityFactory tentity) - { - tileEntity = tentity; - - addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11)); - addSlotToContainer(new SlotDischarge(tentity, 1, 7, 13)); - addSlotToContainer(new Slot(tentity, 2, 180, 75)); - addSlotToContainer(new Slot(tentity, 3, 180, 112)); - addSlotToContainer(new Slot(tentity, 4, 7, 57)); - - if(tileEntity.tier == FactoryTier.BASIC) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 55 + (i*38); - - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); - } - - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 55 + (i*38); - - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); - } - } - else if(tileEntity.tier == FactoryTier.ADVANCED) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 35 + (i*26); - - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); - } - - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 35 + (i*26); - - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); - } - } - else if(tileEntity.tier == FactoryTier.ELITE) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 29 + (i*19); - - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); - } - - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 29 + (i*19); - - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); - } - } - - int slotX; + public ContainerFactory(InventoryPlayer inventory, TileEntityFactory tentity) + { + tileEntity = tentity; - for(slotX = 0; slotX < 3; slotX++) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 95 + slotX * 18)); - } - } + addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11)); + addSlotToContainer(new SlotDischarge(tentity, 1, 7, 13)); + addSlotToContainer(new Slot(tentity, 2, 180, 75)); + addSlotToContainer(new Slot(tentity, 3, 180, 112)); + addSlotToContainer(new Slot(tentity, 4, 7, 57)); - for(slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 153)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + if(tileEntity.tier == FactoryTier.BASIC) + { + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xAxis = 55 + (i*38); + + addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); + } + + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xAxis = 55 + (i*38); + + addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); + } + } + else if(tileEntity.tier == FactoryTier.ADVANCED) + { + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xAxis = 35 + (i*26); + + addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); + } + + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xAxis = 35 + (i*26); + + addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); + } + } + else if(tileEntity.tier == FactoryTier.ELITE) + { + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xAxis = 29 + (i*19); + + addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); + } + + for(int i = 0; i < tileEntity.tier.processes; i++) + { + int xAxis = 29 + (i*19); + + addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); + } + } + + int slotX; + + for(slotX = 0; slotX < 3; slotX++) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 95 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; slotX++) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 153)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); - + tileEntity.close(entityplayer); tileEntity.closeChest(); - } + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(isOutputSlot(slotID)) - { - if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) - { - return null; - } - } - else if(slotID != 2 && slotID != 3 && isProperMachine(slotStack) && !slotStack.isItemEqual(tileEntity.getMachineStack())) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else if(slotID == 3) - { - if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) - { - return null; - } - } - else if(RecipeType.values()[tileEntity.recipeType].getCopiedOutput(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null, false) != null) - { - if(!isInputSlot(slotID)) - { - if(!mergeItemStack(slotStack, 5, 5+tileEntity.tier.processes, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(RecipeType.values()[tileEntity.recipeType].getItemGas(slotStack) != null) - { - if(slotID > tileEntity.inventory.length-1) - { - if(!mergeItemStack(slotStack, 4, 5, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof ItemMachineUpgrade) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - int slotEnd = tileEntity.inventory.length; - - if(slotID >= slotEnd && slotID <= (slotEnd+26)) - { - if(!mergeItemStack(slotStack, (slotEnd+27), inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > (slotEnd+26)) - { - if(!mergeItemStack(slotStack, slotEnd, (slotEnd+26), false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, slotEnd, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if(isOutputSlot(slotID)) + { + if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) + { + return null; + } + } + else if(slotID != 2 && slotID != 3 && isProperMachine(slotStack) && !slotStack.isItemEqual(tileEntity.getMachineStack())) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + else if(slotID == 3) + { + if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) + { + return null; + } + } + else if(RecipeType.values()[tileEntity.recipeType].getCopiedOutput(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null, false) != null) + { + if(!isInputSlot(slotID)) + { + if(!mergeItemStack(slotStack, 5, 5+tileEntity.tier.processes, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(RecipeType.values()[tileEntity.recipeType].getItemGas(slotStack) != null) + { + if(slotID > tileEntity.inventory.length-1) + { + if(!mergeItemStack(slotStack, 4, 5, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof ItemMachineUpgrade) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, tileEntity.inventory.length, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + int slotEnd = tileEntity.inventory.length; - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(slotID >= slotEnd && slotID <= (slotEnd+26)) + { + if(!mergeItemStack(slotStack, (slotEnd+27), inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > (slotEnd+26)) + { + if(!mergeItemStack(slotStack, slotEnd, (slotEnd+26), false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, slotEnd, inventorySlots.size(), true)) + { + return null; + } + } + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - return stack; - } - - public boolean isProperMachine(ItemStack itemStack) - { - if(itemStack != null && itemStack.getItem() instanceof ItemBlockMachine) - { - MachineType type = MachineType.get(itemStack); - - if(type == MachineType.ENERGIZED_SMELTER || type == MachineType.ENRICHMENT_CHAMBER || - type == MachineType.CRUSHER || type == MachineType.OSMIUM_COMPRESSOR || - type == MachineType.COMBINER || type == MachineType.PURIFICATION_CHAMBER) - { - return true; - } - } - - return false; - } - - public boolean isInputSlot(int slot) - { - if(tileEntity.tier == Tier.FactoryTier.BASIC) - return slot >= 5 && slot <= 7; - if(tileEntity.tier == Tier.FactoryTier.ADVANCED) - return slot >= 5 && slot <= 9; - if(tileEntity.tier == Tier.FactoryTier.ELITE) - return slot >= 5 && slot <= 11; - - return false; - } - - public boolean isOutputSlot(int slot) - { - if(tileEntity.tier == Tier.FactoryTier.BASIC) - return slot >= 8 && slot <= 10; - if(tileEntity.tier == Tier.FactoryTier.ADVANCED) - return slot >= 10 && slot <= 14; - if(tileEntity.tier == Tier.FactoryTier.ELITE) - return slot >= 12 && slot <= 18; - - return false; - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + public boolean isProperMachine(ItemStack itemStack) + { + if(itemStack != null && itemStack.getItem() instanceof ItemBlockMachine) + { + MachineType type = MachineType.get(itemStack); + + if(type == MachineType.ENERGIZED_SMELTER || type == MachineType.ENRICHMENT_CHAMBER || + type == MachineType.CRUSHER || type == MachineType.OSMIUM_COMPRESSOR || + type == MachineType.COMBINER || type == MachineType.PURIFICATION_CHAMBER) + { + return true; + } + } + + return false; + } + + public boolean isInputSlot(int slot) + { + if(tileEntity.tier == Tier.FactoryTier.BASIC) + return slot >= 5 && slot <= 7; + if(tileEntity.tier == Tier.FactoryTier.ADVANCED) + return slot >= 5 && slot <= 9; + if(tileEntity.tier == Tier.FactoryTier.ELITE) + return slot >= 5 && slot <= 11; + + return false; + } + + public boolean isOutputSlot(int slot) + { + if(tileEntity.tier == Tier.FactoryTier.BASIC) + return slot >= 8 && slot <= 10; + if(tileEntity.tier == Tier.FactoryTier.ADVANCED) + return slot >= 10 && slot <= 14; + if(tileEntity.tier == Tier.FactoryTier.ELITE) + return slot >= 12 && slot <= 18; + + return false; + } } diff --git a/common/mekanism/common/inventory/container/ContainerFilter.java b/common/mekanism/common/inventory/container/ContainerFilter.java index 3a2da0f1f..8c93aee4e 100644 --- a/common/mekanism/common/inventory/container/ContainerFilter.java +++ b/common/mekanism/common/inventory/container/ContainerFilter.java @@ -10,93 +10,93 @@ import net.minecraft.item.ItemStack; public class ContainerFilter extends Container { private TileEntityContainerBlock tileEntity; - - public ContainerFilter(InventoryPlayer inventory, TileEntityContainerBlock tile) - { - tileEntity = tile; - - int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + public ContainerFilter(InventoryPlayer inventory, TileEntityContainerBlock tile) + { + tileEntity = tile; + + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - tileEntity.open(inventory.player); tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); - + tileEntity.close(entityplayer); tileEntity.closeChest(); - } + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } - + return tileEntity.isUseableByPlayer(entityplayer); + } + @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotID >= 0 && slotID <= 26) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 26) - { - if(!mergeItemStack(slotStack, 0, 26, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) - { - return null; - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if(slotID >= 0 && slotID <= 26) + { + if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 26) + { + if(!mergeItemStack(slotStack, 0, 26, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) + { + return null; + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerGasTank.java b/common/mekanism/common/inventory/container/ContainerGasTank.java index 52c9a5667..69c624eb5 100644 --- a/common/mekanism/common/inventory/container/ContainerGasTank.java +++ b/common/mekanism/common/inventory/container/ContainerGasTank.java @@ -12,127 +12,127 @@ import net.minecraft.item.ItemStack; public class ContainerGasTank extends Container { private TileEntityGasTank tileEntity; - + public ContainerGasTank(InventoryPlayer inventory, TileEntityGasTank tentity) { tileEntity = tentity; addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 8, 8)); addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 8, 40)); - - int slotX; - - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } + @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); - + tileEntity.close(entityplayer); tileEntity.closeChest(); - } - + } + @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } - + return tileEntity.isUseableByPlayer(entityplayer); + } + @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) - { - return null; - } - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if(slotStack.getItem() instanceof IGasItem) + { + if(slotID != 0 && slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) + { + return null; + } + } + } + else if(slotID == 0) + { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 2 && slotID <= 28) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 28) + { + if(!mergeItemStack(slotStack, 2, 28, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java b/common/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java index c1e4762b5..caa6851d3 100644 --- a/common/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java +++ b/common/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java @@ -18,160 +18,160 @@ import net.minecraft.item.ItemStack; public class ContainerMetallurgicInfuser extends Container { - private TileEntityMetallurgicInfuser tileEntity; + private TileEntityMetallurgicInfuser tileEntity; - public ContainerMetallurgicInfuser(InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11)); - addSlotToContainer(new Slot(tentity, 1, 17, 35)); - addSlotToContainer(new Slot(tentity, 2, 51, 43)); - addSlotToContainer(new SlotOutput(tentity, 3, 109, 43)); - addSlotToContainer(new SlotDischarge(tentity, 4, 143, 35)); - int slotX; + public ContainerMetallurgicInfuser(InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity) + { + tileEntity = tentity; + addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11)); + addSlotToContainer(new Slot(tentity, 1, 17, 35)); + addSlotToContainer(new Slot(tentity, 2, 51, 43)); + addSlotToContainer(new SlotOutput(tentity, 3, 109, 43)); + addSlotToContainer(new SlotDischarge(tentity, 4, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4) - { - if(InfuseRegistry.getObject(slotStack) != null && (tileEntity.type == null || tileEntity.type == InfuseRegistry.getObject(slotStack).type)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotStack.getItem() instanceof ItemMachineUpgrade) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(!mergeItemStack(slotStack, 4, 5, false)) - { - return null; - } - } - else if(isInputItem(slotStack)) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(slotID >= 5 && slotID <= 31) - { - if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 31) - { - if(!mergeItemStack(slotStack, 5, 31, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4) + { + if(InfuseRegistry.getObject(slotStack) != null && (tileEntity.type == null || tileEntity.type == InfuseRegistry.getObject(slotStack).type)) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotStack.getItem() instanceof ItemMachineUpgrade) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(ChargeUtils.canBeDischarged(slotStack)) + { + if(!mergeItemStack(slotStack, 4, 5, false)) + { + return null; + } + } + else if(isInputItem(slotStack)) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + else { + if(slotID >= 5 && slotID <= 31) + { + if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 31) + { + if(!mergeItemStack(slotStack, 5, 31, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } - return stack; - } - - public boolean isInputItem(ItemStack itemStack) - { - if(tileEntity.type != null) - { - if(RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(tileEntity.type, tileEntity.infuseStored, itemStack), false) != null) - { - return true; - } - } - else { - for(Object obj : Recipe.METALLURGIC_INFUSER.get().keySet()) - { - InfusionInput input = (InfusionInput)obj; - if(input.inputStack.isItemEqual(itemStack)) - { - return true; - } - } - } - - return false; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + public boolean isInputItem(ItemStack itemStack) + { + if(tileEntity.type != null) + { + if(RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(tileEntity.type, tileEntity.infuseStored, itemStack), false) != null) + { + return true; + } + } + else { + for(Object obj : Recipe.METALLURGIC_INFUSER.get().keySet()) + { + InfusionInput input = (InfusionInput)obj; + if(input.inputStack.isItemEqual(itemStack)) + { + return true; + } + } + } + + return false; + } } diff --git a/common/mekanism/common/inventory/container/ContainerNull.java b/common/mekanism/common/inventory/container/ContainerNull.java index 75c0a4e20..5873ed992 100644 --- a/common/mekanism/common/inventory/container/ContainerNull.java +++ b/common/mekanism/common/inventory/container/ContainerNull.java @@ -7,26 +7,26 @@ import net.minecraft.inventory.Container; public class ContainerNull extends Container { private TileEntityContainerBlock tileEntity; - + public ContainerNull(EntityPlayer player, TileEntityContainerBlock tile) { tileEntity = tile; - + tileEntity.open(player); tileEntity.openChest(); } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); - + tileEntity.close(entityplayer); tileEntity.closeChest(); - } - + } + @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public boolean canInteractWith(EntityPlayer entityplayer) { return tileEntity.isUseableByPlayer(entityplayer); } diff --git a/common/mekanism/common/inventory/container/ContainerRobitCrafting.java b/common/mekanism/common/inventory/container/ContainerRobitCrafting.java index 5c268ac2b..e40ff8aa1 100644 --- a/common/mekanism/common/inventory/container/ContainerRobitCrafting.java +++ b/common/mekanism/common/inventory/container/ContainerRobitCrafting.java @@ -7,14 +7,14 @@ import net.minecraft.world.World; public class ContainerRobitCrafting extends ContainerWorkbench { - public ContainerRobitCrafting(InventoryPlayer inventory, World world) + public ContainerRobitCrafting(InventoryPlayer inventory, World world) { super(inventory, world, 0, 0, 0); } - + @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { + public boolean canInteractWith(EntityPlayer entityplayer) + { return true; - } + } } diff --git a/common/mekanism/common/inventory/container/ContainerRobitInventory.java b/common/mekanism/common/inventory/container/ContainerRobitInventory.java index ecd8d4e32..baeec500c 100644 --- a/common/mekanism/common/inventory/container/ContainerRobitInventory.java +++ b/common/mekanism/common/inventory/container/ContainerRobitInventory.java @@ -10,88 +10,88 @@ import net.minecraft.item.ItemStack; public class ContainerRobitInventory extends Container { public EntityRobit robit; - - public ContainerRobitInventory(InventoryPlayer inventory, EntityRobit entity) - { - robit = entity; - robit.openChest(); - - for(int slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(entity, slotX + slotY * 9, 8 + slotX * 18, 18 + slotY * 18)); - } - } - int slotX; + public ContainerRobitInventory(InventoryPlayer inventory, EntityRobit entity) + { + robit = entity; + robit.openChest(); - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(int slotY = 0; slotY < 3; slotY++) + { + for(int slotX = 0; slotX < 9; slotX++) + { + addSlotToContainer(new Slot(entity, slotX + slotY * 9, 8 + slotX * 18, 18 + slotY * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - } + int slotX; - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return true; - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(slotID < 27) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), true)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 0, 27, false)) - { - return null; - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return true; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - return stack; - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - robit.closeChest(); - } + if(slotID < 27) + { + if(!mergeItemStack(slotStack, 27, inventorySlots.size(), true)) + { + return null; + } + } + else if(!mergeItemStack(slotStack, 0, 27, false)) + { + return null; + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { + super.onContainerClosed(entityplayer); + robit.closeChest(); + } } diff --git a/common/mekanism/common/inventory/container/ContainerRobitMain.java b/common/mekanism/common/inventory/container/ContainerRobitMain.java index 8df3b0bf5..64bd3539f 100644 --- a/common/mekanism/common/inventory/container/ContainerRobitMain.java +++ b/common/mekanism/common/inventory/container/ContainerRobitMain.java @@ -10,47 +10,47 @@ import net.minecraft.item.ItemStack; public class ContainerRobitMain extends Container { - private EntityRobit robit; + private EntityRobit robit; - public ContainerRobitMain(InventoryPlayer inventory, EntityRobit entity) - { - robit = entity; - addSlotToContainer(new SlotDischarge(entity, 27, 153, 17)); - - robit.openChest(); - - int slotX; + public ContainerRobitMain(InventoryPlayer inventory, EntityRobit entity) + { + robit = entity; + addSlotToContainer(new SlotDischarge(entity, 27, 153, 17)); - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + robit.openChest(); - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - robit.closeChest(); - } + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return true; - } + super.onContainerClosed(entityplayer); + robit.closeChest(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - return null; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return true; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + return null; + } } diff --git a/common/mekanism/common/inventory/container/ContainerRobitRepair.java b/common/mekanism/common/inventory/container/ContainerRobitRepair.java index 50bdd0e25..d3bc35490 100644 --- a/common/mekanism/common/inventory/container/ContainerRobitRepair.java +++ b/common/mekanism/common/inventory/container/ContainerRobitRepair.java @@ -7,14 +7,14 @@ import net.minecraft.world.World; public class ContainerRobitRepair extends ContainerRepair { - public ContainerRobitRepair(InventoryPlayer inventory, World world) + public ContainerRobitRepair(InventoryPlayer inventory, World world) { super(inventory, world, 0, 0, 0, inventory.player); } - + @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { + public boolean canInteractWith(EntityPlayer entityplayer) + { return true; - } + } } diff --git a/common/mekanism/common/inventory/container/ContainerRobitSmelting.java b/common/mekanism/common/inventory/container/ContainerRobitSmelting.java index 75a336443..f946e205b 100644 --- a/common/mekanism/common/inventory/container/ContainerRobitSmelting.java +++ b/common/mekanism/common/inventory/container/ContainerRobitSmelting.java @@ -14,174 +14,174 @@ import net.minecraft.tileentity.TileEntityFurnace; public class ContainerRobitSmelting extends Container { public EntityRobit robit; - - private int lastCookTime = 0; - private int lastBurnTime = 0; - private int lastItemBurnTime = 0; - - public ContainerRobitSmelting(InventoryPlayer inventory, EntityRobit entity) - { - robit = entity; - robit.openChest(); - - addSlotToContainer(new Slot(entity, 28, 56, 17)); - addSlotToContainer(new Slot(entity, 29, 56, 53)); - addSlotToContainer(new SlotFurnace(inventory.player, entity, 30, 116, 35)); - int slotX; + private int lastCookTime = 0; + private int lastBurnTime = 0; + private int lastItemBurnTime = 0; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + public ContainerRobitSmelting(InventoryPlayer inventory, EntityRobit entity) + { + robit = entity; + robit.openChest(); - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - } + addSlotToContainer(new Slot(entity, 28, 56, 17)); + addSlotToContainer(new Slot(entity, 29, 56, 53)); + addSlotToContainer(new SlotFurnace(inventory.player, entity, 30, 116, 35)); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return true; - } - - @Override - public void addCraftingToCrafters(ICrafting icrafting) - { - super.addCraftingToCrafters(icrafting); - icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); - icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); - icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); - } + int slotX; - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(int i = 0; i < crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)crafters.get(i); + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + } - if(lastCookTime != robit.furnaceCookTime) - { - icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return true; + } - if(lastBurnTime != robit.furnaceBurnTime) - { - icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); - } + @Override + public void addCraftingToCrafters(ICrafting icrafting) + { + super.addCraftingToCrafters(icrafting); + icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); + icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); + icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); + } - if(lastItemBurnTime != robit.currentItemBurnTime) - { - icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); - } - } + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); - lastCookTime = robit.furnaceCookTime; - lastBurnTime = robit.furnaceBurnTime; - lastItemBurnTime = robit.currentItemBurnTime; - } + for(int i = 0; i < crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)crafters.get(i); - @Override - public void updateProgressBar(int i, int j) - { - if(i == 0) - { - robit.furnaceCookTime = j; - } + if(lastCookTime != robit.furnaceCookTime) + { + icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); + } - if(i == 1) - { - robit.furnaceBurnTime = j; - } + if(lastBurnTime != robit.furnaceBurnTime) + { + icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); + } - if(i == 2) - { - robit.currentItemBurnTime = j; - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + if(lastItemBurnTime != robit.currentItemBurnTime) + { + icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); + } + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(slotID == 2) - { - if(!mergeItemStack(slotStack, 3, 39, true)) - { - return null; - } - } - else if(slotID != 1 && slotID != 0) - { - if(FurnaceRecipes.smelting().getSmeltingResult(slotStack) != null) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(TileEntityFurnace.isItemFuel(slotStack)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID >= 3 && slotID < 30) - { - if(!mergeItemStack(slotStack, 30, 39, false)) - { - return null; - } - } - else if(slotID >= 30 && slotID < 39 && !mergeItemStack(slotStack, 3, 30, false)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 3, 39, false)) - { - return null; - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + lastCookTime = robit.furnaceCookTime; + lastBurnTime = robit.furnaceBurnTime; + lastItemBurnTime = robit.currentItemBurnTime; + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public void updateProgressBar(int i, int j) + { + if(i == 0) + { + robit.furnaceCookTime = j; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(i == 1) + { + robit.furnaceBurnTime = j; + } - return stack; - } + if(i == 2) + { + robit.currentItemBurnTime = j; + } + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - robit.closeChest(); - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); + + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); + + if(slotID == 2) + { + if(!mergeItemStack(slotStack, 3, 39, true)) + { + return null; + } + } + else if(slotID != 1 && slotID != 0) + { + if(FurnaceRecipes.smelting().getSmeltingResult(slotStack) != null) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(TileEntityFurnace.isItemFuel(slotStack)) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID >= 3 && slotID < 30) + { + if(!mergeItemStack(slotStack, 30, 39, false)) + { + return null; + } + } + else if(slotID >= 30 && slotID < 39 && !mergeItemStack(slotStack, 3, 30, false)) + { + return null; + } + } + else if(!mergeItemStack(slotStack, 3, 39, false)) + { + return null; + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { + super.onContainerClosed(entityplayer); + robit.closeChest(); + } } diff --git a/common/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java b/common/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java index 24a464ce1..ee427a5a4 100644 --- a/common/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java +++ b/common/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java @@ -15,159 +15,159 @@ import net.minecraftforge.fluids.FluidContainerRegistry; public class ContainerRotaryCondensentrator extends Container { - private TileEntityRotaryCondensentrator tileEntity; + private TileEntityRotaryCondensentrator tileEntity; - public ContainerRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity) - { - tileEntity = tentity; + public ContainerRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity) + { + tileEntity = tentity; addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 5, 25)); addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 5, 56)); - addSlotToContainer(new Slot(tentity, 2, 155, 25)); - addSlotToContainer(new SlotOutput(tentity, 3, 155, 56)); - addSlotToContainer(new SlotDischarge(tentity, 4, 155, 5)); - - int slotX; + addSlotToContainer(new Slot(tentity, 2, 155, 25)); + addSlotToContainer(new SlotOutput(tentity, 3, 155, 56)); + addSlotToContainer(new SlotDischarge(tentity, 4, 155, 5)); - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + int slotX; - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 4) - { - if(!mergeItemStack(slotStack, 4, 5, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack)) - { - if(slotID != 2 && slotID != 3) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1) - { - if(((IGasItem)slotStack.getItem()).canProvideGas(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(((IGasItem)slotStack.getItem()).canReceiveGas(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 5 && slotID <= 31) - { - if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 31) - { - if(!mergeItemStack(slotStack, 5, 31, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 4) + { + if(!mergeItemStack(slotStack, 4, 5, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack)) + { + if(slotID != 2 && slotID != 3) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof IGasItem) + { + if(slotID != 0 && slotID != 1) + { + if(((IGasItem)slotStack.getItem()).canProvideGas(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null)) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(((IGasItem)slotStack.getItem()).canReceiveGas(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null)) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 5 && slotID <= 31) + { + if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 31) + { + if(!mergeItemStack(slotStack, 5, 31, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerSalinationController.java b/common/mekanism/common/inventory/container/ContainerSalinationController.java index 01e23483a..8f341944e 100644 --- a/common/mekanism/common/inventory/container/ContainerSalinationController.java +++ b/common/mekanism/common/inventory/container/ContainerSalinationController.java @@ -13,142 +13,142 @@ import net.minecraftforge.fluids.FluidRegistry; public class ContainerSalinationController extends Container { - private TileEntitySalinationController tileEntity; + private TileEntitySalinationController tileEntity; - public ContainerSalinationController(InventoryPlayer inventory, TileEntitySalinationController tentity) - { - tileEntity = tentity; - - addSlotToContainer(new Slot(tentity, 0, 28, 20)); - addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); - addSlotToContainer(new Slot(tentity, 2, 132, 20)); - addSlotToContainer(new SlotOutput(tentity, 3, 132, 51)); - - int slotY; + public ContainerSalinationController(InventoryPlayer inventory, TileEntitySalinationController tentity) + { + tileEntity = tentity; - for(slotY = 0; slotY < 3; ++slotY) - { - for(int slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + addSlotToContainer(new Slot(tentity, 0, 28, 20)); + addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); + addSlotToContainer(new Slot(tentity, 2, 132, 20)); + addSlotToContainer(new SlotOutput(tentity, 3, 132, 51)); - for(slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.close(entityplayer); - tileEntity.closeChest(); - } + int slotY; + + for(slotY = 0; slotY < 3; ++slotY) + { + for(int slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); + } + } + + for(slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeChest(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(slotID == 1 || slotID == 3) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - else if(FluidContainerRegistry.isEmptyContainer(slotStack)) - { - if(slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else if(slotID == 2) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(FluidContainerRegistry.isFilledContainer(slotStack) && FluidContainerRegistry.getFluidForFilledItem(slotStack).getFluid() == FluidRegistry.WATER) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if(slotID == 1 || slotID == 3) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + else if(FluidContainerRegistry.isEmptyContainer(slotStack)) + { + if(slotID != 2) + { + if(!mergeItemStack(slotStack, 2, 3, false)) + { + return null; + } + } + else if(slotID == 2) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else if(FluidContainerRegistry.isFilledContainer(slotStack) && FluidContainerRegistry.getFluidForFilledItem(slotStack).getFluid() == FluidRegistry.WATER) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(slotID == 0) + { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 4 && slotID <= 30) + { + if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 30) + { + if(!mergeItemStack(slotStack, 4, 30, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/container/ContainerTeleporter.java b/common/mekanism/common/inventory/container/ContainerTeleporter.java index 22ba34452..30f42e4ad 100644 --- a/common/mekanism/common/inventory/container/ContainerTeleporter.java +++ b/common/mekanism/common/inventory/container/ContainerTeleporter.java @@ -11,113 +11,113 @@ import net.minecraft.item.ItemStack; public class ContainerTeleporter extends Container { - private TileEntityTeleporter tileEntity; + private TileEntityTeleporter tileEntity; - public ContainerTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotDischarge(tentity, 0, 27, 14)); - int slotX; + public ContainerTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) + { + tileEntity = tentity; + addSlotToContainer(new SlotDischarge(tentity, 0, 27, 14)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.open(inventory.player); - tileEntity.openChest(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.open(inventory.player); + tileEntity.openChest(); + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); - + tileEntity.close(entityplayer); tileEntity.closeChest(); - } + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } - + return tileEntity.isUseableByPlayer(entityplayer); + } + @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if(ChargeUtils.canBeDischarged(slotStack)) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(slotID == 0) + { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 1 && slotID <= 27) + { + if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 27) + { + if(!mergeItemStack(slotStack, 1, 27, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) + { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/common/inventory/slot/SlotElectricChest.java b/common/mekanism/common/inventory/slot/SlotElectricChest.java index 1f6c66398..87249361e 100644 --- a/common/mekanism/common/inventory/slot/SlotElectricChest.java +++ b/common/mekanism/common/inventory/slot/SlotElectricChest.java @@ -13,17 +13,17 @@ public class SlotElectricChest extends Slot { super(inventory, index, x, y); } - + @Override - public boolean canTakeStack(EntityPlayer par1EntityPlayer) - { + public boolean canTakeStack(EntityPlayer par1EntityPlayer) + { ItemStack itemstack = inventory.getStackInSlot(getSlotIndex()); - + if(itemstack == null) { return true; } - + if(itemstack.getItem() instanceof IElectricChest) { if(MachineType.get(itemstack) == MachineType.ELECTRIC_CHEST) @@ -31,7 +31,7 @@ public class SlotElectricChest extends Slot return false; } } - + return true; - } + } } diff --git a/common/mekanism/common/inventory/slot/SlotEnergy.java b/common/mekanism/common/inventory/slot/SlotEnergy.java index 043827997..370bcc29e 100644 --- a/common/mekanism/common/inventory/slot/SlotEnergy.java +++ b/common/mekanism/common/inventory/slot/SlotEnergy.java @@ -13,21 +13,21 @@ public class SlotEnergy { super(inventory, index, x, y); } - + @Override public boolean isItemValid(ItemStack itemstack) { return ChargeUtils.canBeCharged(itemstack); } } - + public static class SlotDischarge extends Slot { public SlotDischarge(IInventory inventory, int index, int x, int y) { super(inventory, index, x, y); } - + @Override public boolean isItemValid(ItemStack itemstack) { diff --git a/common/mekanism/common/inventory/slot/SlotMachineUpgrade.java b/common/mekanism/common/inventory/slot/SlotMachineUpgrade.java index 0a8504406..a7ca6acd4 100644 --- a/common/mekanism/common/inventory/slot/SlotMachineUpgrade.java +++ b/common/mekanism/common/inventory/slot/SlotMachineUpgrade.java @@ -11,7 +11,7 @@ public class SlotMachineUpgrade extends Slot { super(inventory, index, x, y); } - + @Override public boolean isItemValid(ItemStack itemstack) { diff --git a/common/mekanism/common/inventory/slot/SlotOutput.java b/common/mekanism/common/inventory/slot/SlotOutput.java index 4f342f8c0..398db49ce 100644 --- a/common/mekanism/common/inventory/slot/SlotOutput.java +++ b/common/mekanism/common/inventory/slot/SlotOutput.java @@ -10,7 +10,7 @@ public class SlotOutput extends Slot { super(inventory, index, x, y); } - + @Override public boolean isItemValid(ItemStack itemstack) { diff --git a/common/mekanism/common/inventory/slot/SlotStorageTank.java b/common/mekanism/common/inventory/slot/SlotStorageTank.java index 3b5890112..7edc5e1c9 100644 --- a/common/mekanism/common/inventory/slot/SlotStorageTank.java +++ b/common/mekanism/common/inventory/slot/SlotStorageTank.java @@ -10,27 +10,27 @@ public class SlotStorageTank extends Slot { public Gas type; public boolean acceptsAllGasses; - + public SlotStorageTank(IInventory inventory, Gas gas, boolean all, int index, int x, int y) { super(inventory, index, x, y); type = gas; acceptsAllGasses = all; } - + @Override public boolean isItemValid(ItemStack itemstack) { - if(acceptsAllGasses) + if(acceptsAllGasses) { return itemstack.getItem() instanceof IGasItem; } - + if(itemstack.getItem() instanceof IGasItem) { return ((IGasItem)itemstack.getItem()).getGas(itemstack) == null || ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == type; } - + return false; } } diff --git a/common/mekanism/common/item/ItemAtomicDisassembler.java b/common/mekanism/common/item/ItemAtomicDisassembler.java index 79f7bf2f1..90711d090 100644 --- a/common/mekanism/common/item/ItemAtomicDisassembler.java +++ b/common/mekanism/common/item/ItemAtomicDisassembler.java @@ -27,135 +27,135 @@ public class ItemAtomicDisassembler extends ItemEnergized { public double ENERGY_USAGE = 10; public double HOE_USAGE = 100; - + public ItemAtomicDisassembler(int id) { super(id, 1000000, 120); } - + @Override public void registerIcons(IconRegister register) {} - - @Override - public boolean canHarvestBlock(Block block) - { - return block != Block.bedrock; - } - - @Override + + @Override + public boolean canHarvestBlock(Block block) + { + return block != Block.bedrock; + } + + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - super.addInformation(itemstack, entityplayer, list, flag); - - list.add("Mode: " + EnumColor.INDIGO + (getMode(itemstack) == 0 ? "normal" : "vein")); - list.add("Efficiency: " + EnumColor.INDIGO + getEfficiency(itemstack)); + super.addInformation(itemstack, entityplayer, list, flag); + + list.add("Mode: " + EnumColor.INDIGO + (getMode(itemstack) == 0 ? "normal" : "vein")); + list.add("Efficiency: " + EnumColor.INDIGO + getEfficiency(itemstack)); } - - @Override - public boolean hitEntity(ItemStack itemstack, EntityLivingBase hitEntity, EntityLivingBase player) - { - if(getEnergy(itemstack) > 0) - { + + @Override + public boolean hitEntity(ItemStack itemstack, EntityLivingBase hitEntity, EntityLivingBase player) + { + if(getEnergy(itemstack) > 0) + { hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 20); setEnergy(itemstack, getEnergy(itemstack) - 2000); - } - else { - hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 4); - } - - return false; - } - - @Override - public float getStrVsBlock(ItemStack itemstack, Block block) - { - return getEnergy(itemstack) != 0 ? getEfficiency(itemstack) : 1F; - } - - @Override - public boolean onBlockDestroyed(ItemStack itemstack, World world, int id, int x, int y, int z, EntityLivingBase entityliving) - { - if(Block.blocksList[id].getBlockHardness(world, x, y, z) != 0.0D) - { - setEnergy(itemstack, getEnergy(itemstack) - (ENERGY_USAGE*getEfficiency(itemstack))); - } - else { - setEnergy(itemstack, getEnergy(itemstack) - (ENERGY_USAGE*(getEfficiency(itemstack))/2)); - } + } + else { + hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 4); + } - return true; - } - - @Override - public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) - { - super.onBlockStartBreak(itemstack, x, y, z, player); - - if(!player.worldObj.isRemote) - { - int id = player.worldObj.getBlockId(x, y, z); - int meta = player.worldObj.getBlockMetadata(x, y, z); - - ItemStack stack = new ItemStack(id, 1, meta); - Coord4D orig = new Coord4D(x, y, z, player.worldObj.provider.dimensionId); - - List names = MekanismUtils.getOreDictName(stack); - - boolean isOre = false; - - for(String s : names) - { - if(s.contains("ore")) - { - isOre = true; - } - } - - if(getMode(itemstack) == 3 && isOre && !player.capabilities.isCreativeMode) - { - Set found = new Finder(player.worldObj, stack, new Coord4D(x, y, z, player.worldObj.provider.dimensionId)).calc(); - - for(Coord4D coord : found) - { - if(coord.equals(orig) || getEnergy(itemstack) < (ENERGY_USAGE*getEfficiency(itemstack))) - { - continue; - } - - Block block = coord.getBlock(player.worldObj); - - block.onBlockDestroyedByPlayer(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, meta); - player.worldObj.playAuxSFXAtEntity(null, 2001, coord.xCoord, coord.yCoord, coord.zCoord, id + (meta << 12)); - player.worldObj.setBlockToAir(coord.xCoord, coord.yCoord, coord.zCoord); - block.breakBlock(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, id, meta); - block.dropBlockAsItem(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, meta, 0); - - setEnergy(itemstack, getEnergy(itemstack) - (ENERGY_USAGE*getEfficiency(itemstack))); - } - } - } - - return false; - } - - @Override - public boolean isFull3D() - { - return true; - } - - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { + return false; + } + + @Override + public float getStrVsBlock(ItemStack itemstack, Block block) + { + return getEnergy(itemstack) != 0 ? getEfficiency(itemstack) : 1F; + } + + @Override + public boolean onBlockDestroyed(ItemStack itemstack, World world, int id, int x, int y, int z, EntityLivingBase entityliving) + { + if(Block.blocksList[id].getBlockHardness(world, x, y, z) != 0.0D) + { + setEnergy(itemstack, getEnergy(itemstack) - (ENERGY_USAGE*getEfficiency(itemstack))); + } + else { + setEnergy(itemstack, getEnergy(itemstack) - (ENERGY_USAGE*(getEfficiency(itemstack))/2)); + } + + return true; + } + + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) + { + super.onBlockStartBreak(itemstack, x, y, z, player); + + if(!player.worldObj.isRemote) + { + int id = player.worldObj.getBlockId(x, y, z); + int meta = player.worldObj.getBlockMetadata(x, y, z); + + ItemStack stack = new ItemStack(id, 1, meta); + Coord4D orig = new Coord4D(x, y, z, player.worldObj.provider.dimensionId); + + List names = MekanismUtils.getOreDictName(stack); + + boolean isOre = false; + + for(String s : names) + { + if(s.contains("ore")) + { + isOre = true; + } + } + + if(getMode(itemstack) == 3 && isOre && !player.capabilities.isCreativeMode) + { + Set found = new Finder(player.worldObj, stack, new Coord4D(x, y, z, player.worldObj.provider.dimensionId)).calc(); + + for(Coord4D coord : found) + { + if(coord.equals(orig) || getEnergy(itemstack) < (ENERGY_USAGE*getEfficiency(itemstack))) + { + continue; + } + + Block block = coord.getBlock(player.worldObj); + + block.onBlockDestroyedByPlayer(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, meta); + player.worldObj.playAuxSFXAtEntity(null, 2001, coord.xCoord, coord.yCoord, coord.zCoord, id + (meta << 12)); + player.worldObj.setBlockToAir(coord.xCoord, coord.yCoord, coord.zCoord); + block.breakBlock(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, id, meta); + block.dropBlockAsItem(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, meta, 0); + + setEnergy(itemstack, getEnergy(itemstack) - (ENERGY_USAGE*getEfficiency(itemstack))); + } + } + } + + return false; + } + + @Override + public boolean isFull3D() + { + return true; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { if(!world.isRemote && entityplayer.isSneaking()) { toggleMode(itemstack); - entityplayer.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Mode toggled to " + EnumColor.INDIGO + getModeName(itemstack) + EnumColor.AQUA + " (" + getEfficiency(itemstack) + ")"); + entityplayer.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Mode toggled to " + EnumColor.INDIGO + getModeName(itemstack) + EnumColor.AQUA + " (" + getEfficiency(itemstack) + ")"); } - - return itemstack; - } - + + return itemstack; + } + @Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { @@ -168,7 +168,7 @@ public class ItemAtomicDisassembler extends ItemEnergized return false; } } - + switch(getEfficiency(stack)) { case 20: @@ -179,7 +179,7 @@ public class ItemAtomicDisassembler extends ItemEnergized useHoe(stack, player, world, x1, y, z1, side); } } - + break; case 128: for(int x1 = x-2; x1 <= x+2; x1++) @@ -189,181 +189,181 @@ public class ItemAtomicDisassembler extends ItemEnergized useHoe(stack, player, world, x1, y, z1, side); } } - + break; } - + return true; } - - return false; - } - + + return false; + } + private boolean useHoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) { if(!player.canPlayerEdit(x, y, z, side, stack)) - { - return false; - } - else { - UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); - - if(MinecraftForge.EVENT_BUS.post(event)) - { - return false; - } + { + return false; + } + else { + UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); - if(event.getResult() == Result.ALLOW) - { - setEnergy(stack, getEnergy(stack)-HOE_USAGE); - return true; - } + if(MinecraftForge.EVENT_BUS.post(event)) + { + return false; + } - int id = world.getBlockId(x, y, z); - boolean air = world.isAirBlock(x, y + 1, z); + if(event.getResult() == Result.ALLOW) + { + setEnergy(stack, getEnergy(stack)-HOE_USAGE); + return true; + } - if(side != 0 && air && (id == Block.grass.blockID || id == Block.dirt.blockID)) - { - Block block = Block.tilledField; - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + int id = world.getBlockId(x, y, z); + boolean air = world.isAirBlock(x, y + 1, z); - if(world.isRemote) - { - return true; - } - else { - world.setBlock(x, y, z, block.blockID); - setEnergy(stack, getEnergy(stack)-HOE_USAGE); - return true; - } - } - else { - return false; - } - } + if(side != 0 && air && (id == Block.grass.blockID || id == Block.dirt.blockID)) + { + Block block = Block.tilledField; + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + + if(world.isRemote) + { + return true; + } + else { + world.setBlock(x, y, z, block.blockID); + setEnergy(stack, getEnergy(stack)-HOE_USAGE); + return true; + } + } + else { + return false; + } + } } - - public int getEfficiency(ItemStack itemStack) - { - switch(getMode(itemStack)) - { - case 0: - return 20; - case 1: - return 8; - case 2: - return 128; - case 3: - return 20; - case 4: - return 0; - } - - return 0; - } - - public int getMode(ItemStack itemStack) - { + + public int getEfficiency(ItemStack itemStack) + { + switch(getMode(itemStack)) + { + case 0: + return 20; + case 1: + return 8; + case 2: + return 128; + case 3: + return 20; + case 4: + return 0; + } + + return 0; + } + + public int getMode(ItemStack itemStack) + { if(itemStack.stackTagCompound == null) { return 0; } - + return itemStack.stackTagCompound.getInteger("mode"); - } - - public String getModeName(ItemStack itemStack) - { - int mode = getMode(itemStack); - - switch(mode) - { - case 0: - return "normal"; - case 1: - return "slow"; - case 2: - return "fast"; - case 3: - return "vein"; - case 4: - return "off"; - } - - return null; - } - - public void toggleMode(ItemStack itemStack) - { + } + + public String getModeName(ItemStack itemStack) + { + int mode = getMode(itemStack); + + switch(mode) + { + case 0: + return "normal"; + case 1: + return "slow"; + case 2: + return "fast"; + case 3: + return "vein"; + case 4: + return "off"; + } + + return null; + } + + public void toggleMode(ItemStack itemStack) + { if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setInteger("mode", getMode(itemStack) < 4 ? getMode(itemStack)+1 : 0); - } - - @Override + } + + @Override public boolean canSend(ItemStack itemStack) { return false; } - - public static class Finder - { - public World world; - - public ItemStack stack; - - public Coord4D location; - - public Set found = new HashSet(); - - public static Map> ignoreID = new HashMap>(); - - public Finder(World w, ItemStack s, Coord4D loc) - { - world = w; - stack = s; - location = loc; - } - - public void loop(Coord4D pointer) - { - if(found.contains(pointer) || found.size() > 128) - { - return; - } - - found.add(pointer); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = pointer.getFromSide(side); - - if(coord.exists(world) && checkID(coord.getBlockId(world)) && coord.getMetadata(world) == stack.getItemDamage()) - { - loop(coord); - } - } - } - - public Set calc() - { - loop(location); - - return found; - } - - public boolean checkID(int id) - { - int origId = location.getBlockId(world); - return (ignoreID.get(origId) == null && id == origId) || (ignoreID.get(origId) != null && ignoreID.get(origId).contains(id)); - } - - static { - ignoreID.put(Block.oreRedstone.blockID, ListUtils.asList(Block.oreRedstone.blockID, Block.oreRedstoneGlowing.blockID)); - ignoreID.put(Block.oreRedstoneGlowing.blockID, ListUtils.asList(Block.oreRedstone.blockID, Block.oreRedstoneGlowing.blockID)); - } - } + + public static class Finder + { + public World world; + + public ItemStack stack; + + public Coord4D location; + + public Set found = new HashSet(); + + public static Map> ignoreID = new HashMap>(); + + public Finder(World w, ItemStack s, Coord4D loc) + { + world = w; + stack = s; + location = loc; + } + + public void loop(Coord4D pointer) + { + if(found.contains(pointer) || found.size() > 128) + { + return; + } + + found.add(pointer); + + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + { + Coord4D coord = pointer.getFromSide(side); + + if(coord.exists(world) && checkID(coord.getBlockId(world)) && coord.getMetadata(world) == stack.getItemDamage()) + { + loop(coord); + } + } + } + + public Set calc() + { + loop(location); + + return found; + } + + public boolean checkID(int id) + { + int origId = location.getBlockId(world); + return (ignoreID.get(origId) == null && id == origId) || (ignoreID.get(origId) != null && ignoreID.get(origId).contains(id)); + } + + static { + ignoreID.put(Block.oreRedstone.blockID, ListUtils.asList(Block.oreRedstone.blockID, Block.oreRedstoneGlowing.blockID)); + ignoreID.put(Block.oreRedstoneGlowing.blockID, ListUtils.asList(Block.oreRedstone.blockID, Block.oreRedstoneGlowing.blockID)); + } + } } diff --git a/common/mekanism/common/item/ItemBalloon.java b/common/mekanism/common/item/ItemBalloon.java index 7811d11e9..01a654400 100644 --- a/common/mekanism/common/item/ItemBalloon.java +++ b/common/mekanism/common/item/ItemBalloon.java @@ -25,19 +25,19 @@ public class ItemBalloon extends ItemMekanism super(id); setHasSubtypes(true); } - + public EnumColor getColor(ItemStack stack) { return EnumColor.DYES[stack.getItemDamage()]; } - + @Override public void getSubItems(int id, CreativeTabs tabs, List list) { for(int i = 0; i < EnumColor.DYES.length; i++) { EnumColor color = EnumColor.DYES[i]; - + if(color != null) { ItemStack stack = new ItemStack(this); @@ -46,7 +46,7 @@ public class ItemBalloon extends ItemMekanism } } } - + @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { @@ -57,78 +57,78 @@ public class ItemBalloon extends ItemMekanism pos.xPos -= 0.4; pos.rotateYaw(entityplayer.renderYawOffset); pos.translate(new Pos3D(entityplayer)); - + world.spawnEntityInWorld(new EntityBalloon(world, pos.xPos-0.5, pos.yPos-0.25, pos.zPos-0.5, getColor(itemstack))); } - + itemstack.stackSize--; - + return itemstack; } - + @Override public String getItemDisplayName(ItemStack stack) { String color = getColor(stack).getName(); - + if(getColor(stack) == EnumColor.BLACK) { color = EnumColor.DARK_GREY + getColor(stack).getLocalizedName(); } - + return color + " " + MekanismUtils.localize("tooltip.balloon"); } - + @Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if(player.isSneaking()) { AxisAlignedBB bound = AxisAlignedBB.getBoundingBox(x, y, z, x+1, y+3, z+1); - + List balloonsNear = player.worldObj.getEntitiesWithinAABB(EntityBalloon.class, bound); - + if(balloonsNear.size() > 0) { return true; } - + Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId); - + if(Block.blocksList[obj.getBlockId(world)].isBlockReplaceable(world, x, y, z)) { obj.yCoord--; } - + if(canReplace(world, obj.xCoord, obj.yCoord+1, obj.zCoord) && canReplace(world, obj.xCoord, obj.yCoord+2, obj.zCoord)) { world.setBlockToAir(obj.xCoord, obj.yCoord+1, obj.zCoord); world.setBlockToAir(obj.xCoord, obj.yCoord+2, obj.zCoord); - + if(!world.isRemote) { world.spawnEntityInWorld(new EntityBalloon(world, obj, getColor(stack))); stack.stackSize--; } } - + return true; } - + return false; } - + @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) - { + public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) + { if(player.isSneaking()) - { + { if(!player.worldObj.isRemote) { AxisAlignedBB bound = AxisAlignedBB.getBoundingBox(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, entity.posX + 0.2, entity.posY + entity.ySize + 4, entity.posZ + 0.2); - + List balloonsNear = player.worldObj.getEntitiesWithinAABB(EntityBalloon.class, bound); - + for(EntityBalloon balloon : balloonsNear) { if(balloon.latchedEntity == entity) @@ -136,22 +136,22 @@ public class ItemBalloon extends ItemMekanism return true; } } - + player.worldObj.spawnEntityInWorld(new EntityBalloon(entity, getColor(stack))); stack.stackSize--; } - + return true; } - - return false; - } - + + return false; + } + private boolean canReplace(World world, int x, int y, int z) { return world.isAirBlock(x, y, z) || Block.blocksList[world.getBlockId(x, y, z)].isBlockReplaceable(world, x, y, z); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} diff --git a/common/mekanism/common/item/ItemBlockBasic.java b/common/mekanism/common/item/ItemBlockBasic.java index b8c9a7730..e87330d96 100644 --- a/common/mekanism/common/item/ItemBlockBasic.java +++ b/common/mekanism/common/item/ItemBlockBasic.java @@ -40,14 +40,14 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemBlockBasic extends ItemBlock { public Block metaBlock; - + public ItemBlockBasic(int id, Block block) { super(id); metaBlock = block; setHasSubtypes(true); } - + @Override public int getItemStackLimit(ItemStack stack) { @@ -58,22 +58,22 @@ public class ItemBlockBasic extends ItemBlock return 1; } } - + return 64; } - + @Override public int getMetadata(int i) { return i; } - + @Override public Icon getIconFromDamage(int i) { return metaBlock.getIcon(2, i); } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) @@ -81,7 +81,7 @@ public class ItemBlockBasic extends ItemBlock if(itemID == Mekanism.basicBlockID && itemstack.getItemDamage() == 6) { InventoryBin inv = new InventoryBin(itemstack); - + if(inv.getItemCount() > 0) { list.add(EnumColor.BRIGHT_GREEN + inv.getItemType().getDisplayName()); @@ -92,13 +92,13 @@ public class ItemBlockBasic extends ItemBlock } } } - + @Override public boolean hasContainerItem() { return true; //TODO forge PR } - + @Override public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) { @@ -109,15 +109,15 @@ public class ItemBlockBasic extends ItemBlock return true; } } - + if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("newCount")) { return true; } - + return false; } - + @Override public ItemStack getContainerItemStack(ItemStack stack) { @@ -128,45 +128,45 @@ public class ItemBlockBasic extends ItemBlock return ItemProxy.getDead(); } } - + ItemStack ret = stack.copy(); ret.stackTagCompound.setInteger("itemCount", stack.stackTagCompound.getInteger("newCount")); - + return ret; } - + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); - - if(place) - { - if(itemID == Mekanism.basicBlockID) - { - if(stack.getItemDamage() == 6 && stack.stackTagCompound != null) - { - TileEntityBin tileEntity = (TileEntityBin)world.getBlockTileEntity(x, y, z); - InventoryBin inv = new InventoryBin(stack); - - if(inv.getItemType() != null) - { - tileEntity.setItemType(inv.getItemType()); - } - - tileEntity.setItemCount(inv.getItemCount()); - } - } - } - - return place; - } - + { + boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + + if(place) + { + if(itemID == Mekanism.basicBlockID) + { + if(stack.getItemDamage() == 6 && stack.stackTagCompound != null) + { + TileEntityBin tileEntity = (TileEntityBin)world.getBlockTileEntity(x, y, z); + InventoryBin inv = new InventoryBin(stack); + + if(inv.getItemType() != null) + { + tileEntity.setItemType(inv.getItemType()); + } + + tileEntity.setItemCount(inv.getItemCount()); + } + } + } + + return place; + } + @Override public String getUnlocalizedName(ItemStack itemstack) { String name = ""; - + if(itemID == Mekanism.basicBlockID) { switch(itemstack.getItemDamage()) @@ -233,7 +233,7 @@ public class ItemBlockBasic extends ItemBlock break; } } - + return getUnlocalizedName() + "." + name; } } diff --git a/common/mekanism/common/item/ItemBlockCardboardBox.java b/common/mekanism/common/item/ItemBlockCardboardBox.java index 3f18a808e..525ed356e 100644 --- a/common/mekanism/common/item/ItemBlockCardboardBox.java +++ b/common/mekanism/common/item/ItemBlockCardboardBox.java @@ -25,139 +25,139 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemBlockCardboardBox extends ItemBlock { private static boolean isMonitoring; - + public Block metaBlock; - + public ItemBlockCardboardBox(int id, Block block) { super(id); setMaxStackSize(1); metaBlock = block; - + MinecraftForge.EVENT_BUS.register(this); } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { list.add(EnumColor.INDIGO + "Block data: " + (getBlockData(itemstack) != null ? "Yes" : "No")); - + if(getBlockData(itemstack) != null) { list.add("Block ID: " + getBlockData(itemstack).id); list.add("Metadata: " + getBlockData(itemstack).meta); - + if(getBlockData(itemstack).tileTag != null) { list.add("Tile: " + getBlockData(itemstack).tileTag.getString("id")); } } } - + @Override public int getMetadata(int i) { return i; } - + @Override public Icon getIconFromDamage(int i) { return metaBlock.getIcon(2, i); } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { if(!player.isSneaking() && !world.isAirBlock(x, y, z) && stack.getItemDamage() == 0) { int id = world.getBlockId(x, y, z); int meta = world.getBlockMetadata(x, y, z); - - if(!world.isRemote && MekanismAPI.isBlockCompatible(id, meta)) - { - BlockData data = new BlockData(); - data.id = id; - data.meta = meta; - - isMonitoring = true; - - if(world.getBlockTileEntity(x, y, z) != null) - { - TileEntity tile = world.getBlockTileEntity(x, y, z); - NBTTagCompound tag = new NBTTagCompound(); - - tile.writeToNBT(tag); - data.tileTag = tag; - } - - if(!player.capabilities.isCreativeMode) - { - stack.stackSize--; - } - - world.setBlock(x, y, z, Mekanism.cardboardBoxID, 1, 3); - - isMonitoring = false; - - TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getBlockTileEntity(x, y, z); - - if(tileEntity != null) - { - tileEntity.storedData = data; - } - - return true; - } + + if(!world.isRemote && MekanismAPI.isBlockCompatible(id, meta)) + { + BlockData data = new BlockData(); + data.id = id; + data.meta = meta; + + isMonitoring = true; + + if(world.getBlockTileEntity(x, y, z) != null) + { + TileEntity tile = world.getBlockTileEntity(x, y, z); + NBTTagCompound tag = new NBTTagCompound(); + + tile.writeToNBT(tag); + data.tileTag = tag; + } + + if(!player.capabilities.isCreativeMode) + { + stack.stackSize--; + } + + world.setBlock(x, y, z, Mekanism.cardboardBoxID, 1, 3); + + isMonitoring = false; + + TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getBlockTileEntity(x, y, z); + + if(tileEntity != null) + { + tileEntity.storedData = data; + } + + return true; + } } - - return false; - } - + + return false; + } + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { + { if(world.isRemote) { return true; } - - boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); - - if(place) - { - TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getBlockTileEntity(x, y, z); - + + boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + + if(place) + { + TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getBlockTileEntity(x, y, z); + if(tileEntity != null) { tileEntity.storedData = getBlockData(stack); } - } - - return place; - } + } - public void setBlockData(ItemStack itemstack, BlockData data) - { + return place; + } + + public void setBlockData(ItemStack itemstack, BlockData data) + { if(itemstack.stackTagCompound == null) { itemstack.setTagCompound(new NBTTagCompound()); } - - itemstack.stackTagCompound.setCompoundTag("blockData", data.write(new NBTTagCompound())); - } - public BlockData getBlockData(ItemStack itemstack) - { + itemstack.stackTagCompound.setCompoundTag("blockData", data.write(new NBTTagCompound())); + } + + public BlockData getBlockData(ItemStack itemstack) + { if(itemstack.stackTagCompound == null || !itemstack.stackTagCompound.hasKey("blockData")) { return null; } - + return BlockData.read(itemstack.stackTagCompound.getCompoundTag("blockData")); - } - + } + @ForgeSubscribe public void onEntitySpawn(EntityJoinWorldEvent event) { diff --git a/common/mekanism/common/item/ItemBlockEnergyCube.java b/common/mekanism/common/item/ItemBlockEnergyCube.java index 08c919cad..373e8c9a0 100644 --- a/common/mekanism/common/item/ItemBlockEnergyCube.java +++ b/common/mekanism/common/item/ItemBlockEnergyCube.java @@ -36,7 +36,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IEnergyCube, ISpecialElectricItem, ISustainedInventory, IEnergyContainerItem { public Block metaBlock; - + public ItemBlockEnergyCube(int id, Block block) { super(id); @@ -46,7 +46,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE setNoRepair(); setCreativeTab(Mekanism.tabMekanism); } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) @@ -60,7 +60,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } } - + public ItemStack getUnchargedItem(EnergyCubeTier tier) { ItemStack charged = new ItemStack(this); @@ -68,53 +68,53 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE charged.setItemDamage(100); return charged; } - + @Override public String getUnlocalizedName(ItemStack itemstack) { return getUnlocalizedName() + "." + getEnergyCubeTier(itemstack).name; } - + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); - - if(place) - { - TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); - tileEntity.tier = ((IEnergyCube)stack.getItem()).getEnergyCubeTier(stack); - tileEntity.electricityStored = getEnergy(stack); - - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); - - if(!world.isRemote) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList()))); - } - } - - return place; - } + { + boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + + if(place) + { + TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); + tileEntity.tier = ((IEnergyCube)stack.getItem()).getEnergyCubeTier(stack); + tileEntity.electricityStored = getEnergy(stack); + + ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); + + if(!world.isRemote) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList()))); + } + } + + return place; + } @Override public EnergyCubeTier getEnergyCubeTier(ItemStack itemstack) { if(itemstack.stackTagCompound == null) - { - return EnergyCubeTier.BASIC; + { + return EnergyCubeTier.BASIC; } - + if(itemstack.stackTagCompound.getString("tier") == null) { return EnergyCubeTier.BASIC; } - + return EnergyCubeTier.getFromName(itemstack.stackTagCompound.getString("tier")); } @Override - public void setEnergyCubeTier(ItemStack itemstack, EnergyCubeTier tier) + public void setEnergyCubeTier(ItemStack itemstack, EnergyCubeTier tier) { if(itemstack.stackTagCompound == null) { @@ -123,7 +123,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE itemstack.stackTagCompound.setString("tier", tier.name); } - + @Override public boolean canProvideEnergy(ItemStack itemStack) { @@ -159,57 +159,57 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE { return 0; } - + @Override - public void setInventory(NBTTagList nbtTags, Object... data) + public void setInventory(NBTTagList nbtTags, Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - + if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setTag("Items", nbtTags); } } @Override - public NBTTagList getInventory(Object... data) + public NBTTagList getInventory(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - - if(itemStack.stackTagCompound == null) - { - return null; + + if(itemStack.stackTagCompound == null) + { + return null; } - + return itemStack.stackTagCompound.getTagList("Items"); } - + return null; } - + @Override - public double getEnergy(ItemStack itemStack) + public double getEnergy(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 0; + if(itemStack.stackTagCompound == null) + { + return 0; } - + double electricityStored = itemStack.stackTagCompound.getDouble("electricity"); itemStack.setItemDamage((int)Math.max(1, (Math.abs(((electricityStored/getMaxEnergy(itemStack))*100)-100)))); - + return electricityStored; } @Override - public void setEnergy(ItemStack itemStack, double amount) + public void setEnergy(ItemStack itemStack, double amount) { if(itemStack.stackTagCompound == null) { @@ -222,19 +222,19 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE } @Override - public double getMaxEnergy(ItemStack itemStack) + public double getMaxEnergy(ItemStack itemStack) { return getEnergyCubeTier(itemStack).MAX_ELECTRICITY; } @Override - public double getMaxTransfer(ItemStack itemStack) + public double getMaxTransfer(ItemStack itemStack) { return getMaxEnergy(itemStack)*0.005; } @Override - public boolean canReceive(ItemStack itemStack) + public boolean canReceive(ItemStack itemStack) { return true; } @@ -244,7 +244,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE { return true; } - + @Override public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) { @@ -252,34 +252,34 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE { double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - + return (int)Math.round(toReceive*Mekanism.TO_TE); } - + return 0; } @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if(canSend(theItem)) { double energyRemaining = getEnergy(theItem); double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - + return (int)Math.round(toSend*Mekanism.TO_TE); } - + return 0; } @@ -294,15 +294,15 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IE { return (int)(getMaxEnergy(theItem)*Mekanism.TO_TE); } - + @Override public boolean isMetadataSpecific() { return false; } - + @Override - public IElectricItemManager getManager(ItemStack itemStack) + public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); } diff --git a/common/mekanism/common/item/ItemBlockGasTank.java b/common/mekanism/common/item/ItemBlockGasTank.java index 24dfe9169..4475bdb92 100644 --- a/common/mekanism/common/item/ItemBlockGasTank.java +++ b/common/mekanism/common/item/ItemBlockGasTank.java @@ -25,13 +25,13 @@ import org.lwjgl.input.Keyboard; public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedInventory { public Block metaBlock; - + /** The maximum amount of gas this tank can hold. */ public int MAX_GAS = 96000; - + /** How fast this tank can transfer gas. */ public static final int TRANSFER_RATE = 16; - + public ItemBlockGasTank(int id, Block block) { super(id); @@ -42,46 +42,46 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI setNoRepair(); setCreativeTab(Mekanism.tabMekanism); } - + @Override public int getMetadata(int i) { return i; } - + @Override public Icon getIconFromDamage(int i) { return metaBlock.getIcon(2, i); } - + @Override public String getUnlocalizedName(ItemStack itemstack) { return getUnlocalizedName() + "." + "GasTank"; } - + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); - - if(place) - { - TileEntityGasTank tileEntity = (TileEntityGasTank)world.getBlockTileEntity(x, y, z); - tileEntity.gasTank.setGas(getGas(stack)); - - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); - } - - return place; - } - + { + boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + + if(place) + { + TileEntityGasTank tileEntity = (TileEntityGasTank)world.getBlockTileEntity(x, y, z); + tileEntity.gasTank.setGas(getGas(stack)); + + ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); + } + + return place; + } + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { GasStack gasStack = getGas(itemstack); - + if(gasStack == null) { list.add("No gas stored."); @@ -89,7 +89,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI else { list.add("Stored " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); } - + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for more details."); @@ -98,13 +98,13 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } } - + @Override public void onCreated(ItemStack itemstack, World world, EntityPlayer entityplayer) { itemstack = getEmptyItem(); } - + @Override public GasStack getGas(ItemStack itemstack) { @@ -112,9 +112,9 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI { return null; } - + GasStack stored = GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); - + if(stored == null) { itemstack.setItemDamage(100); @@ -122,10 +122,10 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI else { itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored.amount/getMaxGas(itemstack))*100)-100)))); } - + return stored; } - + @Override public void setGas(ItemStack itemstack, GasStack stack) { @@ -133,7 +133,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI { itemstack.setTagCompound(new NBTTagCompound()); } - + if(stack == null || stack.amount == 0) { itemstack.setItemDamage(100); @@ -142,12 +142,12 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI else { int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); GasStack gasStack = new GasStack(stack.getGas(), amount); - + itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)amount/getMaxGas(itemstack))*100)-100)))); itemstack.stackTagCompound.setCompoundTag("stored", gasStack.write(new NBTTagCompound())); } } - + public ItemStack getEmptyItem() { ItemStack empty = new ItemStack(this); @@ -155,7 +155,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI empty.setItemDamage(100); return empty; } - + @Override public void getSubItems(int i, CreativeTabs tabs, List list) { @@ -163,7 +163,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI setGas(empty, null); empty.setItemDamage(100); list.add(empty); - + for(Gas type : GasRegistry.getRegisteredGasses()) { if(type.isVisible()) @@ -174,7 +174,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI } } } - + @Override public int getMaxGas(ItemStack itemstack) { @@ -182,22 +182,22 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI } @Override - public int getRate(ItemStack itemstack) + public int getRate(ItemStack itemstack) { return TRANSFER_RATE; } @Override - public int addGas(ItemStack itemstack, GasStack stack) + public int addGas(ItemStack itemstack, GasStack stack) { if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { return 0; } - + int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); - + return toUse; } @@ -208,63 +208,63 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI { return null; } - + Gas type = getGas(itemstack).getGas(); - + int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); setGas(itemstack, new GasStack(type, getStored(itemstack)-gasToUse)); - + return new GasStack(type, gasToUse); } - + private int getStored(ItemStack itemstack) { return getGas(itemstack) != null ? getGas(itemstack).amount : 0; } - + @Override public boolean canReceiveGas(ItemStack itemstack, Gas type) { return getGas(itemstack) == null || getGas(itemstack).getGas() == type; } - + @Override public boolean canProvideGas(ItemStack itemstack, Gas type) { return getGas(itemstack) != null && (type == null || getGas(itemstack).getGas() == type); } - + @Override - public void setInventory(NBTTagList nbtTags, Object... data) + public void setInventory(NBTTagList nbtTags, Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - + if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setTag("Items", nbtTags); } } @Override - public NBTTagList getInventory(Object... data) + public NBTTagList getInventory(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - - if(itemStack.stackTagCompound == null) - { - return null; + + if(itemStack.stackTagCompound == null) + { + return null; } - + return itemStack.stackTagCompound.getTagList("Items"); } - + return null; } } diff --git a/common/mekanism/common/item/ItemBlockMachine.java b/common/mekanism/common/item/ItemBlockMachine.java index 486cd09df..470f8115f 100644 --- a/common/mekanism/common/item/ItemBlockMachine.java +++ b/common/mekanism/common/item/ItemBlockMachine.java @@ -85,7 +85,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IUpgradeManagement, IFactory, ISustainedInventory, ISustainedTank, IElectricChest, IEnergyContainerItem { public Block metaBlock; - + public ItemBlockMachine(int id, Block block) { super(id); @@ -94,13 +94,13 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec setNoRepair(); setMaxStackSize(1); } - + @Override public int getMetadata(int i) { return i; } - + @Override public String getUnlocalizedName(ItemStack itemstack) { @@ -108,16 +108,16 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { return getUnlocalizedName() + "." + MachineType.get(itemstack).name; } - + return "null"; } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { MachineType type = MachineType.get(itemstack); - + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { list.add("Hold " + EnumColor.AQUA + EnumColor.INDIGO + "shift" + EnumColor.GREY + " for more details."); @@ -129,18 +129,18 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { list.add(EnumColor.INDIGO + "Recipe Type: " + EnumColor.GREY + RecipeType.values()[getRecipeType(itemstack)].getName()); } - + if(type == MachineType.ELECTRIC_CHEST) { list.add(EnumColor.INDIGO + "Authenticated: " + EnumColor.GREY + getAuthenticated(itemstack)); list.add(EnumColor.INDIGO + "Locked: " + EnumColor.GREY + getLocked(itemstack)); } - + if(type != MachineType.LOGISTICAL_SORTER) { list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergyStored(itemstack))); } - + if(hasTank(itemstack)) { if(getFluidStack(itemstack) != null) @@ -148,13 +148,13 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec list.add(EnumColor.PINK + FluidRegistry.getFluidName(getFluidStack(itemstack)) + ": " + EnumColor.GREY + getFluidStack(itemstack).amount + "mB"); } } - + if(supportsUpgrades(itemstack)) { list.add(EnumColor.PURPLE + "Energy: " + EnumColor.GREY + "x" + (getEnergyMultiplier(itemstack)+1)); list.add(EnumColor.PURPLE + "Speed: " + EnumColor.GREY + "x" + (getSpeedMultiplier(itemstack)+1)); } - + if(type != MachineType.CHARGEPAD && type != MachineType.LOGISTICAL_SORTER) { list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); @@ -164,179 +164,179 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec list.addAll(MekanismUtils.splitLines(type.getDescription())); } } - + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = true; - - if(MachineType.get(stack) == MachineType.DIGITAL_MINER) - { - for(int xPos = x-1; xPos <= x+1; xPos++) - { - for(int yPos = y; yPos <= y+1; yPos++) - { - for(int zPos = z-1; zPos <= z+1; zPos++) - { - Block b = Block.blocksList[world.getBlockId(xPos, yPos, zPos)]; - - if(yPos > 255) - place = false; - - if(b != null && b.blockID != 0 && !b.isBlockReplaceable(world, xPos, yPos, zPos)) - return false; - } - } - } - } - - if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) - { - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); - - if(tileEntity instanceof IUpgradeManagement) - { - ((IUpgradeManagement)tileEntity).setEnergyMultiplier(getEnergyMultiplier(stack)); - ((IUpgradeManagement)tileEntity).setSpeedMultiplier(getSpeedMultiplier(stack)); - } - - if(tileEntity instanceof IInvConfiguration) - { - IInvConfiguration config = (IInvConfiguration)tileEntity; - - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSideData")) - { - config.getEjector().setEjecting(stack.stackTagCompound.getBoolean("ejecting")); - - for(int i = 0; i < 6; i++) - { - config.getConfiguration()[i] = stack.stackTagCompound.getByte("config"+i); - } - } - } - - if(tileEntity instanceof TileEntityDigitalMiner) - { - TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity; - - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasMinerConfig")) - { - miner.radius = stack.stackTagCompound.getInteger("radius"); - miner.minY = stack.stackTagCompound.getInteger("minY"); - miner.maxY = stack.stackTagCompound.getInteger("maxY"); - miner.doEject = stack.stackTagCompound.getBoolean("doEject"); - miner.doPull = stack.stackTagCompound.getBoolean("doPull"); - miner.silkTouch = stack.stackTagCompound.getBoolean("silkTouch"); - - if(stack.stackTagCompound.hasKey("replaceStack")) - { - miner.replaceStack = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("replaceStack")); - } - - if(stack.stackTagCompound.hasKey("filters")) - { - NBTTagList tagList = stack.stackTagCompound.getTagList("filters"); - - for(int i = 0; i < tagList.tagCount(); i++) - { - miner.filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i))); - } - } - } - } - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; - - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSorterConfig")) - { - if(stack.stackTagCompound.hasKey("color")) - { - sorter.color = TransporterUtils.colors.get(stack.stackTagCompound.getInteger("color")); - } - - sorter.autoEject = stack.stackTagCompound.getBoolean("autoEject"); - sorter.roundRobin = stack.stackTagCompound.getBoolean("roundRobin"); - - if(stack.stackTagCompound.hasKey("filters")) - { - NBTTagList tagList = stack.stackTagCompound.getTagList("filters"); - - for(int i = 0; i < tagList.tagCount(); i++) - { - sorter.filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i))); - } - } - } - } - - if(tileEntity instanceof IRedstoneControl) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("controlType")) - { - ((IRedstoneControl)tileEntity).setControlType(RedstoneControl.values()[stack.stackTagCompound.getInteger("controlType")]); - } - } - - if(tileEntity instanceof TileEntityFactory) - { - ((TileEntityFactory)tileEntity).recipeType = getRecipeType(stack); + { + boolean place = true; + + if(MachineType.get(stack) == MachineType.DIGITAL_MINER) + { + for(int xPos = x-1; xPos <= x+1; xPos++) + { + for(int yPos = y; yPos <= y+1; yPos++) + { + for(int zPos = z-1; zPos <= z+1; zPos++) + { + Block b = Block.blocksList[world.getBlockId(xPos, yPos, zPos)]; + + if(yPos > 255) + place = false; + + if(b != null && b.blockID != 0 && !b.isBlockReplaceable(world, xPos, yPos, zPos)) + return false; + } + } + } + } + + if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) + { + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); + + if(tileEntity instanceof IUpgradeManagement) + { + ((IUpgradeManagement)tileEntity).setEnergyMultiplier(getEnergyMultiplier(stack)); + ((IUpgradeManagement)tileEntity).setSpeedMultiplier(getSpeedMultiplier(stack)); + } + + if(tileEntity instanceof IInvConfiguration) + { + IInvConfiguration config = (IInvConfiguration)tileEntity; + + if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSideData")) + { + config.getEjector().setEjecting(stack.stackTagCompound.getBoolean("ejecting")); + + for(int i = 0; i < 6; i++) + { + config.getConfiguration()[i] = stack.stackTagCompound.getByte("config"+i); + } + } + } + + if(tileEntity instanceof TileEntityDigitalMiner) + { + TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity; + + if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasMinerConfig")) + { + miner.radius = stack.stackTagCompound.getInteger("radius"); + miner.minY = stack.stackTagCompound.getInteger("minY"); + miner.maxY = stack.stackTagCompound.getInteger("maxY"); + miner.doEject = stack.stackTagCompound.getBoolean("doEject"); + miner.doPull = stack.stackTagCompound.getBoolean("doPull"); + miner.silkTouch = stack.stackTagCompound.getBoolean("silkTouch"); + + if(stack.stackTagCompound.hasKey("replaceStack")) + { + miner.replaceStack = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("replaceStack")); + } + + if(stack.stackTagCompound.hasKey("filters")) + { + NBTTagList tagList = stack.stackTagCompound.getTagList("filters"); + + for(int i = 0; i < tagList.tagCount(); i++) + { + miner.filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i))); + } + } + } + } + + if(tileEntity instanceof TileEntityLogisticalSorter) + { + TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; + + if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSorterConfig")) + { + if(stack.stackTagCompound.hasKey("color")) + { + sorter.color = TransporterUtils.colors.get(stack.stackTagCompound.getInteger("color")); + } + + sorter.autoEject = stack.stackTagCompound.getBoolean("autoEject"); + sorter.roundRobin = stack.stackTagCompound.getBoolean("roundRobin"); + + if(stack.stackTagCompound.hasKey("filters")) + { + NBTTagList tagList = stack.stackTagCompound.getTagList("filters"); + + for(int i = 0; i < tagList.tagCount(); i++) + { + sorter.filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i))); + } + } + } + } + + if(tileEntity instanceof IRedstoneControl) + { + if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("controlType")) + { + ((IRedstoneControl)tileEntity).setControlType(RedstoneControl.values()[stack.stackTagCompound.getInteger("controlType")]); + } + } + + if(tileEntity instanceof TileEntityFactory) + { + ((TileEntityFactory)tileEntity).recipeType = getRecipeType(stack); world.notifyBlocksOfNeighborChange(x, y, z, tileEntity.getBlockType().blockID); - } - - if(tileEntity instanceof ISustainedTank) - { - if(hasTank(stack) && getFluidStack(stack) != null) - { - ((ISustainedTank)tileEntity).setFluidStack(getFluidStack(stack)); - } - } - - if(tileEntity instanceof TileEntityElectricChest) - { - ((TileEntityElectricChest)tileEntity).authenticated = getAuthenticated(stack); - ((TileEntityElectricChest)tileEntity).locked = getLocked(stack); - ((TileEntityElectricChest)tileEntity).password = getPassword(stack); - } - - if(tileEntity instanceof TileEntityRotaryCondensentrator) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("gasStack")) - { - GasStack gasStack = GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("gasStack")); - ((TileEntityRotaryCondensentrator)tileEntity).gasTank.setGas(gasStack); - } - } - - if(tileEntity instanceof TileEntityChemicalOxidizer) - { - if(stack.stackTagCompound != null) - { - ((TileEntityChemicalOxidizer)tileEntity).gasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("gasTank"))); - } - } - - if(tileEntity instanceof TileEntityChemicalInfuser) - { - if(stack.stackTagCompound != null) - { - ((TileEntityChemicalInfuser)tileEntity).leftTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("leftTank"))); - ((TileEntityChemicalInfuser)tileEntity).rightTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("rightTank"))); - ((TileEntityChemicalInfuser)tileEntity).centerTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("centerTank"))); - } - } - - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); - - tileEntity.electricityStored = getEnergy(stack); - - return true; - } - - return false; - } - + } + + if(tileEntity instanceof ISustainedTank) + { + if(hasTank(stack) && getFluidStack(stack) != null) + { + ((ISustainedTank)tileEntity).setFluidStack(getFluidStack(stack)); + } + } + + if(tileEntity instanceof TileEntityElectricChest) + { + ((TileEntityElectricChest)tileEntity).authenticated = getAuthenticated(stack); + ((TileEntityElectricChest)tileEntity).locked = getLocked(stack); + ((TileEntityElectricChest)tileEntity).password = getPassword(stack); + } + + if(tileEntity instanceof TileEntityRotaryCondensentrator) + { + if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("gasStack")) + { + GasStack gasStack = GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("gasStack")); + ((TileEntityRotaryCondensentrator)tileEntity).gasTank.setGas(gasStack); + } + } + + if(tileEntity instanceof TileEntityChemicalOxidizer) + { + if(stack.stackTagCompound != null) + { + ((TileEntityChemicalOxidizer)tileEntity).gasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("gasTank"))); + } + } + + if(tileEntity instanceof TileEntityChemicalInfuser) + { + if(stack.stackTagCompound != null) + { + ((TileEntityChemicalInfuser)tileEntity).leftTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("leftTank"))); + ((TileEntityChemicalInfuser)tileEntity).rightTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("rightTank"))); + ((TileEntityChemicalInfuser)tileEntity).centerTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("centerTank"))); + } + } + + ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); + + tileEntity.electricityStored = getEnergy(stack); + + return true; + } + + return false; + } + @Override public boolean canProvideEnergy(ItemStack itemStack) { @@ -372,7 +372,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { return 0; } - + @Override public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { @@ -381,7 +381,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if(world != null && !world.isRemote) { InventoryElectricChest inv = new InventoryElectricChest(itemstack); - + if(inv.getStackInSlot(54) != null && getEnergy(itemstack) < getMaxEnergy(itemstack)) { if(inv.getStackInSlot(54).getItem() instanceof IEnergizedItem) @@ -391,7 +391,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec else if(Mekanism.hooks.IC2Loaded && inv.getStackInSlot(54).getItem() instanceof IElectricItem) { IElectricItem item = (IElectricItem)inv.getStackInSlot(54).getItem(); - + if(item.canProvideEnergy(inv.getStackInSlot(54))) { double gain = ElectricItem.manager.discharge(inv.getStackInSlot(54), (int)((getMaxEnergy(itemstack) - getEnergy(itemstack))*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2; @@ -402,49 +402,49 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { ItemStack itemStack = inv.getStackInSlot(54); IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(54).getItem(); - + int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getEnergyStored(itemStack))); int toTransfer = (int)Math.round(Math.min(itemEnergy, ((getMaxEnergy(itemstack) - getEnergy(itemstack))*Mekanism.TO_TE))); - + setEnergy(itemstack, getEnergy(itemstack) + (item.extractEnergy(itemStack, toTransfer, false)*Mekanism.FROM_TE)); } else if(inv.getStackInSlot(54).itemID == Item.redstone.itemID && getEnergy(itemstack)+Mekanism.ENERGY_PER_REDSTONE <= getMaxEnergy(itemstack)) { setEnergy(itemstack, getEnergy(itemstack) + Mekanism.ENERGY_PER_REDSTONE); inv.getStackInSlot(54).stackSize--; - - if(inv.getStackInSlot(54).stackSize <= 0) - { - inv.setInventorySlotContents(54, null); - } + + if(inv.getStackInSlot(54).stackSize <= 0) + { + inv.setInventorySlotContents(54, null); + } } - + inv.write(); } } } } - + @Override public boolean onEntityItemUpdate(EntityItem entityItem) { - onUpdate(entityItem.getEntityItem(), null, entityItem, 0, false); - - return false; + onUpdate(entityItem.getEntityItem(), null, entityItem, 0, false); + + return false; } @Override - public int getEnergyMultiplier(Object... data) + public int getEnergyMultiplier(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - if(itemStack.stackTagCompound == null) - { - return 0; + if(itemStack.stackTagCompound == null) + { + return 0; } - + return itemStack.stackTagCompound.getInteger("energyMultiplier"); } @@ -452,7 +452,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public void setEnergyMultiplier(int multiplier, Object... data) + public void setEnergyMultiplier(int multiplier, Object... data) { if(data[0] instanceof ItemStack) { @@ -468,17 +468,17 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public int getSpeedMultiplier(Object... data) + public int getSpeedMultiplier(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - if(itemStack.stackTagCompound == null) - { - return 0; + if(itemStack.stackTagCompound == null) + { + return 0; } - + return itemStack.stackTagCompound.getInteger("speedMultiplier"); } @@ -486,7 +486,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public void setSpeedMultiplier(int multiplier, Object... data) + public void setSpeedMultiplier(int multiplier, Object... data) { if(data[0] instanceof ItemStack) { @@ -500,20 +500,20 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec itemStack.stackTagCompound.setInteger("speedMultiplier", multiplier); } } - + @Override public boolean supportsUpgrades(Object... data) { if(data[0] instanceof ItemStack) { MachineType type = MachineType.get((ItemStack)data[0]); - + return type.supportsUpgrades; } - + return false; } - + @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { @@ -521,37 +521,37 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { if(MachineType.get(itemstack) == MachineType.ELECTRIC_CHEST) { - if(!getAuthenticated(itemstack)) - { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 2, 0, false), entityplayer); - } - else if(getLocked(itemstack) && getEnergy(itemstack) > 0) - { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 1, 0, false), entityplayer); - } - else { - InventoryElectricChest inventory = new InventoryElectricChest(entityplayer); - MekanismUtils.openElectricChestGui((EntityPlayerMP)entityplayer, null, inventory, false); - } + if(!getAuthenticated(itemstack)) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 2, 0, false), entityplayer); + } + else if(getLocked(itemstack) && getEnergy(itemstack) > 0) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 1, 0, false), entityplayer); + } + else { + InventoryElectricChest inventory = new InventoryElectricChest(entityplayer); + MekanismUtils.openElectricChestGui((EntityPlayerMP)entityplayer, null, inventory, false); + } } } - + return itemstack; } @Override public int getRecipeType(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 0; + if(itemStack.stackTagCompound == null) + { + return 0; } - + return itemStack.stackTagCompound.getInteger("recipeType"); } @Override - public void setRecipeType(int type, ItemStack itemStack) + public void setRecipeType(int type, ItemStack itemStack) { if(itemStack.stackTagCompound == null) { @@ -562,90 +562,90 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public void setInventory(NBTTagList nbtTags, Object... data) + public void setInventory(NBTTagList nbtTags, Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - + if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setTag("Items", nbtTags); } } @Override - public NBTTagList getInventory(Object... data) + public NBTTagList getInventory(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - - if(itemStack.stackTagCompound == null) - { - return null; + + if(itemStack.stackTagCompound == null) + { + return null; } - + return itemStack.stackTagCompound.getTagList("Items"); } - + return null; } @Override - public void setFluidStack(FluidStack fluidStack, Object... data) + public void setFluidStack(FluidStack fluidStack, Object... data) { if(fluidStack == null || fluidStack.amount == 0 || fluidStack.fluidID == 0) { return; } - + if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - + if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setTag("fluidTank", fluidStack.writeToNBT(new NBTTagCompound())); } } @Override - public FluidStack getFluidStack(Object... data) + public FluidStack getFluidStack(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - - if(itemStack.stackTagCompound == null) - { - return null; + + if(itemStack.stackTagCompound == null) + { + return null; } - + if(itemStack.stackTagCompound.hasKey("fluidTank")) { return FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank")); } } - + return null; } @Override - public boolean hasTank(Object... data) + public boolean hasTank(Object... data) { return data[0] instanceof ItemStack && ((ItemStack)data[0]).getItem() instanceof ISustainedTank && (MachineType.get((ItemStack)data[0]) == MachineType.ELECTRIC_PUMP || MachineType.get((ItemStack)data[0]) == MachineType.ROTARY_CONDENSENTRATOR); } @Override - public void setAuthenticated(ItemStack itemStack, boolean auth) + public void setAuthenticated(ItemStack itemStack, boolean auth) { if(itemStack.stackTagCompound == null) { @@ -656,13 +656,13 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public boolean getAuthenticated(ItemStack itemStack) + public boolean getAuthenticated(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return false; + if(itemStack.stackTagCompound == null) + { + return false; } - + return itemStack.stackTagCompound.getBoolean("authenticated"); } @@ -680,16 +680,16 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec @Override public String getPassword(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { + if(itemStack.stackTagCompound == null) + { return ""; } - + return itemStack.stackTagCompound.getString("password"); } @Override - public void setLocked(ItemStack itemStack, boolean locked) + public void setLocked(ItemStack itemStack, boolean locked) { if(itemStack.stackTagCompound == null) { @@ -700,18 +700,18 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public boolean getLocked(ItemStack itemStack) + public boolean getLocked(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return false; + if(itemStack.stackTagCompound == null) + { + return false; } - + return itemStack.stackTagCompound.getBoolean("locked"); } - + @Override - public void setOpen(ItemStack itemStack, boolean open) + public void setOpen(ItemStack itemStack, boolean open) { if(itemStack.stackTagCompound == null) { @@ -722,18 +722,18 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public boolean getOpen(ItemStack itemStack) + public boolean getOpen(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return false; + if(itemStack.stackTagCompound == null) + { + return false; } - + return itemStack.stackTagCompound.getBoolean("open"); } - + @Override - public void setLidAngle(ItemStack itemStack, float lidAngle) + public void setLidAngle(ItemStack itemStack, float lidAngle) { if(itemStack.stackTagCompound == null) { @@ -744,18 +744,18 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public float getLidAngle(ItemStack itemStack) + public float getLidAngle(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 0.0F; + if(itemStack.stackTagCompound == null) + { + return 0.0F; } - + return itemStack.stackTagCompound.getFloat("lidAngle"); } - + @Override - public void setPrevLidAngle(ItemStack itemStack, float prevLidAngle) + public void setPrevLidAngle(ItemStack itemStack, float prevLidAngle) { if(itemStack.stackTagCompound == null) { @@ -766,29 +766,29 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public float getPrevLidAngle(ItemStack itemStack) + public float getPrevLidAngle(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 0.0F; + if(itemStack.stackTagCompound == null) + { + return 0.0F; } - + return itemStack.stackTagCompound.getFloat("prevLidAngle"); } - + @Override - public double getEnergy(ItemStack itemStack) + public double getEnergy(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 0; + if(itemStack.stackTagCompound == null) + { + return 0; } - + return itemStack.stackTagCompound.getDouble("electricity"); } @Override - public void setEnergy(ItemStack itemStack, double amount) + public void setEnergy(ItemStack itemStack, double amount) { if(itemStack.stackTagCompound == null) { @@ -800,19 +800,19 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public double getMaxEnergy(ItemStack itemStack) + public double getMaxEnergy(ItemStack itemStack) { return MekanismUtils.getMaxEnergy(getEnergyMultiplier(itemStack), MachineType.get(itemStack.itemID, itemStack.getItemDamage()).baseEnergy); } @Override - public double getMaxTransfer(ItemStack itemStack) + public double getMaxTransfer(ItemStack itemStack) { return getMaxEnergy(itemStack)*0.005; } @Override - public boolean canReceive(ItemStack itemStack) + public boolean canReceive(ItemStack itemStack) { return true; } @@ -822,7 +822,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { return false; } - + @Override public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) { @@ -830,34 +830,34 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - + return (int)Math.round(toReceive*Mekanism.TO_TE); } - + return 0; } @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if(canSend(theItem)) { double energyRemaining = getEnergy(theItem); double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - + return (int)Math.round(toSend*Mekanism.TO_TE); } - + return 0; } @@ -872,15 +872,15 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec { return (int)(getMaxEnergy(theItem)*Mekanism.TO_TE); } - + @Override public boolean isMetadataSpecific() { return true; } - + @Override - public IElectricItemManager getManager(ItemStack itemStack) + public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); } diff --git a/common/mekanism/common/item/ItemBlockOre.java b/common/mekanism/common/item/ItemBlockOre.java index bbfc0ff29..0c87a3928 100644 --- a/common/mekanism/common/item/ItemBlockOre.java +++ b/common/mekanism/common/item/ItemBlockOre.java @@ -26,14 +26,14 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemBlockOre extends ItemBlock { public Block metaBlock; - + public ItemBlockOre(int id, Block block) { super(id); metaBlock = block; setHasSubtypes(true); } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) @@ -46,24 +46,24 @@ public class ItemBlockOre extends ItemBlock list.addAll(MekanismUtils.splitLines(MekanismUtils.localize("tooltip." + getUnlocalizedName(itemstack).replace("tile.OreBlock.", "")))); } } - + @Override public int getMetadata(int i) { return i; } - + @Override public Icon getIconFromDamage(int i) { return metaBlock.getIcon(2, i); } - + @Override public String getUnlocalizedName(ItemStack itemstack) { String name = ""; - + switch(itemstack.getItemDamage()) { case 0: @@ -79,7 +79,7 @@ public class ItemBlockOre extends ItemBlock name = "Unknown"; break; } - + return getUnlocalizedName() + "." + name; } } diff --git a/common/mekanism/common/item/ItemClump.java b/common/mekanism/common/item/ItemClump.java index cb6736086..973b76387 100644 --- a/common/mekanism/common/item/ItemClump.java +++ b/common/mekanism/common/item/ItemClump.java @@ -12,14 +12,14 @@ import net.minecraft.util.Icon; public class ItemClump extends ItemMekanism { public Icon[] icons = new Icon[256]; - + public ItemClump(int id) { super(id); setHasSubtypes(true); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void registerIcons(IconRegister register) { diff --git a/common/mekanism/common/item/ItemConfigurator.java b/common/mekanism/common/item/ItemConfigurator.java index 710e543b2..d5480161a 100644 --- a/common/mekanism/common/item/ItemConfigurator.java +++ b/common/mekanism/common/item/ItemConfigurator.java @@ -29,20 +29,20 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench { public final int ENERGY_PER_CONFIGURE = 400; public final int ENERGY_PER_ITEM_DUMP = 8; - + private Random random = new Random(); - - public ItemConfigurator(int id) - { - super(id, 60000, 120); - } - + + public ItemConfigurator(int id) + { + super(id, 60000, 120); + } + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { super.addInformation(itemstack, entityplayer, list, flag); list.add(EnumColor.PINK + MekanismUtils.localize("gui.state") + ": " + EnumColor.GREY + getStateDisplay(getState(itemstack))); - + if(getState(itemstack) == 3) { if(hasLink(itemstack)) @@ -56,219 +56,219 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench } } } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(!world.isRemote) - { - TileEntity tile = world.getBlockTileEntity(x, y, z); - - if(tile instanceof IConfigurable) - { - IConfigurable config = (IConfigurable)tile; - - if(player.isSneaking()) - { - config.onSneakRightClick(player, side); - } - else { - config.onRightClick(player, side); - } - } - - if(getState(stack) == 0) - { - if(tile instanceof IInvConfiguration) - { - IInvConfiguration config = (IInvConfiguration)tile; - - if(!player.isSneaking()) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.viewColor") + ": " + config.getSideData().get(config.getConfiguration()[MekanismUtils.getBaseOrientation(side, config.getOrientation())]).color.getName())); - return true; - } - else { - if(getEnergy(stack) >= ENERGY_PER_CONFIGURE) - { - setEnergy(stack, getEnergy(stack) - ENERGY_PER_CONFIGURE); - MekanismUtils.incrementOutput(config, MekanismUtils.getBaseOrientation(side, config.getOrientation())); - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + config.getSideData().get(config.getConfiguration()[MekanismUtils.getBaseOrientation(side, config.getOrientation())]).color.getName())); - - if(config instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)config; - PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), Coord4D.get(tileEntity), 50D); - } - - return true; - } - } - } - } - else if(getState(stack) == 1) - { - if(tile instanceof IInventory) - { - int itemAmount = 0; - IInventory inv = (IInventory)tile; - - if(!(inv instanceof TileEntityElectricChest) || (((TileEntityElectricChest)inv).canAccess())) - { - for(int i = 0; i < inv.getSizeInventory(); i++) - { - ItemStack slotStack = inv.getStackInSlot(i); - - if(slotStack != null) - { - if(getEnergy(stack) < ENERGY_PER_ITEM_DUMP) - { - break; - } - - float xRandom = random.nextFloat() * 0.8F + 0.1F; - float yRandom = random.nextFloat() * 0.8F + 0.1F; - float zRandom = random.nextFloat() * 0.8F + 0.1F; - - while(slotStack.stackSize > 0) - { - int j = random.nextInt(21) + 10; - - if(j > slotStack.stackSize) - { - j = slotStack.stackSize; - } - - slotStack.stackSize -= j; - EntityItem item = new EntityItem(world, x + xRandom, y + yRandom, z + zRandom, new ItemStack(slotStack.itemID, j, slotStack.getItemDamage())); - - if(slotStack.hasTagCompound()) - { - item.getEntityItem().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); - } - - float k = 0.05F; - item.motionX = random.nextGaussian() * k; - item.motionY = random.nextGaussian() * k + 0.2F; - item.motionZ = random.nextGaussian() * k; - world.spawnEntityInWorld(item); - - inv.setInventorySlotContents(i, null); - setEnergy(stack, getEnergy(stack) - ENERGY_PER_ITEM_DUMP); - } - } - } - - return true; - } - else { - player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.unauth")); - return true; - } - } - } - else if(getState(stack) == 2) - { - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicBlock = (TileEntityBasicBlock)tile; - int newSide = basicBlock.facing; - - if(!player.isSneaking()) - { - newSide = side; - } - else { - newSide = ForgeDirection.OPPOSITES[side]; - } - - if(basicBlock.canSetFacing(newSide)) - { - basicBlock.setFacing((short)newSide); - world.playSoundEffect(x, y, z, "random.click", 1.0F, 1.0F); - } - - return true; - } - } - else if(getState(stack) == 3) - { - if(!world.isRemote && player.isSneaking()) - { - Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId); - player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Set link to block " + EnumColor.INDIGO + MekanismUtils.getCoordDisplay(obj) + EnumColor.GREY + ", dimension " + EnumColor.INDIGO + obj.dimensionId); - setLink(stack, obj); - - return true; - } - } - } - - return false; - } - - public String getStateDisplay(int state) - { - switch(state) - { - case 0: - return MekanismUtils.localize("tooltip.configurator.modify"); - case 1: - return MekanismUtils.localize("tooltip.configurator.empty"); - case 2: - return MekanismUtils.localize("tooltip.configurator.wrench"); - case 3: - return MekanismUtils.localize("tooltip.configurator.link"); - } - - return "unknown"; - } - - public EnumColor getColor(int state) - { - switch(state) - { - case 0: - return EnumColor.BRIGHT_GREEN; - case 1: - return EnumColor.AQUA; - case 2: - return EnumColor.YELLOW; - case 3: - return EnumColor.PINK; - } - - return EnumColor.GREY; - } - - public void setState(ItemStack itemstack, byte state) - { + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + if(!world.isRemote) + { + TileEntity tile = world.getBlockTileEntity(x, y, z); + + if(tile instanceof IConfigurable) + { + IConfigurable config = (IConfigurable)tile; + + if(player.isSneaking()) + { + config.onSneakRightClick(player, side); + } + else { + config.onRightClick(player, side); + } + } + + if(getState(stack) == 0) + { + if(tile instanceof IInvConfiguration) + { + IInvConfiguration config = (IInvConfiguration)tile; + + if(!player.isSneaking()) + { + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.viewColor") + ": " + config.getSideData().get(config.getConfiguration()[MekanismUtils.getBaseOrientation(side, config.getOrientation())]).color.getName())); + return true; + } + else { + if(getEnergy(stack) >= ENERGY_PER_CONFIGURE) + { + setEnergy(stack, getEnergy(stack) - ENERGY_PER_CONFIGURE); + MekanismUtils.incrementOutput(config, MekanismUtils.getBaseOrientation(side, config.getOrientation())); + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + config.getSideData().get(config.getConfiguration()[MekanismUtils.getBaseOrientation(side, config.getOrientation())]).color.getName())); + + if(config instanceof TileEntityBasicBlock) + { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)config; + PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), Coord4D.get(tileEntity), 50D); + } + + return true; + } + } + } + } + else if(getState(stack) == 1) + { + if(tile instanceof IInventory) + { + int itemAmount = 0; + IInventory inv = (IInventory)tile; + + if(!(inv instanceof TileEntityElectricChest) || (((TileEntityElectricChest)inv).canAccess())) + { + for(int i = 0; i < inv.getSizeInventory(); i++) + { + ItemStack slotStack = inv.getStackInSlot(i); + + if(slotStack != null) + { + if(getEnergy(stack) < ENERGY_PER_ITEM_DUMP) + { + break; + } + + float xRandom = random.nextFloat() * 0.8F + 0.1F; + float yRandom = random.nextFloat() * 0.8F + 0.1F; + float zRandom = random.nextFloat() * 0.8F + 0.1F; + + while(slotStack.stackSize > 0) + { + int j = random.nextInt(21) + 10; + + if(j > slotStack.stackSize) + { + j = slotStack.stackSize; + } + + slotStack.stackSize -= j; + EntityItem item = new EntityItem(world, x + xRandom, y + yRandom, z + zRandom, new ItemStack(slotStack.itemID, j, slotStack.getItemDamage())); + + if(slotStack.hasTagCompound()) + { + item.getEntityItem().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); + } + + float k = 0.05F; + item.motionX = random.nextGaussian() * k; + item.motionY = random.nextGaussian() * k + 0.2F; + item.motionZ = random.nextGaussian() * k; + world.spawnEntityInWorld(item); + + inv.setInventorySlotContents(i, null); + setEnergy(stack, getEnergy(stack) - ENERGY_PER_ITEM_DUMP); + } + } + } + + return true; + } + else { + player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.unauth")); + return true; + } + } + } + else if(getState(stack) == 2) + { + if(tile instanceof TileEntityBasicBlock) + { + TileEntityBasicBlock basicBlock = (TileEntityBasicBlock)tile; + int newSide = basicBlock.facing; + + if(!player.isSneaking()) + { + newSide = side; + } + else { + newSide = ForgeDirection.OPPOSITES[side]; + } + + if(basicBlock.canSetFacing(newSide)) + { + basicBlock.setFacing((short)newSide); + world.playSoundEffect(x, y, z, "random.click", 1.0F, 1.0F); + } + + return true; + } + } + else if(getState(stack) == 3) + { + if(!world.isRemote && player.isSneaking()) + { + Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId); + player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Set link to block " + EnumColor.INDIGO + MekanismUtils.getCoordDisplay(obj) + EnumColor.GREY + ", dimension " + EnumColor.INDIGO + obj.dimensionId); + setLink(stack, obj); + + return true; + } + } + } + + return false; + } + + public String getStateDisplay(int state) + { + switch(state) + { + case 0: + return MekanismUtils.localize("tooltip.configurator.modify"); + case 1: + return MekanismUtils.localize("tooltip.configurator.empty"); + case 2: + return MekanismUtils.localize("tooltip.configurator.wrench"); + case 3: + return MekanismUtils.localize("tooltip.configurator.link"); + } + + return "unknown"; + } + + public EnumColor getColor(int state) + { + switch(state) + { + case 0: + return EnumColor.BRIGHT_GREEN; + case 1: + return EnumColor.AQUA; + case 2: + return EnumColor.YELLOW; + case 3: + return EnumColor.PINK; + } + + return EnumColor.GREY; + } + + public void setState(ItemStack itemstack, byte state) + { if(itemstack.stackTagCompound == null) { itemstack.setTagCompound(new NBTTagCompound()); } - + itemstack.stackTagCompound.setByte("state", state); - } - - public byte getState(ItemStack itemstack) - { + } + + public byte getState(ItemStack itemstack) + { if(itemstack.stackTagCompound == null) { return 0; } - + byte state = 0; - + if(itemstack.stackTagCompound.getTag("state") != null) { state = itemstack.stackTagCompound.getByte("state"); } - + return state; - } - - public boolean hasLink(ItemStack itemStack) + } + + public boolean hasLink(ItemStack itemStack) { return getLink(itemStack) != null; } @@ -279,7 +279,7 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench { return null; } - + return Coord4D.read(itemStack.getTagCompound().getCompoundTag("position")); } @@ -297,7 +297,7 @@ public class ItemConfigurator extends ItemEnergized implements IToolWrench { itemStack.getTagCompound().removeTag("position"); } - + @Override public boolean canSend(ItemStack itemStack) { diff --git a/common/mekanism/common/item/ItemCrystal.java b/common/mekanism/common/item/ItemCrystal.java index dfe729301..c14f68166 100644 --- a/common/mekanism/common/item/ItemCrystal.java +++ b/common/mekanism/common/item/ItemCrystal.java @@ -12,14 +12,14 @@ import net.minecraft.util.Icon; public class ItemCrystal extends ItemMekanism { public Icon[] icons = new Icon[256]; - + public ItemCrystal(int id) { super(id); setHasSubtypes(true); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void registerIcons(IconRegister register) { diff --git a/common/mekanism/common/item/ItemDictionary.java b/common/mekanism/common/item/ItemDictionary.java index 78cfdfa4d..35e105395 100644 --- a/common/mekanism/common/item/ItemDictionary.java +++ b/common/mekanism/common/item/ItemDictionary.java @@ -17,25 +17,25 @@ public class ItemDictionary extends ItemMekanism super(id); setMaxStackSize(1); } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { if(!player.isSneaking()) { Block block = Block.blocksList[world.getBlockId(x, y, z)]; - + if(block != null) { if(world.isRemote) { ItemStack testStack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); List names = MekanismUtils.getOreDictName(testStack); - + if(!names.isEmpty()) { player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Key(s) found:"); - + for(String name : names) { player.addChatMessage(EnumColor.DARK_GREEN + " - " + name); @@ -45,14 +45,14 @@ public class ItemDictionary extends ItemMekanism player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No key."); } } - - return true; + + return true; } } - - return false; - } - + + return false; + } + @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { @@ -60,7 +60,7 @@ public class ItemDictionary extends ItemMekanism { entityplayer.openGui(Mekanism.instance, 0, world, 0, 0, 0); } - + return itemstack; } } diff --git a/common/mekanism/common/item/ItemDirtyDust.java b/common/mekanism/common/item/ItemDirtyDust.java index 5ff759dc1..5a9b4d7ac 100644 --- a/common/mekanism/common/item/ItemDirtyDust.java +++ b/common/mekanism/common/item/ItemDirtyDust.java @@ -12,14 +12,14 @@ import net.minecraft.util.Icon; public class ItemDirtyDust extends ItemMekanism { public Icon[] icons = new Icon[256]; - + public ItemDirtyDust(int id) { super(id); setHasSubtypes(true); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void registerIcons(IconRegister register) { diff --git a/common/mekanism/common/item/ItemDust.java b/common/mekanism/common/item/ItemDust.java index 42ae33292..18e8f870d 100644 --- a/common/mekanism/common/item/ItemDust.java +++ b/common/mekanism/common/item/ItemDust.java @@ -11,19 +11,19 @@ import net.minecraft.util.Icon; public class ItemDust extends ItemMekanism { public Icon[] icons = new Icon[256]; - - public static String[] en_USNames = {"Iron", "Gold", "Osmium", + + public static String[] en_USNames = {"Iron", "Gold", "Osmium", "Obsidian", "Diamond", "Steel", "Copper", "Tin", "Silver", "Lead", "Sulfur"}; - + public ItemDust(int id) { super(id); setHasSubtypes(true); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void registerIcons(IconRegister register) { diff --git a/common/mekanism/common/item/ItemElectricBow.java b/common/mekanism/common/item/ItemElectricBow.java index 6a1c0acb9..3be617314 100644 --- a/common/mekanism/common/item/ItemElectricBow.java +++ b/common/mekanism/common/item/ItemElectricBow.java @@ -15,11 +15,11 @@ import net.minecraft.world.World; public class ItemElectricBow extends ItemEnergized { - public ItemElectricBow(int id) - { - super(id, 120000, 120); - } - + public ItemElectricBow(int id) + { + super(id, 120000, 120); + } + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { @@ -27,120 +27,120 @@ public class ItemElectricBow extends ItemEnergized list.add(EnumColor.PINK + "Fire Mode: " + EnumColor.GREY + (getFireState(itemstack) ? "ON" : "OFF")); } - @Override - public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityPlayer player, int itemUseCount) - { - if(getEnergy(itemstack) > 0) - { - boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, itemstack) > 0; - - if(flag || player.inventory.hasItem(Item.arrow.itemID)) - { - int maxItemUse = getMaxItemUseDuration(itemstack) - itemUseCount; - float f = maxItemUse / 20F; - f = (f * f + f * 2.0F) / 3F; - - if(f < 0.1D) - { - return; - } - - if(f > 1.0F) - { - f = 1.0F; - } - - EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F); - - if(f == 1.0F) - { - entityarrow.setIsCritical(true); - } - - if(!player.capabilities.isCreativeMode) - { - setEnergy(itemstack, getEnergy(itemstack) - (getFireState(itemstack) ? 1200 : 120)); - } - - world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); - - if(flag) - { - entityarrow.canBePickedUp = 2; - } - else { - player.inventory.consumeInventoryItem(Item.arrow.itemID); - } - - if(!world.isRemote) - { - world.spawnEntityInWorld(entityarrow); - entityarrow.setFire(getFireState(itemstack) ? 60 : 0); - } - } - } - } + @Override + public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityPlayer player, int itemUseCount) + { + if(getEnergy(itemstack) > 0) + { + boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, itemstack) > 0; - @Override - public int getMaxItemUseDuration(ItemStack itemstack) - { - return 72000; - } + if(flag || player.inventory.hasItem(Item.arrow.itemID)) + { + int maxItemUse = getMaxItemUseDuration(itemstack) - itemUseCount; + float f = maxItemUse / 20F; + f = (f * f + f * 2.0F) / 3F; - @Override - public EnumAction getItemUseAction(ItemStack itemstack) - { - return EnumAction.bow; - } + if(f < 0.1D) + { + return; + } - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { - if(entityplayer.capabilities.isCreativeMode || entityplayer.inventory.hasItem(Item.arrow.itemID)) - { - entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); - } - - return itemstack; - } - - /** - * Sets the bow's fire state in NBT. - * @param itemstack - the bow's itemstack - * @param state - state to change to - */ - public void setFireState(ItemStack itemstack, boolean state) - { + if(f > 1.0F) + { + f = 1.0F; + } + + EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F); + + if(f == 1.0F) + { + entityarrow.setIsCritical(true); + } + + if(!player.capabilities.isCreativeMode) + { + setEnergy(itemstack, getEnergy(itemstack) - (getFireState(itemstack) ? 1200 : 120)); + } + + world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + + if(flag) + { + entityarrow.canBePickedUp = 2; + } + else { + player.inventory.consumeInventoryItem(Item.arrow.itemID); + } + + if(!world.isRemote) + { + world.spawnEntityInWorld(entityarrow); + entityarrow.setFire(getFireState(itemstack) ? 60 : 0); + } + } + } + } + + @Override + public int getMaxItemUseDuration(ItemStack itemstack) + { + return 72000; + } + + @Override + public EnumAction getItemUseAction(ItemStack itemstack) + { + return EnumAction.bow; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + if(entityplayer.capabilities.isCreativeMode || entityplayer.inventory.hasItem(Item.arrow.itemID)) + { + entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); + } + + return itemstack; + } + + /** + * Sets the bow's fire state in NBT. + * @param itemstack - the bow's itemstack + * @param state - state to change to + */ + public void setFireState(ItemStack itemstack, boolean state) + { if(itemstack.stackTagCompound == null) { itemstack.setTagCompound(new NBTTagCompound()); } - + itemstack.stackTagCompound.setBoolean("fireState", state); - } - - /** - * Gets the bow's fire state from NBT. - * @param itemstack - the bow's itemstack - * @return fire state - */ - public boolean getFireState(ItemStack itemstack) - { + } + + /** + * Gets the bow's fire state from NBT. + * @param itemstack - the bow's itemstack + * @return fire state + */ + public boolean getFireState(ItemStack itemstack) + { if(itemstack.stackTagCompound == null) { return false; } - + boolean state = false; - + if(itemstack.stackTagCompound.getTag("fireState") != null) { state = itemstack.stackTagCompound.getBoolean("fireState"); } - + return state; - } - + } + @Override public boolean canSend(ItemStack itemStack) { diff --git a/common/mekanism/common/item/ItemEnergized.java b/common/mekanism/common/item/ItemEnergized.java index a1a0c2124..b1775f37f 100644 --- a/common/mekanism/common/item/ItemEnergized.java +++ b/common/mekanism/common/item/ItemEnergized.java @@ -21,7 +21,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec { /** The maximum amount of energy this item can hold. */ public double MAX_ELECTRICITY; - + public ItemEnergized(int id, double maxElectricity, float voltage) { super(id); @@ -31,20 +31,20 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec setNoRepair(); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { list.add(EnumColor.AQUA + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); } - + public ItemStack getUnchargedItem() { ItemStack charged = new ItemStack(this); charged.setItemDamage(100); return charged; } - + @Override public void getSubItems(int i, CreativeTabs tabs, List list) { @@ -55,7 +55,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec setEnergy(charged, ((IEnergizedItem)charged.getItem()).getMaxEnergy(charged)); list.add(charged); } - + @Override public boolean canProvideEnergy(ItemStack itemStack) { @@ -93,21 +93,21 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec } @Override - public double getEnergy(ItemStack itemStack) + public double getEnergy(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 0; + if(itemStack.stackTagCompound == null) + { + return 0; } - + double electricityStored = itemStack.stackTagCompound.getDouble("electricity"); itemStack.setItemDamage((int)Math.max(1, (Math.abs(((electricityStored/getMaxEnergy(itemStack))*100)-100)))); - + return electricityStored; } @Override - public void setEnergy(ItemStack itemStack, double amount) + public void setEnergy(ItemStack itemStack, double amount) { if(itemStack.stackTagCompound == null) { @@ -120,19 +120,19 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec } @Override - public double getMaxEnergy(ItemStack itemStack) + public double getMaxEnergy(ItemStack itemStack) { return MAX_ELECTRICITY; } @Override - public double getMaxTransfer(ItemStack itemStack) + public double getMaxTransfer(ItemStack itemStack) { return getMaxEnergy(itemStack)*0.005; } @Override - public boolean canReceive(ItemStack itemStack) + public boolean canReceive(ItemStack itemStack) { return getMaxEnergy(itemStack)-getEnergy(itemStack) > 0; } @@ -150,34 +150,34 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec { double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - + return (int)Math.round(toReceive*Mekanism.TO_TE); } - + return 0; } @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if(canSend(theItem)) { double energyRemaining = getEnergy(theItem); double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - + return (int)Math.round(toSend*Mekanism.TO_TE); } - + return 0; } @@ -192,7 +192,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec { return (int)Math.round(getMaxEnergy(theItem)*Mekanism.TO_TE); } - + @Override public boolean isMetadataSpecific() { @@ -200,7 +200,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec } @Override - public IElectricItemManager getManager(ItemStack itemStack) + public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); } diff --git a/common/mekanism/common/item/ItemFreeRunners.java b/common/mekanism/common/item/ItemFreeRunners.java index 489fe2c95..4a85f7957 100644 --- a/common/mekanism/common/item/ItemFreeRunners.java +++ b/common/mekanism/common/item/ItemFreeRunners.java @@ -35,7 +35,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci { /** The maximum amount of energy this item can hold. */ public double MAX_ELECTRICITY = 64000; - + public ItemFreeRunners(int id) { super(id, EnumHelper.addArmorMaterial("FRICTIONBOOTS", 0, new int[] {0, 0, 0, 0}, 0), 0, 3); @@ -45,45 +45,45 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci setCreativeTab(Mekanism.tabMekanism); MinecraftForge.EVENT_BUS.register(this); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} - + @Override - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { - return armorType == 3; - } - + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) + { + return armorType == 3; + } + @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { + { return "mekanism:render/NullArmor.png"; - } - + } + @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) + { ModelCustomArmor model = ModelCustomArmor.INSTANCE; model.modelType = ArmorModel.FREERUNNERS; - return model; - } - + return model; + } + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { list.add(EnumColor.AQUA + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); } - + public ItemStack getUnchargedItem() { ItemStack charged = new ItemStack(this); charged.setItemDamage(100); return charged; } - + @Override public void getSubItems(int i, CreativeTabs tabs, List list) { @@ -94,7 +94,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci setEnergy(charged, ((IEnergizedItem)charged.getItem()).getMaxEnergy(charged)); list.add(charged); } - + @Override public boolean canProvideEnergy(ItemStack itemStack) { @@ -132,21 +132,21 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci } @Override - public double getEnergy(ItemStack itemStack) + public double getEnergy(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 0; + if(itemStack.stackTagCompound == null) + { + return 0; } - + double electricityStored = itemStack.stackTagCompound.getDouble("electricity"); itemStack.setItemDamage((int)Math.max(1, (Math.abs(((electricityStored/getMaxEnergy(itemStack))*100)-100)))); - + return electricityStored; } @Override - public void setEnergy(ItemStack itemStack, double amount) + public void setEnergy(ItemStack itemStack, double amount) { if(itemStack.stackTagCompound == null) { @@ -159,19 +159,19 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci } @Override - public double getMaxEnergy(ItemStack itemStack) + public double getMaxEnergy(ItemStack itemStack) { return MAX_ELECTRICITY; } @Override - public double getMaxTransfer(ItemStack itemStack) + public double getMaxTransfer(ItemStack itemStack) { return getMaxEnergy(itemStack)*0.005; } @Override - public boolean canReceive(ItemStack itemStack) + public boolean canReceive(ItemStack itemStack) { return getMaxEnergy(itemStack)-getEnergy(itemStack) > 0; } @@ -189,34 +189,34 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci { double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - + return (int)Math.round(toReceive*Mekanism.TO_TE); } - + return 0; } @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if(canSend(theItem)) { double energyRemaining = getEnergy(theItem); double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - + return (int)Math.round(toSend*Mekanism.TO_TE); } - + return 0; } @@ -231,7 +231,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci { return (int)Math.round(getMaxEnergy(theItem)*Mekanism.TO_TE); } - + @Override public boolean isMetadataSpecific() { @@ -239,21 +239,21 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci } @Override - public IElectricItemManager getManager(ItemStack itemStack) + public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); } - + @ForgeSubscribe public void onEntityAttacked(LivingAttackEvent event) { EntityLivingBase base = event.entityLiving; - + if(base.getCurrentItemOrArmor(1) != null && base.getCurrentItemOrArmor(1).getItem() instanceof ItemFreeRunners) { ItemStack stack = base.getCurrentItemOrArmor(1); ItemFreeRunners boots = (ItemFreeRunners)stack.getItem(); - + if(boots.getEnergy(stack) > 0 && event.source == DamageSource.fall) { boots.setEnergy(stack, boots.getEnergy(stack)-event.ammount*50); diff --git a/common/mekanism/common/item/ItemGasMask.java b/common/mekanism/common/item/ItemGasMask.java index 8d636d097..fc7d766f3 100644 --- a/common/mekanism/common/item/ItemGasMask.java +++ b/common/mekanism/common/item/ItemGasMask.java @@ -25,45 +25,45 @@ public class ItemGasMask extends ItemArmor setCreativeTab(Mekanism.tabMekanism); MinecraftForge.EVENT_BUS.register(this); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} - + @Override - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { - return armorType == 0; - } - + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) + { + return armorType == 0; + } + @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { + { return "mekanism:render/NullArmor.png"; - } - + } + @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) + { ModelCustomArmor model = ModelCustomArmor.INSTANCE; model.modelType = ArmorModel.GASMASK; - return model; - } - + return model; + } + @ForgeSubscribe public void onEntityAttacked(LivingAttackEvent event) { EntityLivingBase base = event.entityLiving; - + if(base.getCurrentItemOrArmor(4) != null && base.getCurrentItemOrArmor(4).getItem() instanceof ItemGasMask) { ItemGasMask mask = (ItemGasMask)base.getCurrentItemOrArmor(4).getItem(); - + if(base.getCurrentItemOrArmor(3) != null && base.getCurrentItemOrArmor(3).getItem() instanceof ItemScubaTank) { ItemScubaTank tank = (ItemScubaTank)base.getCurrentItemOrArmor(3).getItem(); - + if(tank.getFlowing(base.getCurrentItemOrArmor(3)) && tank.getGas(base.getCurrentItemOrArmor(3)) != null) { if(event.source == DamageSource.magic) diff --git a/common/mekanism/common/item/ItemIngot.java b/common/mekanism/common/item/ItemIngot.java index 454c37bd5..d9a8cfa59 100644 --- a/common/mekanism/common/item/ItemIngot.java +++ b/common/mekanism/common/item/ItemIngot.java @@ -11,16 +11,16 @@ import net.minecraft.util.Icon; public class ItemIngot extends ItemMekanism { public Icon[] icons = new Icon[256]; - + public static String[] en_USNames = {"Obsidian", "Osmium", "Bronze", "Glowstone", "Steel", "Copper", "Tin"}; - + public ItemIngot(int id) { super(id); setHasSubtypes(true); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void registerIcons(IconRegister register) { diff --git a/common/mekanism/common/item/ItemJetpack.java b/common/mekanism/common/item/ItemJetpack.java index 8f010887a..c2f85a3fc 100644 --- a/common/mekanism/common/item/ItemJetpack.java +++ b/common/mekanism/common/item/ItemJetpack.java @@ -30,7 +30,7 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { public int MAX_GAS = 24000; public int TRANSFER_RATE = 16; - + public ItemJetpack(int id) { super(id, EnumHelper.addArmorMaterial("JETPACK", 0, new int[] {0, 0, 0, 0}, 0), 0, 1); @@ -38,16 +38,16 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor setMaxDamage(100); setNoRepair(); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} - + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { GasStack gasStack = getGas(itemstack); - + if(gasStack == null) { list.add("No gas stored."); @@ -55,28 +55,28 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor else { list.add("Stored " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); } - + list.add(EnumColor.GREY + "Mode: " + EnumColor.GREY + getMode(itemstack).getName()); } - + @Override - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { - return armorType == 1; - } - + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) + { + return armorType == 1; + } + @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { + { return "mekanism:render/NullArmor.png"; - } - + } + @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) + { ModelCustomArmor model = ModelCustomArmor.INSTANCE; - + if(this == Mekanism.Jetpack) { model.modelType = ArmorModel.JETPACK; @@ -85,20 +85,20 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { model.modelType = ArmorModel.ARMOREDJETPACK; } - - return model; - } - + + return model; + } + public void incrementMode(ItemStack stack) { setMode(stack, getMode(stack).increment()); } - + public void useGas(ItemStack stack) { setGas(stack, new GasStack(getGas(stack).getGas(), getGas(stack).amount-1)); } - + @Override public int getMaxGas(ItemStack itemstack) { @@ -106,27 +106,27 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor } @Override - public int getRate(ItemStack itemstack) + public int getRate(ItemStack itemstack) { return TRANSFER_RATE; } @Override - public int addGas(ItemStack itemstack, GasStack stack) + public int addGas(ItemStack itemstack, GasStack stack) { if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { return 0; } - + if(stack.getGas() != GasRegistry.getGas("hydrogen")) { return 0; } - + int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); - + return toUse; } @@ -137,32 +137,32 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { return null; } - + Gas type = getGas(itemstack).getGas(); - + int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); setGas(itemstack, new GasStack(type, getStored(itemstack)-gasToUse)); - + return new GasStack(type, gasToUse); } - + public int getStored(ItemStack itemstack) { return getGas(itemstack) != null ? getGas(itemstack).amount : 0; } - + @Override public boolean canReceiveGas(ItemStack itemstack, Gas type) { return type == GasRegistry.getGas("hydrogen"); } - + @Override public boolean canProvideGas(ItemStack itemstack, Gas type) { return getGas(itemstack) != null && (type == null || getGas(itemstack).getGas() == type); } - + @Override public GasStack getGas(ItemStack itemstack) { @@ -170,9 +170,9 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { return null; } - + GasStack stored = GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); - + if(stored == null) { itemstack.setItemDamage(100); @@ -180,30 +180,30 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor else { itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored.amount/getMaxGas(itemstack))*100)-100)))); } - + return stored; } - + public JetpackMode getMode(ItemStack stack) { if(stack.stackTagCompound == null) { return JetpackMode.NORMAL; } - + return JetpackMode.values()[stack.stackTagCompound.getInteger("mode")]; } - + public void setMode(ItemStack stack, JetpackMode mode) { if(stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); } - + stack.stackTagCompound.setInteger("mode", mode.ordinal()); } - + @Override public void setGas(ItemStack itemstack, GasStack stack) { @@ -211,7 +211,7 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { itemstack.setTagCompound(new NBTTagCompound()); } - + if(stack == null || stack.amount == 0) { itemstack.setItemDamage(100); @@ -220,12 +220,12 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor else { int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); GasStack gasStack = new GasStack(stack.getGas(), amount); - + itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)amount/getMaxGas(itemstack))*100)-100)))); itemstack.stackTagCompound.setCompoundTag("stored", gasStack.write(new NBTTagCompound())); } } - + public ItemStack getEmptyItem() { ItemStack empty = new ItemStack(this); @@ -233,7 +233,7 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor empty.setItemDamage(100); return empty; } - + @Override public void getSubItems(int i, CreativeTabs tabs, List list) { @@ -241,32 +241,32 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor setGas(empty, null); empty.setItemDamage(100); list.add(empty); - + ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(GasRegistry.getGas("hydrogen"), ((IGasItem)filled.getItem()).getMaxGas(filled))); list.add(filled); } - + public static enum JetpackMode { NORMAL("tooltip.jetpack.regular", EnumColor.DARK_GREEN), HOVER("tooltip.jetpack.hover", EnumColor.DARK_AQUA), DISABLED("tooltip.jetpack.disabled", EnumColor.DARK_RED); - + private String unlocalized; private EnumColor color; - + private JetpackMode(String s, EnumColor c) { unlocalized = s; color = c; } - + public JetpackMode increment() { return ordinal() < values().length-1 ? values()[ordinal()+1] : values()[0]; } - + public String getName() { return color + MekanismUtils.localize(unlocalized); @@ -284,7 +284,7 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { return new ArmorProperties(1, 0.8, 5); } - + return new ArmorProperties(0, 0, 0); } @@ -299,7 +299,7 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { return 12; } - + return 0; } diff --git a/common/mekanism/common/item/ItemMekanism.java b/common/mekanism/common/item/ItemMekanism.java index 51fe5d123..918a40ee9 100644 --- a/common/mekanism/common/item/ItemMekanism.java +++ b/common/mekanism/common/item/ItemMekanism.java @@ -4,14 +4,14 @@ import mekanism.common.Mekanism; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.item.Item; -public class ItemMekanism extends Item +public class ItemMekanism extends Item { public ItemMekanism(int i) { super(i); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void registerIcons(IconRegister register) { diff --git a/common/mekanism/common/item/ItemNetworkReader.java b/common/mekanism/common/item/ItemNetworkReader.java index d40e9f754..7099efee8 100644 --- a/common/mekanism/common/item/ItemNetworkReader.java +++ b/common/mekanism/common/item/ItemNetworkReader.java @@ -13,58 +13,58 @@ import net.minecraft.world.World; public class ItemNetworkReader extends ItemEnergized { public static double ENERGY_PER_USE = 400; - + public ItemNetworkReader(int id) - { - super(id, 60000, 120); - } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - - if(tileEntity instanceof IGridTransmitter) - { - if(getEnergy(stack) >= ENERGY_PER_USE) - { - setEnergy(stack, getEnergy(stack)-ENERGY_PER_USE); - - IGridTransmitter transmitter = (IGridTransmitter)tileEntity; - - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getSize())); - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getAcceptorSize())); - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getNeeded())); + { + super(id, 60000, 120); + } + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + if(!world.isRemote) + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + if(tileEntity instanceof IGridTransmitter) + { + if(getEnergy(stack) >= ENERGY_PER_USE) + { + setEnergy(stack, getEnergy(stack)-ENERGY_PER_USE); + + IGridTransmitter transmitter = (IGridTransmitter)tileEntity; + + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getSize())); + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getAcceptorSize())); + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getNeeded())); player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getStored())); - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getFlow())); - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getCapacity() + "/tick")); - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - } - - if(player.isSneaking() && Mekanism.debug) - { - String[] strings = TransmitterNetworkRegistry.getInstance().toStrings(); - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "---------- " + EnumColor.DARK_BLUE + "[Mekanism Debug]" + EnumColor.GREY + " ----------")); - - for(String s : strings) - { - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_GREY + s)); - } - - player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - } - - return false; - } - - @Override - public boolean canSend(ItemStack itemstack) - { - return false; - } + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getFlow())); + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().getCapacity() + "/tick")); + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + } + } + + if(player.isSneaking() && Mekanism.debug) + { + String[] strings = TransmitterNetworkRegistry.getInstance().toStrings(); + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "---------- " + EnumColor.DARK_BLUE + "[Mekanism Debug]" + EnumColor.GREY + " ----------")); + + for(String s : strings) + { + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_GREY + s)); + } + + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + } + } + + return false; + } + + @Override + public boolean canSend(ItemStack itemstack) + { + return false; + } } diff --git a/common/mekanism/common/item/ItemPortableTeleporter.java b/common/mekanism/common/item/ItemPortableTeleporter.java index 2cf253591..fb1c8375a 100644 --- a/common/mekanism/common/item/ItemPortableTeleporter.java +++ b/common/mekanism/common/item/ItemPortableTeleporter.java @@ -16,35 +16,35 @@ public class ItemPortableTeleporter extends ItemEnergized { super(id, 1000000, 120); } - + @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { entityplayer.openGui(Mekanism.instance, 14, world, 0, 0, 0); return itemstack; } - + public int calculateEnergyCost(Entity entity, Coord4D coords) { if(coords == null) { return 0; } - + int neededEnergy = 1000; - + if(entity.worldObj.provider.dimensionId != coords.dimensionId) { neededEnergy+=10000; } - + int distance = (int)entity.getDistance(coords.xCoord, coords.yCoord, coords.zCoord); - + neededEnergy+=(distance*10); - + return neededEnergy; } - + public String getStatusAsString(int i) { switch(i) @@ -63,17 +63,17 @@ public class ItemPortableTeleporter extends ItemEnergized return EnumColor.DARK_RED + MekanismUtils.localize("gui.teleporter.notReady"); } } - + public int getStatus(ItemStack itemstack) { - if(itemstack.stackTagCompound == null) - { + if(itemstack.stackTagCompound == null) + { return 0; } - + return itemstack.stackTagCompound.getInteger("status"); } - + public void setStatus(ItemStack itemstack, int status) { if(itemstack.stackTagCompound == null) @@ -83,17 +83,17 @@ public class ItemPortableTeleporter extends ItemEnergized itemstack.stackTagCompound.setInteger("status", status); } - + public int getDigit(ItemStack itemstack, int index) { - if(itemstack.stackTagCompound == null) - { - return 0; + if(itemstack.stackTagCompound == null) + { + return 0; } - + return itemstack.stackTagCompound.getInteger("digit"+index); } - + public void setDigit(ItemStack itemstack, int index, int digit) { if(itemstack.stackTagCompound == null) @@ -103,7 +103,7 @@ public class ItemPortableTeleporter extends ItemEnergized itemstack.stackTagCompound.setInteger("digit"+index, digit); } - + @Override public boolean canSend(ItemStack itemStack) { diff --git a/common/mekanism/common/item/ItemProxy.java b/common/mekanism/common/item/ItemProxy.java index 882826f70..9377784f7 100644 --- a/common/mekanism/common/item/ItemProxy.java +++ b/common/mekanism/common/item/ItemProxy.java @@ -17,32 +17,32 @@ public class ItemProxy extends Item super(id); setMaxDamage(1); } - + @Override public ItemStack getContainerItemStack(ItemStack stack) { return getSavedItem(stack) != null ? getSavedItem(stack) : getDead(); } - + @Override public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) { return stack.stackTagCompound == null || !stack.stackTagCompound.getBoolean("hasStack"); } - + @Override public boolean hasContainerItem() { return true; //TODO forge PR } - + public void setSavedItem(ItemStack stack, ItemStack save) { if(stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); } - + if(save == null) { stack.stackTagCompound.setBoolean("hasStack", false); @@ -53,28 +53,28 @@ public class ItemProxy extends Item stack.stackTagCompound.setCompoundTag("savedItem", save.writeToNBT(new NBTTagCompound())); } } - + public ItemStack getSavedItem(ItemStack stack) { if(stack.stackTagCompound == null) { return null; } - + if(stack.stackTagCompound.getBoolean("hasStack")) { return ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("savedItem")); } - + return null; } - + public static ItemStack getDead() { ItemStack stack = new ItemStack(Mekanism.ItemProxy); stack.stackSize = 0; stack.setItemDamage(2); - + return stack; } diff --git a/common/mekanism/common/item/ItemRobit.java b/common/mekanism/common/item/ItemRobit.java index 68c18c5b9..9327adb48 100644 --- a/common/mekanism/common/item/ItemRobit.java +++ b/common/mekanism/common/item/ItemRobit.java @@ -23,26 +23,26 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory { super(id, 100000, 120); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { + { super.addInformation(itemstack, entityplayer, list, flag); - + list.add(EnumColor.INDIGO + "Name: " + EnumColor.GREY + getName(itemstack)); list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } - + @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float posX, float posY, float posZ) - { + public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float posX, float posY, float posZ) + { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof TileEntityChargepad) { TileEntityChargepad chargepad = (TileEntityChargepad)tileEntity; @@ -51,84 +51,84 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory if(!world.isRemote) { EntityRobit robit = new EntityRobit(world, x+0.5, y+0.1, z+0.5); - + robit.setHome(Coord4D.get(chargepad)); robit.setEnergy(getEnergy(itemstack)); robit.setOwner(entityplayer.username); robit.setInventory(getInventory(itemstack)); robit.setName(getName(itemstack)); - + world.spawnEntityInWorld(robit); } - + entityplayer.setCurrentItemOrArmor(0, null); - + return true; } } - - return false; - } - + + return false; + } + @Override public boolean canSend(ItemStack itemStack) { return false; } - + public void setName(ItemStack itemstack, String name) { if(itemstack.stackTagCompound == null) { itemstack.setTagCompound(new NBTTagCompound()); } - + itemstack.stackTagCompound.setString("name", name); } - + public String getName(ItemStack itemstack) { if(itemstack.stackTagCompound == null) { return "Robit"; } - + String name = itemstack.stackTagCompound.getString("name"); - + return name.equals("") ? "Robit" : name; } - + @Override - public void setInventory(NBTTagList nbtTags, Object... data) + public void setInventory(NBTTagList nbtTags, Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - + if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setTag("Items", nbtTags); } } @Override - public NBTTagList getInventory(Object... data) + public NBTTagList getInventory(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - - if(itemStack.stackTagCompound == null) - { - return null; + + if(itemStack.stackTagCompound == null) + { + return null; } - + return itemStack.stackTagCompound.getTagList("Items"); } - + return null; } } diff --git a/common/mekanism/common/item/ItemScubaTank.java b/common/mekanism/common/item/ItemScubaTank.java index b8e51a7d0..17cede912 100644 --- a/common/mekanism/common/item/ItemScubaTank.java +++ b/common/mekanism/common/item/ItemScubaTank.java @@ -27,7 +27,7 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { public int MAX_GAS = 24000; public int TRANSFER_RATE = 16; - + public ItemScubaTank(int id) { super(id, EnumHelper.addArmorMaterial("SCUBATANK", 0, new int[] {0, 0, 0, 0}, 0), 0, 1); @@ -35,12 +35,12 @@ public class ItemScubaTank extends ItemArmor implements IGasItem setMaxDamage(100); setNoRepair(); } - + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { GasStack gasStack = getGas(itemstack); - + if(gasStack == null) { list.add("No gas stored."); @@ -48,36 +48,36 @@ public class ItemScubaTank extends ItemArmor implements IGasItem else { list.add("Stored " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); } - + list.add(EnumColor.GREY + "Flowing: " + (getFlowing(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + getFlowing(itemstack)); } - + @Override - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { - return armorType == 1; - } - + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) + { + return armorType == 1; + } + @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { + { return "mekanism:render/NullArmor.png"; - } - + } + @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) + { ModelCustomArmor model = ModelCustomArmor.INSTANCE; model.modelType = ArmorModel.SCUBATANK; - return model; - } - + return model; + } + public void useGas(ItemStack stack) { setGas(stack, new GasStack(getGas(stack).getGas(), getGas(stack).amount-1)); } - + @Override public int getMaxGas(ItemStack itemstack) { @@ -85,27 +85,27 @@ public class ItemScubaTank extends ItemArmor implements IGasItem } @Override - public int getRate(ItemStack itemstack) + public int getRate(ItemStack itemstack) { return TRANSFER_RATE; } @Override - public int addGas(ItemStack itemstack, GasStack stack) + public int addGas(ItemStack itemstack, GasStack stack) { if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { return 0; } - + if(stack.getGas() != GasRegistry.getGas("oxygen")) { return 0; } - + int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); - + return toUse; } @@ -116,57 +116,57 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { return null; } - + Gas type = getGas(itemstack).getGas(); - + int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); setGas(itemstack, new GasStack(type, getStored(itemstack)-gasToUse)); - + return new GasStack(type, gasToUse); } - + public int getStored(ItemStack itemstack) { return getGas(itemstack) != null ? getGas(itemstack).amount : 0; } - + public void toggleFlowing(ItemStack stack) { setFlowing(stack, !getFlowing(stack)); } - + public boolean getFlowing(ItemStack stack) { if(stack.stackTagCompound == null) { return false; } - + return stack.stackTagCompound.getBoolean("flowing"); } - + public void setFlowing(ItemStack stack, boolean flowing) { if(stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); } - + stack.stackTagCompound.setBoolean("flowing", flowing); } - + @Override public boolean canReceiveGas(ItemStack itemstack, Gas type) { return type == GasRegistry.getGas("oxygen"); } - + @Override public boolean canProvideGas(ItemStack itemstack, Gas type) { return getGas(itemstack) != null && (type == null || getGas(itemstack).getGas() == type); } - + @Override public GasStack getGas(ItemStack itemstack) { @@ -174,9 +174,9 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { return null; } - + GasStack stored = GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); - + if(stored == null) { itemstack.setItemDamage(100); @@ -184,10 +184,10 @@ public class ItemScubaTank extends ItemArmor implements IGasItem else { itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)stored.amount/getMaxGas(itemstack))*100)-100)))); } - + return stored; } - + @Override public void setGas(ItemStack itemstack, GasStack stack) { @@ -195,7 +195,7 @@ public class ItemScubaTank extends ItemArmor implements IGasItem { itemstack.setTagCompound(new NBTTagCompound()); } - + if(stack == null || stack.amount == 0) { itemstack.setItemDamage(100); @@ -204,12 +204,12 @@ public class ItemScubaTank extends ItemArmor implements IGasItem else { int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); GasStack gasStack = new GasStack(stack.getGas(), amount); - + itemstack.setItemDamage((int)Math.max(1, (Math.abs((((float)amount/getMaxGas(itemstack))*100)-100)))); itemstack.stackTagCompound.setCompoundTag("stored", gasStack.write(new NBTTagCompound())); } } - + public ItemStack getEmptyItem() { ItemStack empty = new ItemStack(this); @@ -217,7 +217,7 @@ public class ItemScubaTank extends ItemArmor implements IGasItem empty.setItemDamage(100); return empty; } - + @Override public void getSubItems(int i, CreativeTabs tabs, List list) { @@ -225,12 +225,12 @@ public class ItemScubaTank extends ItemArmor implements IGasItem setGas(empty, null); empty.setItemDamage(100); list.add(empty); - + ItemStack filled = new ItemStack(this); setGas(filled, new GasStack(GasRegistry.getGas("oxygen"), ((IGasItem)filled.getItem()).getMaxGas(filled))); list.add(filled); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} diff --git a/common/mekanism/common/item/ItemShard.java b/common/mekanism/common/item/ItemShard.java index 2d07895c5..b6ede5be2 100644 --- a/common/mekanism/common/item/ItemShard.java +++ b/common/mekanism/common/item/ItemShard.java @@ -12,14 +12,14 @@ import net.minecraft.util.Icon; public class ItemShard extends ItemMekanism { public Icon[] icons = new Icon[256]; - + public ItemShard(int id) { super(id); setHasSubtypes(true); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void registerIcons(IconRegister register) { diff --git a/common/mekanism/common/item/ItemWalkieTalkie.java b/common/mekanism/common/item/ItemWalkieTalkie.java index 37e27228d..3fe63ae14 100644 --- a/common/mekanism/common/item/ItemWalkieTalkie.java +++ b/common/mekanism/common/item/ItemWalkieTalkie.java @@ -15,22 +15,22 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemWalkieTalkie extends ItemMekanism { public Icon[] icons = new Icon[256]; - + public ItemWalkieTalkie(int id) { super(id); setMaxStackSize(1); } - + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { super.addInformation(itemstack, entityplayer, list, flag); - + list.add(getOn(itemstack) ? EnumColor.DARK_GREEN + "On" : EnumColor.DARK_RED + "Off"); list.add(EnumColor.DARK_AQUA + "Channel: " + EnumColor.GREY + getChannel(itemstack)); } - + @Override public Icon getIconIndex(ItemStack itemStack) { @@ -38,21 +38,21 @@ public class ItemWalkieTalkie extends ItemMekanism { return icons[0]; } - + return icons[getChannel(itemStack)]; - } - + } + @Override public void registerIcons(IconRegister register) { icons[0] = register.registerIcon("mekanism:WalkieTalkieOff"); - + for(int i = 1; i <= 9; i++) { icons[i] = register.registerIcon("mekanism:WalkieTalkie_ch" + i); } } - + @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { @@ -60,31 +60,31 @@ public class ItemWalkieTalkie extends ItemMekanism { setOn(itemStack, !getOn(itemStack)); } - + return itemStack; } - + public void setOn(ItemStack itemStack, boolean on) { if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setBoolean("on", on); } - + public boolean getOn(ItemStack itemStack) { if(itemStack.stackTagCompound == null) { return false; } - + return itemStack.stackTagCompound.getBoolean("on"); } - - public void setChannel(ItemStack itemStack, int channel) + + public void setChannel(ItemStack itemStack, int channel) { if(itemStack.stackTagCompound == null) { @@ -94,20 +94,20 @@ public class ItemWalkieTalkie extends ItemMekanism itemStack.stackTagCompound.setInteger("channel", channel); } - public int getChannel(ItemStack itemStack) + public int getChannel(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 1; + if(itemStack.stackTagCompound == null) + { + return 1; } - + int channel = itemStack.stackTagCompound.getInteger("channel"); - + if(channel == 0) { setChannel(itemStack, 1); } - + return itemStack.stackTagCompound.getInteger("channel"); } } diff --git a/common/mekanism/common/miner/MItemStackFilter.java b/common/mekanism/common/miner/MItemStackFilter.java index d2fb6477a..1d58c4eca 100644 --- a/common/mekanism/common/miner/MItemStackFilter.java +++ b/common/mekanism/common/miner/MItemStackFilter.java @@ -13,18 +13,18 @@ import com.google.common.io.ByteArrayDataInput; public class MItemStackFilter extends MinerFilter { private static List metaIgnoreArray = ListUtils.asList(Block.planks.blockID, Block.ladder.blockID, Block.torchWood.blockID, - Block.furnaceBurning.blockID, Block.furnaceIdle.blockID, Block.dispenser.blockID, Block.pistonBase.blockID, + Block.furnaceBurning.blockID, Block.furnaceIdle.blockID, Block.dispenser.blockID, Block.pistonBase.blockID, Block.pistonExtension.blockID, Block.pistonStickyBase.blockID, Block.pistonMoving.blockID); - + public ItemStack itemType; - + public MItemStackFilter(ItemStack item) { itemType = item; } - + public MItemStackFilter() {} - + @Override public boolean canFilter(ItemStack itemStack) { @@ -32,48 +32,48 @@ public class MItemStackFilter extends MinerFilter { return false; } - + if(itemStack.itemID == itemType.itemID && metaIgnoreArray.contains(itemType.itemID)) { return true; } - + return itemType.isItemEqual(itemStack); } - + @Override public NBTTagCompound write(NBTTagCompound nbtTags) { nbtTags.setInteger("type", 0); itemType.writeToNBT(nbtTags); - + return nbtTags; } - + @Override protected void read(NBTTagCompound nbtTags) { itemType = ItemStack.loadItemStackFromNBT(nbtTags); } - + @Override public void write(ArrayList data) { data.add(0); - + data.add(itemType.itemID); data.add(itemType.stackSize); data.add(itemType.getItemDamage()); } - + @Override protected void read(ByteArrayDataInput dataStream) { itemType = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + itemType.itemID; @@ -81,19 +81,19 @@ public class MItemStackFilter extends MinerFilter code = 31 * code + itemType.getItemDamage(); return code; } - + @Override public boolean equals(Object filter) { return super.equals(filter) && filter instanceof MItemStackFilter && ((MItemStackFilter)filter).itemType.isItemEqual(itemType); } - + @Override public MItemStackFilter clone() { MItemStackFilter filter = new MItemStackFilter(); filter.itemType = itemType.copy(); - + return filter; } } diff --git a/common/mekanism/common/miner/MOreDictFilter.java b/common/mekanism/common/miner/MOreDictFilter.java index 7ed5ef5c3..393330054 100644 --- a/common/mekanism/common/miner/MOreDictFilter.java +++ b/common/mekanism/common/miner/MOreDictFilter.java @@ -12,7 +12,7 @@ import com.google.common.io.ByteArrayDataInput; public class MOreDictFilter extends MinerFilter { public String oreDictName; - + @Override public boolean canFilter(ItemStack itemStack) { @@ -20,58 +20,58 @@ public class MOreDictFilter extends MinerFilter { return false; } - + return new OreDictFinder(oreDictName).modifies(itemStack); } - + @Override public NBTTagCompound write(NBTTagCompound nbtTags) { nbtTags.setInteger("type", 1); nbtTags.setString("oreDictName", oreDictName); - + return nbtTags; } - + @Override protected void read(NBTTagCompound nbtTags) { oreDictName = nbtTags.getString("oreDictName"); } - + @Override public void write(ArrayList data) { data.add(1); data.add(oreDictName); } - + @Override protected void read(ByteArrayDataInput dataStream) { oreDictName = dataStream.readUTF(); } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + oreDictName.hashCode(); return code; } - + @Override public boolean equals(Object filter) { return super.equals(filter) && filter instanceof MOreDictFilter && ((MOreDictFilter)filter).oreDictName.equals(oreDictName); } - + @Override public MOreDictFilter clone() { MOreDictFilter filter = new MOreDictFilter(); filter.oreDictName = oreDictName; - + return filter; } } diff --git a/common/mekanism/common/miner/MinerFilter.java b/common/mekanism/common/miner/MinerFilter.java index 4f1e7f9d8..4a52b8adc 100644 --- a/common/mekanism/common/miner/MinerFilter.java +++ b/common/mekanism/common/miner/MinerFilter.java @@ -7,24 +7,24 @@ import net.minecraft.nbt.NBTTagCompound; import com.google.common.io.ByteArrayDataInput; -public abstract class MinerFilter +public abstract class MinerFilter { public abstract boolean canFilter(ItemStack itemStack); - + public abstract NBTTagCompound write(NBTTagCompound nbtTags); - + protected abstract void read(NBTTagCompound nbtTags); - + public abstract void write(ArrayList data); - + protected abstract void read(ByteArrayDataInput dataStream); - + public static MinerFilter readFromNBT(NBTTagCompound nbtTags) { int type = nbtTags.getInteger("type"); - + MinerFilter filter = null; - + if(type == 0) { filter = new MItemStackFilter(); @@ -32,18 +32,18 @@ public abstract class MinerFilter else { filter = new MOreDictFilter(); } - + filter.read(nbtTags); - + return filter; } - + public static MinerFilter readFromPacket(ByteArrayDataInput dataStream) { int type = dataStream.readInt(); - + MinerFilter filter = null; - + if(type == 0) { filter = new MItemStackFilter(); @@ -52,12 +52,12 @@ public abstract class MinerFilter { filter = new MOreDictFilter(); } - + filter.read(dataStream); - + return filter; } - + @Override public boolean equals(Object filter) { diff --git a/common/mekanism/common/miner/ThreadMinerSearch.java b/common/mekanism/common/miner/ThreadMinerSearch.java index 42939e0eb..23932ad01 100644 --- a/common/mekanism/common/miner/ThreadMinerSearch.java +++ b/common/mekanism/common/miner/ThreadMinerSearch.java @@ -15,83 +15,83 @@ import net.minecraft.item.ItemStack; public class ThreadMinerSearch extends Thread { public TileEntityDigitalMiner tileEntity; - + public State state = State.IDLE; - + public BitSet oresToMine = new BitSet(); - + public Map acceptedItems = new HashMap(); - + public int found = 0; - + public ThreadMinerSearch(TileEntityDigitalMiner tile) { tileEntity = tile; } - + @Override public void run() { state = State.SEARCHING; - + if(!tileEntity.inverse && tileEntity.filters.isEmpty()) { state = State.FINISHED; return; } - + Coord4D coord = tileEntity.getStartingCoord(); int diameter = tileEntity.getDiameter(); int size = tileEntity.getTotalSize(); ItemInfo info = new ItemInfo(0,0); - + for(int i = 0; i < size; i++) { int x = coord.xCoord+i%diameter; int z = coord.zCoord+(i/diameter)%diameter; int y = coord.yCoord+(i/diameter/diameter); - + if(tileEntity.isInvalid()) { return; } - + if(tileEntity.xCoord == x && tileEntity.yCoord == y && tileEntity.zCoord == z) { continue; } - + if(!tileEntity.worldObj.getChunkProvider().chunkExists(x >> 4, z >> 4)) { continue; } - + if(tileEntity.worldObj.getBlockTileEntity(x, y, z) instanceof IBoundingBlock) { continue; } - + info.id = tileEntity.worldObj.getBlockId(x, y, z); info.meta = tileEntity.worldObj.getBlockMetadata(x, y, z); - + if(info.id != 0 && info.id != Block.bedrock.blockID) { boolean canFilter = false; - + if(acceptedItems.containsKey(info)) { canFilter = acceptedItems.get(info); } else { ItemStack stack = new ItemStack(info.id, 1, info.meta); - + if(tileEntity.replaceStack != null && tileEntity.replaceStack.isItemEqual(stack)) { continue; } - + boolean hasFilter = false; - + for(MinerFilter filter : tileEntity.filters) { if(filter.canFilter(stack)) @@ -99,11 +99,11 @@ public class ThreadMinerSearch extends Thread hasFilter = true; } } - + canFilter = tileEntity.inverse ? !hasFilter : hasFilter; acceptedItems.put(info, canFilter); } - + if(canFilter) { oresToMine.set(i); @@ -111,26 +111,26 @@ public class ThreadMinerSearch extends Thread } } } - + state = State.FINISHED; tileEntity.oresToMine = oresToMine; MekanismUtils.saveChunk(tileEntity); } - + public void reset() { state = State.IDLE; } - + public static enum State { - IDLE("Not ready"), - SEARCHING("Searching"), + IDLE("Not ready"), + SEARCHING("Searching"), PAUSED("Paused"), FINISHED("Ready"); - + public String desc; - + private State(String s) { desc = s; diff --git a/common/mekanism/common/multipart/ItemPartTransmitter.java b/common/mekanism/common/multipart/ItemPartTransmitter.java index acef93682..6849eae7c 100644 --- a/common/mekanism/common/multipart/ItemPartTransmitter.java +++ b/common/mekanism/common/multipart/ItemPartTransmitter.java @@ -36,7 +36,7 @@ public class ItemPartTransmitter extends JItemMultiPart setHasSubtypes(true); setCreativeTab(Mekanism.tabMekanism); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister register) {} @@ -45,23 +45,23 @@ public class ItemPartTransmitter extends JItemMultiPart public TMultiPart newPart(ItemStack stack, EntityPlayer player, World world, BlockCoord coord, int face, Vector3 vecHit) { TransmitterType type = TransmitterType.values()[stack.getItemDamage()]; - + if(type.getTransmission() != TransmissionType.ITEM) { Coord4D obj = new Coord4D(coord.x, coord.y, coord.z, world.provider.dimensionId); - + List> networks = new ArrayList>(); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = obj.getFromSide(side).getTileEntity(world); - + if(tile instanceof IGridTransmitter && TransmissionType.checkTransmissionType(tile, type.getTransmission())) { networks.add(((IGridTransmitter)tile).getTransmitterNetwork()); } } - + if(networks.size() > 0) { if(!networks.iterator().next().canMerge(networks)) @@ -70,10 +70,10 @@ public class ItemPartTransmitter extends JItemMultiPart } } } - + return PartTransmitter.getPartType(TransmitterType.values()[getDamage(stack)]); } - + @Override public int getMetadata(int damage) { @@ -90,7 +90,7 @@ public class ItemPartTransmitter extends JItemMultiPart { list.add(EnumColor.INDIGO + "Capacity: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(Tier.CableTier.values()[itemstack.getItemDamage()].cableCapacity) + "/t"); } - + list.add("Hold " + EnumColor.AQUA + "shift" + EnumColor.GREY + " for details."); } else { @@ -144,26 +144,26 @@ public class ItemPartTransmitter extends JItemMultiPart } } } - - @Override - public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo) - { - for(TransmitterType type : TransmitterType.values()) - { - listToAddTo.add(new ItemStack(itemID, 1, type.ordinal())); - } - } - - @Override - @SideOnly(Side.CLIENT) - public int getSpriteNumber() - { - return 0; - } - - @Override - public String getUnlocalizedName(ItemStack stack) - { - return getUnlocalizedName() + "." + TransmitterType.values()[stack.getItemDamage()].getName(); - } + + @Override + public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo) + { + for(TransmitterType type : TransmitterType.values()) + { + listToAddTo.add(new ItemStack(itemID, 1, type.ordinal())); + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getSpriteNumber() + { + return 0; + } + + @Override + public String getUnlocalizedName(ItemStack stack) + { + return getUnlocalizedName() + "." + TransmitterType.values()[stack.getItemDamage()].getName(); + } } diff --git a/common/mekanism/common/multipart/MultipartMekanism.java b/common/mekanism/common/multipart/MultipartMekanism.java index 3e956e42f..f6021e4d5 100644 --- a/common/mekanism/common/multipart/MultipartMekanism.java +++ b/common/mekanism/common/multipart/MultipartMekanism.java @@ -13,7 +13,7 @@ public class MultipartMekanism implements IPartFactory { init(); } - + public void init() { MultiPartRegistry.registerParts(this, new String[] {"mekanism:universal_cable_basic", @@ -21,7 +21,7 @@ public class MultipartMekanism implements IPartFactory "mekanism:universal_cable_ultimate", "mekanism:mechanical_pipe", "mekanism:pressurized_tube", "mekanism:logistical_transporter", "mekanism:restrictive_transporter", "mekanism:diversion_transporter"}); - + MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.ITransmitter"); MultipartGenerator.registerPassThroughInterface("mekanism.api.energy.IStrictEnergyAcceptor"); MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.IGridTransmitter"); @@ -78,7 +78,7 @@ public class MultipartMekanism implements IPartFactory { return new PartDiversionTransporter(); } - + return null; } } diff --git a/common/mekanism/common/multipart/PartDiversionTransporter.java b/common/mekanism/common/multipart/PartDiversionTransporter.java index 4d4b33f71..0261b759d 100644 --- a/common/mekanism/common/multipart/PartDiversionTransporter.java +++ b/common/mekanism/common/multipart/PartDiversionTransporter.java @@ -20,46 +20,46 @@ import com.google.common.io.ByteArrayDataInput; public class PartDiversionTransporter extends PartLogisticalTransporter { public int[] modes = {0, 0, 0, 0, 0, 0}; - + @Override public String getType() { return "mekanism:diversion_transporter"; } - + @Override public TransmitterType getTransmitter() { return TransmitterType.DIVERSION_TRANSPORTER; } - + @Override public Icon getCenterIcon() { return transporterIcons.getCenterIcon(2); } - + @Override public void load(NBTTagCompound nbtTags) { super.load(nbtTags); - + modes = nbtTags.getIntArray("modes"); } - + @Override public void save(NBTTagCompound nbtTags) { super.save(nbtTags); - + nbtTags.setIntArray("modes", modes); } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + modes[0] = dataStream.readInt(); modes[1] = dataStream.readInt(); modes[2] = dataStream.readInt(); @@ -67,45 +67,45 @@ public class PartDiversionTransporter extends PartLogisticalTransporter modes[4] = dataStream.readInt(); modes[5] = dataStream.readInt(); } - + @Override public ArrayList getNetworkedData(ArrayList data) { data = super.getNetworkedData(data); - + data.add(modes[0]); data.add(modes[1]); data.add(modes[2]); data.add(modes[3]); data.add(modes[4]); data.add(modes[5]); - + return data; } - + @Override public ArrayList getSyncPacket(TransporterStack stack, boolean kill) { ArrayList data = super.getSyncPacket(stack, kill); - + data.add(modes[0]); data.add(modes[1]); data.add(modes[2]); data.add(modes[3]); data.add(modes[4]); data.add(modes[5]); - + return data; } - + @Override protected boolean onConfigure(EntityPlayer player, int part, int side) { int newMode = (modes[side] + 1) % 3; String description = "ERROR"; - + modes[side] = newMode; - + switch(newMode) { case 0: @@ -118,15 +118,15 @@ public class PartDiversionTransporter extends PartLogisticalTransporter description = MekanismUtils.localize("control.low.desc"); break; } - + refreshConnections(); tile().notifyPartChange(this); player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description)); PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tile()), getNetworkedData(new ArrayList())), Coord4D.get(tile()), 50D); - + return true; } - + @Override public boolean canConnect(ForgeDirection side) { @@ -134,15 +134,15 @@ public class PartDiversionTransporter extends PartLogisticalTransporter { return false; } - - int mode = modes[side.ordinal()]; - boolean redstone = world().isBlockIndirectlyGettingPowered(x(), y(), z()); - - if((mode == 2 && redstone == true) || (mode == 1 && redstone == false)) - { - return false; - } - - return true; + + int mode = modes[side.ordinal()]; + boolean redstone = world().isBlockIndirectlyGettingPowered(x(), y(), z()); + + if((mode == 2 && redstone == true) || (mode == 1 && redstone == false)) + { + return false; + } + + return true; } } diff --git a/common/mekanism/common/multipart/PartLogisticalTransporter.java b/common/mekanism/common/multipart/PartLogisticalTransporter.java index 876204c0a..8b5a211c6 100644 --- a/common/mekanism/common/multipart/PartLogisticalTransporter.java +++ b/common/mekanism/common/multipart/PartLogisticalTransporter.java @@ -49,15 +49,15 @@ import cpw.mods.fml.relauncher.SideOnly; public class PartLogisticalTransporter extends PartSidedPipe implements ILogisticalTransporter, IPipeTile { public static TransmitterIcons transporterIcons = new TransmitterIcons(3, 2); - + public static final int SPEED = 5; - + public EnumColor color; - + public int pullDelay = 0; - + public HashList transit = new HashList(); - + public Set needsSync = new HashSet(); @Override @@ -71,7 +71,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { return TransmitterType.LOGISTICAL_TRANSPORTER; } - + @Override public TransmissionType getTransmissionType() { @@ -83,7 +83,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti transporterIcons.registerCenterIcons(register, new String[] {"LogisticalTransporter", "RestrictiveTransporter", "DiversionTransporter"}); transporterIcons.registerSideIcons(register, new String[] {"LogisticalTransporterSide", "RestrictiveTransporterSide"}); } - + @Override @SideOnly(Side.CLIENT) public void renderDynamic(Vector3 pos, float f, int pass) @@ -93,7 +93,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti RenderPartTransmitter.getInstance().renderContents(this, f, pos); } } - + @Override public boolean canConnect(ForgeDirection side) { @@ -102,12 +102,12 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti testingSide = null; return unblocked; } - + @Override public byte getPossibleTransmitterConnections() { byte connections = 0x00; - + if(world().isBlockIndirectlyGettingPowered(x(), y(), z())) { return connections; @@ -122,7 +122,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti if(TransmissionType.checkTransmissionType(tileEntity, getTransmitter().getTransmission())) { ILogisticalTransporter transporter = (ILogisticalTransporter)tileEntity; - + if(getColor() == null || transporter.getColor() == null || getColor() == transporter.getColor()) { connections |= 1 << side.ordinal(); @@ -133,7 +133,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti return connections; } - + @Override public byte getPossibleAcceptorConnections() { @@ -175,12 +175,12 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti @Override public void onModeChange(ForgeDirection side) {} - + @Override public void update() { super.update(); - + if(world().isRemote) { for(TransporterStack stack : transit) @@ -193,9 +193,9 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti } else { Set remove = new HashSet(); - + pullItems(); - + for(TransporterStack stack : transit) { if(!stack.initiatedPath) @@ -206,18 +206,18 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti continue; } } - + stack.progress += SPEED; - + if(stack.progress > 100) { Coord4D prevSet = null; - + if(stack.hasPath()) { int currentIndex = stack.pathToTarget.indexOf(Coord4D.get(tile())); Coord4D next = stack.pathToTarget.get(currentIndex-1); - + if(!stack.isFinal(this)) { if(next != null && stack.canInsertToTransporter(stack.getNext(this).getTileEntity(world()), ForgeDirection.getOrientation(stack.getSide(this)))) @@ -225,7 +225,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti ILogisticalTransporter nextTile = (ILogisticalTransporter)next.getTileEntity(world()); nextTile.entityEntering(stack); remove.add(stack); - + continue; } else if(next != null) @@ -240,11 +240,11 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { needsSync.add(stack); IInventory inventory = (IInventory)next.getTileEntity(world()); - + if(inventory != null) { ItemStack rejected = InventoryUtils.putStackInInventory(inventory, stack.itemStack, stack.getSide(this), stack.pathType == Path.HOME); - + if(rejected == null) { TransporterManager.remove(stack); @@ -254,7 +254,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti else { needsSync.add(stack); stack.itemStack = rejected; - + prevSet = next; } } @@ -262,7 +262,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti } } } - + if(!recalculate(stack, prevSet)) { remove.add(stack); @@ -310,12 +310,12 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti else { TileEntity next = stack.getNext(this).getTileEntity(world()); boolean recalculate = false; - + if(!stack.canInsertToTransporter(next, ForgeDirection.getOrientation(stack.getSide(this)))) { recalculate = true; } - + if(recalculate) { if(!recalculate(stack, null)) @@ -327,14 +327,14 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti } } } - + for(TransporterStack stack : remove) { PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tile()), getSyncPacket(stack, true)), Coord4D.get(tile()), 50D); transit.remove(stack); MekanismUtils.saveChunk(tile()); } - + for(TransporterStack stack : needsSync) { if(transit.contains(stack)) @@ -342,37 +342,37 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tile()), getSyncPacket(stack, false)), Coord4D.get(tile()), 50D); } } - + needsSync.clear(); } } - + private boolean checkSideForInsert(TransporterStack stack) { ForgeDirection side = ForgeDirection.getOrientation(stack.getSide(this)); - + return getConnectionType(side) == ConnectionType.NORMAL || getConnectionType(side) == ConnectionType.PUSH; } - + private void pullItems() { if(pullDelay == 0) { boolean did = false; - + for(ForgeDirection side : getConnections(ConnectionType.PULL)) { TileEntity tile = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - + if(tile instanceof IInventory) { IInventory inv = (IInventory)tile; InvStack stack = InventoryUtils.takeTopItem(inv, side.ordinal()); - + if(stack != null && stack.getStack() != null) { ItemStack rejects = TransporterUtils.insert(tile, this, stack.getStack(), color, true, 0); - + if(TransporterManager.didEmit(stack.getStack(), rejects)) { did = true; @@ -381,7 +381,7 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti } } } - + if(did) { pullDelay = 10; @@ -391,11 +391,11 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti pullDelay--; } } - + private boolean recalculate(TransporterStack stack, Coord4D from) { needsSync.add(stack); - + if(!TransporterManager.didEmit(stack.itemStack, stack.recalculatePath(this, 0))) { if(!stack.calculateIdle(this)) @@ -404,42 +404,42 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti return false; } } - + if(from != null) { stack.originalLocation = from; } - + return true; } - + @Override public ItemStack insert(Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min) { return insert_do(original, itemStack, color, doEmit, min, false); } - + private ItemStack insert_do(Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min, boolean force) { ForgeDirection from = Coord4D.get(tile()).sideDifference(original).getOpposite(); - + TransporterStack stack = new TransporterStack(); stack.itemStack = itemStack; stack.originalLocation = original; stack.homeLocation = original; stack.color = color; - + if((force && !canReceiveFrom(original.getTileEntity(world()), from)) || !stack.canInsertToTransporter(tile(), from)) { return itemStack; } - + ItemStack rejected = stack.recalculatePath(this, min); - + if(TransporterManager.didEmit(stack.itemStack, rejected)) { stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected); - + if(doEmit) { transit.add(stack); @@ -447,35 +447,35 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tile()), getSyncPacket(stack, false)), Coord4D.get(tile()), 50D); MekanismUtils.saveChunk(tile()); } - + return rejected; } - + return itemStack; } - + @Override public ItemStack insertRR(TileEntityLogisticalSorter outputter, ItemStack itemStack, EnumColor color, boolean doEmit, int min) { ForgeDirection from = Coord4D.get(tile()).sideDifference(Coord4D.get(outputter)).getOpposite(); - + TransporterStack stack = new TransporterStack(); stack.itemStack = itemStack; stack.originalLocation = Coord4D.get(outputter); stack.homeLocation = Coord4D.get(outputter); stack.color = color; - + if(!canReceiveFrom(outputter, from) || !stack.canInsertToTransporter(tile(), from)) { return itemStack; } - + ItemStack rejected = stack.recalculateRRPath(outputter, this, min); - + if(TransporterManager.didEmit(stack.itemStack, rejected)) { stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected); - + if(doEmit) { transit.add(stack); @@ -483,13 +483,13 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tile()), getSyncPacket(stack, false)), Coord4D.get(tile()), 50D); MekanismUtils.saveChunk(tile()); } - + return rejected; } - + return itemStack; } - + @Override public void entityEntering(TransporterStack stack) { @@ -498,29 +498,29 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tile()), getSyncPacket(stack, false)), Coord4D.get(tile()), 50D); MekanismUtils.saveChunk(tile()); } - + @Override public void onWorldJoin() { super.onWorldJoin(); - + if(world().isRemote) { PacketHandler.sendPacket(Transmission.SERVER, new PacketDataRequest().setParams(Coord4D.get(tile()))); } } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { int type = dataStream.readInt(); - + if(type == 0) { int c = dataStream.readInt(); - + EnumColor prev = color; - + if(c != -1) { color = TransporterUtils.colors.get(c); @@ -528,16 +528,16 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti else { color = null; } - + if(prev != color) { tile().markRender(); } - + transit.clear(); - + int amount = dataStream.readInt(); - + for(int i = 0; i < amount; i++) { transit.add(TransporterStack.readFromPacket(dataStream)); @@ -547,29 +547,29 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { boolean kill = dataStream.readBoolean(); int index = dataStream.readInt(); - + if(kill) { transit.remove(index); } else { TransporterStack stack = TransporterStack.readFromPacket(dataStream); - + if(stack.progress == 0) { stack.progress = 5; } - + transit.replace(index, stack); } } } - + @Override public ArrayList getNetworkedData(ArrayList data) { data.add(0); - + if(color != null) { data.add(TransporterUtils.colors.indexOf(color)); @@ -577,81 +577,81 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti else { data.add(-1); } - + data.add(transit.size()); - + for(TransporterStack stack : transit) { stack.write(this, data); } - + return data; } - + public ArrayList getSyncPacket(TransporterStack stack, boolean kill) { ArrayList data = new ArrayList(); - + data.add(1); data.add(kill); data.add(transit.indexOf(stack)); - + if(!kill) { stack.write(this, data); } - + return data; } - - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); - - if(nbtTags.hasKey("color")) - { - color = TransporterUtils.colors.get(nbtTags.getInteger("color")); - } - - if(nbtTags.hasKey("stacks")) - { - NBTTagList tagList = nbtTags.getTagList("stacks"); - - for(int i = 0; i < tagList.tagCount(); i++) - { - TransporterStack stack = TransporterStack.readFromNBT((NBTTagCompound)tagList.tagAt(i)); - - transit.add(stack); - TransporterManager.add(stack); - } - } - } @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); - - if(color != null) - { - nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); - } - - NBTTagList stacks = new NBTTagList(); - - for(TransporterStack stack : transit) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - stack.write(tagCompound); - stacks.appendTag(tagCompound); - } - - if(stacks.tagCount() != 0) - { - nbtTags.setTag("stacks", stacks); - } - } + public void load(NBTTagCompound nbtTags) + { + super.load(nbtTags); + + if(nbtTags.hasKey("color")) + { + color = TransporterUtils.colors.get(nbtTags.getInteger("color")); + } + + if(nbtTags.hasKey("stacks")) + { + NBTTagList tagList = nbtTags.getTagList("stacks"); + + for(int i = 0; i < tagList.tagCount(); i++) + { + TransporterStack stack = TransporterStack.readFromNBT((NBTTagCompound)tagList.tagAt(i)); + + transit.add(stack); + TransporterManager.add(stack); + } + } + } + + @Override + public void save(NBTTagCompound nbtTags) + { + super.save(nbtTags); + + if(color != null) + { + nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); + } + + NBTTagList stacks = new NBTTagList(); + + for(TransporterStack stack : transit) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + stack.write(tagCompound); + stacks.appendTag(tagCompound); + } + + if(stacks.tagCount() != 0) + { + nbtTags.setTag("stacks", stacks); + } + } @Override public boolean isSolidOnSide(ForgeDirection side) @@ -660,69 +660,69 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti } @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { return 0; } @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return null; } @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { return null; } @Override - public boolean canFill(ForgeDirection from, Fluid fluid) + public boolean canFill(ForgeDirection from, Fluid fluid) { return false; } @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) + public boolean canDrain(ForgeDirection from, Fluid fluid) { return false; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) + public FluidTankInfo[] getTankInfo(ForgeDirection from) { return PipeUtils.EMPTY; } @Override - public IPipe getPipe() + public IPipe getPipe() { return null; } @Override - public PipeType getPipeType() + public PipeType getPipeType() { return PipeType.ITEM; } @Override - public int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from) + public int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from) { if(doAdd) { TileEntity tile = Coord4D.get(tile()).getFromSide(from).getTileEntity(world()); - + ItemStack rejects = TransporterUtils.insert(tile, this, stack, null, true, 0); return TransporterManager.getToUse(stack, rejects).stackSize; } - + return 0; } @Override - public boolean isPipeConnected(ForgeDirection with) + public boolean isPipeConnected(ForgeDirection with) { return true; } @@ -735,10 +735,10 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti tile().notifyPartChange(this); PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(tile()), getNetworkedData(new ArrayList())), Coord4D.get(tile()), 50D); player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + (color != null ? color.getName() : EnumColor.BLACK + MekanismUtils.localize("gui.none")))); - + return true; } - + @Override public boolean onRightClick(EntityPlayer player, int side) { @@ -746,31 +746,31 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.viewColor") + ": " + (color != null ? color.getName() : "None"))); return true; } - + @Override public EnumColor getColor() { return color; } - + @Override public void setColor(EnumColor c) { color = c; } - + @Override public TileEntity getTile() { return tile(); } - + @Override public EnumColor getRenderColor() { return color; } - + @Override public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side) { @@ -778,10 +778,10 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { return false; } - + return getConnectionType(side) == ConnectionType.NORMAL || getConnectionType(side) == ConnectionType.PUSH; } - + @Override public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side) { @@ -789,24 +789,24 @@ public class PartLogisticalTransporter extends PartSidedPipe implements ILogisti { return false; } - + return getConnectionType(side) == ConnectionType.NORMAL; } - + @Override public void onRemoved() { super.onRemoved(); - + if(!world().isRemote) { for(TransporterStack stack : transit) - { - TransporterUtils.drop(this, stack); - } + { + TransporterUtils.drop(this, stack); + } } } - + @Override public int getCost() { diff --git a/common/mekanism/common/multipart/PartMechanicalPipe.java b/common/mekanism/common/multipart/PartMechanicalPipe.java index 0ee83e440..cd066e75a 100644 --- a/common/mekanism/common/multipart/PartMechanicalPipe.java +++ b/common/mekanism/common/multipart/PartMechanicalPipe.java @@ -27,95 +27,95 @@ public class PartMechanicalPipe extends PartTransmitter implements { /** The fake tank used for fluid transfer calculations. */ public FluidTank dummyTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME); - - public static TransmitterIcons pipeIcons = new TransmitterIcons(2, 1); - - public float currentScale; - - public FluidStack cacheFluid; - public FluidStack lastWrite; - + + public static TransmitterIcons pipeIcons = new TransmitterIcons(2, 1); + + public float currentScale; + + public FluidStack cacheFluid; + public FluidStack lastWrite; + @Override public void update() { if(!world().isRemote) { - if(cacheFluid != null) - { - if(getTransmitterNetwork().fluidStored == null) - { - getTransmitterNetwork().fluidStored = cacheFluid; - } - else { - getTransmitterNetwork().fluidStored.amount += cacheFluid.amount; - } - - cacheFluid = null; - } - - if(getTransmitterNetwork(false) != null && getTransmitterNetwork(false).getSize() > 0) - { - int last = lastWrite != null ? lastWrite.amount : 0; - - if(last != getSaveShare()) - { - MekanismUtils.saveChunk(tile()); - } - } - - IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile()); - - for(ForgeDirection side : getConnections(ConnectionType.PULL)) - { - if(connectedAcceptors[side.ordinal()] != null) - { - IFluidHandler container = connectedAcceptors[side.ordinal()]; - + if(cacheFluid != null) + { + if(getTransmitterNetwork().fluidStored == null) + { + getTransmitterNetwork().fluidStored = cacheFluid; + } + else { + getTransmitterNetwork().fluidStored.amount += cacheFluid.amount; + } + + cacheFluid = null; + } + + if(getTransmitterNetwork(false) != null && getTransmitterNetwork(false).getSize() > 0) + { + int last = lastWrite != null ? lastWrite.amount : 0; + + if(last != getSaveShare()) + { + MekanismUtils.saveChunk(tile()); + } + } + + IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile()); + + for(ForgeDirection side : getConnections(ConnectionType.PULL)) + { + if(connectedAcceptors[side.ordinal()] != null) + { + IFluidHandler container = connectedAcceptors[side.ordinal()]; + if(container != null) { FluidStack received = container.drain(side.getOpposite(), 100, false); - + if(received != null && received.amount != 0) { container.drain(side.getOpposite(), getTransmitterNetwork().emit(received, true), true); } } - } + } } } - + super.update(); } - + private int getSaveShare() { - if(getTransmitterNetwork().fluidStored != null) - { - int remain = getTransmitterNetwork().fluidStored.amount%getTransmitterNetwork().transmitters.size(); - int toSave = getTransmitterNetwork().fluidStored.amount/getTransmitterNetwork().transmitters.size(); - - if(getTransmitterNetwork().isFirst((IGridTransmitter)tile())) - { - toSave += remain; - } - - return toSave; - } - - return 0; + if(getTransmitterNetwork().fluidStored != null) + { + int remain = getTransmitterNetwork().fluidStored.amount%getTransmitterNetwork().transmitters.size(); + int toSave = getTransmitterNetwork().fluidStored.amount/getTransmitterNetwork().transmitters.size(); + + if(getTransmitterNetwork().isFirst((IGridTransmitter)tile())) + { + toSave += remain; + } + + return toSave; + } + + return 0; } - + @Override public void onChunkUnload() - { + { if(!world().isRemote) - { + { if(lastWrite != null) { if(getTransmitterNetwork().fluidStored != null) { getTransmitterNetwork().fluidStored.amount -= lastWrite.amount; - + if(getTransmitterNetwork().fluidStored.amount <= 0) { getTransmitterNetwork().fluidStored = null; @@ -123,61 +123,61 @@ public class PartMechanicalPipe extends PartTransmitter implements } } } - + super.onChunkUnload(); } - - @Override - public void preSingleMerge(FluidNetwork network) - { - if(cacheFluid != null) - { - if(network.fluidStored == null) - { - network.fluidStored = cacheFluid; - } - else { - network.fluidStored.amount += cacheFluid.amount; - } - - cacheFluid = null; - } - } - - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); - - if(nbtTags.hasKey("cacheFluid")) - { - cacheFluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cacheFluid")); - } - } - - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); - - if(getTransmitterNetwork().fluidStored != null) - { - int remain = getTransmitterNetwork().fluidStored.amount%getTransmitterNetwork().transmitters.size(); - int toSave = getTransmitterNetwork().fluidStored.amount/getTransmitterNetwork().transmitters.size(); - - if(getTransmitterNetwork().isFirst((IGridTransmitter)tile())) - { - toSave += remain; - } - - if(toSave > 0) - { - FluidStack stack = new FluidStack(getTransmitterNetwork().fluidStored.getFluid(), toSave); - lastWrite = stack; - nbtTags.setCompoundTag("cacheFluid", stack.writeToNBT(new NBTTagCompound())); - } - } - } + + @Override + public void preSingleMerge(FluidNetwork network) + { + if(cacheFluid != null) + { + if(network.fluidStored == null) + { + network.fluidStored = cacheFluid; + } + else { + network.fluidStored.amount += cacheFluid.amount; + } + + cacheFluid = null; + } + } + + @Override + public void load(NBTTagCompound nbtTags) + { + super.load(nbtTags); + + if(nbtTags.hasKey("cacheFluid")) + { + cacheFluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cacheFluid")); + } + } + + @Override + public void save(NBTTagCompound nbtTags) + { + super.save(nbtTags); + + if(getTransmitterNetwork().fluidStored != null) + { + int remain = getTransmitterNetwork().fluidStored.amount%getTransmitterNetwork().transmitters.size(); + int toSave = getTransmitterNetwork().fluidStored.amount/getTransmitterNetwork().transmitters.size(); + + if(getTransmitterNetwork().isFirst((IGridTransmitter)tile())) + { + toSave += remain; + } + + if(toSave > 0) + { + FluidStack stack = new FluidStack(getTransmitterNetwork().fluidStored.getFluid(), toSave); + lastWrite = stack; + nbtTags.setCompoundTag("cacheFluid", stack.writeToNBT(new NBTTagCompound())); + } + } + } @Override public String getType() @@ -185,42 +185,42 @@ public class PartMechanicalPipe extends PartTransmitter implements return "mekanism:mechanical_pipe"; } - public static void registerIcons(IconRegister register) - { - pipeIcons.registerCenterIcons(register, new String[] {"MechanicalPipe", "MechanicalPipeActive"}); - pipeIcons.registerSideIcons(register, new String[] {"MechanicalPipeSide"}); - } + public static void registerIcons(IconRegister register) + { + pipeIcons.registerCenterIcons(register, new String[] {"MechanicalPipe", "MechanicalPipeActive"}); + pipeIcons.registerSideIcons(register, new String[] {"MechanicalPipeSide"}); + } - @Override - public Icon getCenterIcon() - { - return pipeIcons.getCenterIcon(0); - } + @Override + public Icon getCenterIcon() + { + return pipeIcons.getCenterIcon(0); + } - @Override - public Icon getSideIcon() - { - return pipeIcons.getSideIcon(0); - } + @Override + public Icon getSideIcon() + { + return pipeIcons.getSideIcon(0); + } - @Override + @Override public TransmissionType getTransmissionType() { return TransmissionType.FLUID; } - - @Override - public TransmitterType getTransmitter() - { - return TransmitterType.MECHANICAL_PIPE; - } + + @Override + public TransmitterType getTransmitter() + { + return TransmitterType.MECHANICAL_PIPE; + } @Override public boolean isValidAcceptor(TileEntity tile, ForgeDirection side) { return PipeUtils.getConnections(tile())[side.ordinal()]; } - + @Override public FluidNetwork createNetworkFromSingleTransmitter(IGridTransmitter transmitter) { @@ -232,7 +232,7 @@ public class PartMechanicalPipe extends PartTransmitter implements { return new FluidNetwork(networks); } - + @Override @SideOnly(Side.CLIENT) public void renderDynamic(Vector3 pos, float f, int pass) @@ -250,42 +250,42 @@ public class PartMechanicalPipe extends PartTransmitter implements { return getTransmitterNetwork().emit(resource, doFill); } - + return 0; } @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { return null; } @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return null; } @Override - public boolean canFill(ForgeDirection from, Fluid fluid) + public boolean canFill(ForgeDirection from, Fluid fluid) { return true; } @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) + public boolean canDrain(ForgeDirection from, Fluid fluid) { return true; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) + public FluidTankInfo[] getTankInfo(ForgeDirection from) { if(getConnectionType(from) != ConnectionType.NONE) { return new FluidTankInfo[] {dummyTank.getInfo()}; } - + return new FluidTankInfo[0]; } @@ -306,16 +306,16 @@ public class PartMechanicalPipe extends PartTransmitter implements { return getTransmitterNetwork().getNeeded(); } - + @Override public String getTransmitterNetworkFlow() { return getTransmitterNetwork().getFlow(); } - @Override - public int getCapacity() - { - return 1000; - } + @Override + public int getCapacity() + { + return 1000; + } } diff --git a/common/mekanism/common/multipart/PartPressurizedTube.java b/common/mekanism/common/multipart/PartPressurizedTube.java index 397708a11..4655c6481 100644 --- a/common/mekanism/common/multipart/PartPressurizedTube.java +++ b/common/mekanism/common/multipart/PartPressurizedTube.java @@ -23,105 +23,105 @@ import cpw.mods.fml.relauncher.SideOnly; public class PartPressurizedTube extends PartTransmitter { - public static TransmitterIcons tubeIcons = new TransmitterIcons(1, 1); - - public float currentScale; - - public GasStack cacheGas; - public GasStack lastWrite; - - @Override - public void update() - { - if(!world().isRemote) - { - if(cacheGas != null) - { - if(getTransmitterNetwork().gasStored == null) - { - getTransmitterNetwork().gasStored = cacheGas; - } - else { - getTransmitterNetwork().gasStored.amount += cacheGas.amount; - } - - cacheGas = null; - } - - if(getTransmitterNetwork(false) != null && getTransmitterNetwork(false).getSize() > 0) - { - int last = lastWrite != null ? lastWrite.amount : 0; - - if(last != getSaveShare()) - { - MekanismUtils.saveChunk(tile()); - } - } - } - else { - float targetScale = getTransmitterNetwork().gasScale; - + public static TransmitterIcons tubeIcons = new TransmitterIcons(1, 1); + + public float currentScale; + + public GasStack cacheGas; + public GasStack lastWrite; + + @Override + public void update() + { + if(!world().isRemote) + { + if(cacheGas != null) + { + if(getTransmitterNetwork().gasStored == null) + { + getTransmitterNetwork().gasStored = cacheGas; + } + else { + getTransmitterNetwork().gasStored.amount += cacheGas.amount; + } + + cacheGas = null; + } + + if(getTransmitterNetwork(false) != null && getTransmitterNetwork(false).getSize() > 0) + { + int last = lastWrite != null ? lastWrite.amount : 0; + + if(last != getSaveShare()) + { + MekanismUtils.saveChunk(tile()); + } + } + } + else { + float targetScale = getTransmitterNetwork().gasScale; + if(Math.abs(currentScale - targetScale) > 0.01) { currentScale = (9 * currentScale + targetScale) / 10; } - } - - super.update(); - } - + } + + super.update(); + } + private int getSaveShare() { - if(getTransmitterNetwork().gasStored != null) - { - int remain = getTransmitterNetwork().gasStored.amount%getTransmitterNetwork().transmitters.size(); - int toSave = getTransmitterNetwork().gasStored.amount/getTransmitterNetwork().transmitters.size(); - - if(getTransmitterNetwork().isFirst((IGridTransmitter)tile())) - { - toSave += remain; - } - - return toSave; - } - - return 0; + if(getTransmitterNetwork().gasStored != null) + { + int remain = getTransmitterNetwork().gasStored.amount%getTransmitterNetwork().transmitters.size(); + int toSave = getTransmitterNetwork().gasStored.amount/getTransmitterNetwork().transmitters.size(); + + if(getTransmitterNetwork().isFirst((IGridTransmitter)tile())) + { + toSave += remain; + } + + return toSave; + } + + return 0; } - - @Override - public TransmitterType getTransmitter() - { - return TransmitterType.PRESSURIZED_TUBE; - } - - @Override - public void preSingleMerge(GasNetwork network) - { - if(cacheGas != null) - { - if(network.gasStored == null) - { - network.gasStored = cacheGas; - } - else { - network.gasStored.amount += cacheGas.amount; - } - - cacheGas = null; - } - } - + + @Override + public TransmitterType getTransmitter() + { + return TransmitterType.PRESSURIZED_TUBE; + } + + @Override + public void preSingleMerge(GasNetwork network) + { + if(cacheGas != null) + { + if(network.gasStored == null) + { + network.gasStored = cacheGas; + } + else { + network.gasStored.amount += cacheGas.amount; + } + + cacheGas = null; + } + } + @Override public void onChunkUnload() - { + { if(!world().isRemote) - { + { if(lastWrite != null) { if(getTransmitterNetwork().gasStored != null) { getTransmitterNetwork().gasStored.amount -= lastWrite.amount; - + if(getTransmitterNetwork().gasStored.amount <= 0) { getTransmitterNetwork().gasStored = null; @@ -129,45 +129,45 @@ public class PartPressurizedTube extends PartTransmitter } } } - + super.onChunkUnload(); } - - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); - - if(nbtTags.hasKey("cacheGas")) - { - cacheGas = GasStack.readFromNBT(nbtTags.getCompoundTag("cacheGas")); - } - } - - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); - - if(getTransmitterNetwork().gasStored != null) - { - int remain = getTransmitterNetwork().gasStored.amount%getTransmitterNetwork().transmitters.size(); - int toSave = getTransmitterNetwork().gasStored.amount/getTransmitterNetwork().transmitters.size(); - - if(getTransmitterNetwork().isFirst((IGridTransmitter)tile())) - { - toSave += remain; - } - - if(toSave > 0) - { - GasStack stack = new GasStack(getTransmitterNetwork().gasStored.getGas(), toSave); - - lastWrite = stack; - nbtTags.setCompoundTag("cacheGas", stack.write(new NBTTagCompound())); - } - } - } + + @Override + public void load(NBTTagCompound nbtTags) + { + super.load(nbtTags); + + if(nbtTags.hasKey("cacheGas")) + { + cacheGas = GasStack.readFromNBT(nbtTags.getCompoundTag("cacheGas")); + } + } + + @Override + public void save(NBTTagCompound nbtTags) + { + super.save(nbtTags); + + if(getTransmitterNetwork().gasStored != null) + { + int remain = getTransmitterNetwork().gasStored.amount%getTransmitterNetwork().transmitters.size(); + int toSave = getTransmitterNetwork().gasStored.amount/getTransmitterNetwork().transmitters.size(); + + if(getTransmitterNetwork().isFirst((IGridTransmitter)tile())) + { + toSave += remain; + } + + if(toSave > 0) + { + GasStack stack = new GasStack(getTransmitterNetwork().gasStored.getGas(), toSave); + + lastWrite = stack; + nbtTags.setCompoundTag("cacheGas", stack.write(new NBTTagCompound())); + } + } + } @Override public String getType() @@ -175,25 +175,25 @@ public class PartPressurizedTube extends PartTransmitter return "mekanism:pressurized_tube"; } - public static void registerIcons(IconRegister register) - { - tubeIcons.registerCenterIcons(register, new String[] {"PressurizedTube"}); - tubeIcons.registerSideIcons(register, new String[] {"TransmitterSideSmall"}); - } + public static void registerIcons(IconRegister register) + { + tubeIcons.registerCenterIcons(register, new String[] {"PressurizedTube"}); + tubeIcons.registerSideIcons(register, new String[] {"TransmitterSideSmall"}); + } - @Override - public Icon getCenterIcon() - { - return tubeIcons.getCenterIcon(0); - } + @Override + public Icon getCenterIcon() + { + return tubeIcons.getCenterIcon(0); + } - @Override - public Icon getSideIcon() - { - return tubeIcons.getSideIcon(0); - } + @Override + public Icon getSideIcon() + { + return tubeIcons.getSideIcon(0); + } - @Override + @Override public TransmissionType getTransmissionType() { return TransmissionType.GAS; @@ -234,13 +234,13 @@ public class PartPressurizedTube extends PartTransmitter { return getTransmitterNetwork().getNeeded(); } - + @Override public String getTransmitterNetworkFlow() { return getTransmitterNetwork().getFlow(); } - + @Override @SideOnly(Side.CLIENT) public void renderDynamic(Vector3 pos, float f, int pass) @@ -251,9 +251,9 @@ public class PartPressurizedTube extends PartTransmitter } } - @Override - public int getCapacity() - { - return 256; - } + @Override + public int getCapacity() + { + return 256; + } } diff --git a/common/mekanism/common/multipart/PartRestrictiveTransporter.java b/common/mekanism/common/multipart/PartRestrictiveTransporter.java index 9bab0f337..d5e86c04c 100644 --- a/common/mekanism/common/multipart/PartRestrictiveTransporter.java +++ b/common/mekanism/common/multipart/PartRestrictiveTransporter.java @@ -9,13 +9,13 @@ public class PartRestrictiveTransporter extends PartLogisticalTransporter { return "mekanism:restrictive_transporter"; } - + @Override public TransmitterType getTransmitter() { return TransmitterType.RESTRICTIVE_TRANSPORTER; } - + @Override public Icon getCenterIcon() { @@ -27,7 +27,7 @@ public class PartRestrictiveTransporter extends PartLogisticalTransporter { return transporterIcons.getSideIcon(1); } - + @Override public int getCost() { diff --git a/common/mekanism/common/multipart/PartSidedPipe.java b/common/mekanism/common/multipart/PartSidedPipe.java index 172f81e10..2cba45ed0 100644 --- a/common/mekanism/common/multipart/PartSidedPipe.java +++ b/common/mekanism/common/multipart/PartSidedPipe.java @@ -59,19 +59,19 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { public static IndexedCuboid6[] smallSides = new IndexedCuboid6[7]; public static IndexedCuboid6[] largeSides = new IndexedCuboid6[7]; - + public int delayTicks; - + public ForgeDirection testingSide = null; - + public byte currentAcceptorConnections = 0x00; public byte currentTransmitterConnections = 0x00; - + public boolean sendDesc = false; public boolean redstonePowered = false; public boolean redstoneReactive = true; - + public ConnectionType[] connectionTypes = {ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL}; static @@ -129,24 +129,24 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, public abstract Icon getCenterIcon(); public abstract Icon getSideIcon(); - + @Override public void update() { - if(world().isRemote) - { - if(delayTicks == 5) - { - delayTicks = 6; /* don't refresh again */ - refreshConnections(); - } - else if(delayTicks < 5) - { - delayTicks++; - } - } + if(world().isRemote) + { + if(delayTicks == 5) + { + delayTicks = 6; /* don't refresh again */ + refreshConnections(); + } + else if(delayTicks < 5) + { + delayTicks++; + } + } - if(sendDesc && !world().isRemote) + if(sendDesc && !world().isRemote) { sendDescUpdate(); sendDesc = false; @@ -156,7 +156,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, public Icon getIconForSide(ForgeDirection side) { ConnectionType type = getConnectionType(side); - + if(type == ConnectionType.NONE) { return getCenterIcon(); @@ -250,7 +250,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, return subParts; } - + public abstract TransmitterType getTransmitter(); @Override @@ -258,7 +258,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { Set collisionBoxes = new HashSet(); collisionBoxes.addAll((Collection)getSubParts()); - + return collisionBoxes; } @@ -277,7 +277,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, @Override public Icon getBreakingIcon(Object subPart, int side) { - return getCenterIcon(); + return getCenterIcon(); } @Override @@ -309,16 +309,16 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, } @Override - public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) - { - IconHitEffects.addHitEffects(this, hit, effectRenderer); - } + public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) + { + IconHitEffects.addHitEffects(this, hit, effectRenderer); + } @Override - public void addDestroyEffects(EffectRenderer effectRenderer) - { - IconHitEffects.addDestroyEffects(this, effectRenderer, false); - } + public void addDestroyEffects(EffectRenderer effectRenderer) + { + IconHitEffects.addDestroyEffects(this, effectRenderer, false); + } public abstract boolean isValidAcceptor(TileEntity tile, ForgeDirection side); @@ -350,7 +350,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { currentTransmitterConnections = packet.readByte(); currentAcceptorConnections = packet.readByte(); - + for(int i = 0; i < 6; i++) { connectionTypes[i] = ConnectionType.values()[packet.readInt()]; @@ -362,33 +362,33 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { packet.writeByte(currentTransmitterConnections); packet.writeByte(currentAcceptorConnections); - + for(int i = 0; i < 6; i++) { packet.writeInt(connectionTypes[i].ordinal()); } } - + @Override public void load(NBTTagCompound nbtTags) { super.load(nbtTags); - + redstoneReactive = nbtTags.getBoolean("redstoneReactive"); - + for(int i = 0; i < 6; i++) { connectionTypes[i] = ConnectionType.values()[nbtTags.getInteger("connection" + i)]; } } - + @Override public void save(NBTTagCompound nbtTags) { super.save(nbtTags); - + nbtTags.setBoolean("redstoneReactive", redstoneReactive); - + for(int i = 0; i < 6; i++) { nbtTags.setInteger("connection" + i, connectionTypes[i].ordinal()); @@ -402,7 +402,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { return false; } - + if(item.getItem() instanceof IToolWrench && !(item.getItem() instanceof ItemConfigurator) && player.isSneaking()) { if(!world().isRemote) @@ -434,52 +434,52 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { return true; } - + protected void onRedstoneSplit() {} - + protected void onRefresh() {} - + public void refreshConnections() { byte possibleTransmitters = getPossibleTransmitterConnections(); byte possibleAcceptors = getPossibleAcceptorConnections(); - + if(possibleTransmitters != currentTransmitterConnections) { boolean nowPowered = redstoneReactive && world().isBlockIndirectlyGettingPowered(x(), y(), z()); - + if(nowPowered != redstonePowered) { redstonePowered = nowPowered; - + if(nowPowered) { onRedstoneSplit(); } - + tile().notifyPartChange(this); } } - + if(!world().isRemote) { currentTransmitterConnections = possibleTransmitters; currentAcceptorConnections = possibleAcceptors; } - + onRefresh(); - + if(!world().isRemote) - { + { sendDesc = true; } } - + protected void onModeChange(ForgeDirection side) { refreshConnections(); } - + @Override public void onAdded() { @@ -493,14 +493,14 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, super.onChunkLoad(); refreshConnections(); } - + @Override public void onNeighborChanged() { super.onNeighborChanged(); refreshConnections(); } - + @Override public void onPartChanged(TMultiPart part) { @@ -527,14 +527,14 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { return ConnectionType.NORMAL; } - + return connectionTypes[side.ordinal()]; } - + public List getConnections(ConnectionType type) { List sides = new ArrayList(); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if(getConnectionType(side) == type) @@ -542,7 +542,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, sides.add(side); } } - + return sides; } @@ -571,7 +571,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, public boolean onSneakRightClick(EntityPlayer player, int side) { ExtendedMOP hit = (ExtendedMOP)RayTracer.retraceBlock(world(), player, x(), y(), z()); - + if(hit == null) { return false; @@ -580,22 +580,22 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, { connectionTypes[hit.subHit] = connectionTypes[hit.subHit].next(); sendDesc = true; - + onModeChange(ForgeDirection.getOrientation(side)); player.sendChatToPlayer(ChatMessageComponent.createFromText("Connection type changed to " + connectionTypes[hit.subHit].toString())); - + return true; } else { return onConfigure(player, hit.subHit, side); } } - - protected boolean onConfigure(EntityPlayer player, int part, int side) + + protected boolean onConfigure(EntityPlayer player, int part, int side) { return false; } - + public EnumColor getRenderColor() { return null; @@ -611,14 +611,14 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Redstone sensitivity turned " + EnumColor.INDIGO + (redstoneReactive ? "on." : "off."))); return true; } - + public boolean canConnectToAcceptor(ForgeDirection side, boolean ignoreActive) { if(!isValidAcceptor(Coord4D.get(tile()).getFromSide(side).getTileEntity(world()), side) || !connectionMapContainsSide(currentAcceptorConnections, side)) { return false; } - + if(!ignoreActive) { return getConnectionType(side) == ConnectionType.NORMAL || getConnectionType(side) == ConnectionType.PUSH; @@ -627,7 +627,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, return connectionTypes[side.ordinal()] == ConnectionType.NORMAL || connectionTypes[side.ordinal()] == ConnectionType.PUSH; } } - + @Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { @@ -667,14 +667,14 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, PUSH, PULL, NONE; - + public ConnectionType next() { if(ordinal() == values().length-1) { return NORMAL; } - + return values()[ordinal()+1]; } } diff --git a/common/mekanism/common/multipart/PartTransmitter.java b/common/mekanism/common/multipart/PartTransmitter.java index c69e072a1..88186077d 100644 --- a/common/mekanism/common/multipart/PartTransmitter.java +++ b/common/mekanism/common/multipart/PartTransmitter.java @@ -22,7 +22,7 @@ import net.minecraftforge.common.ForgeDirection; public abstract class PartTransmitter> extends PartSidedPipe implements IGridTransmitter, IConfigurable { public N theNetwork; - + @Override public void bind(TileMultipart t) { @@ -36,19 +36,19 @@ public abstract class PartTransmitter> extends Pa super.bind(t); } } - + @Override public void refreshTransmitterNetwork() { byte possibleTransmitters = getPossibleTransmitterConnections(); byte possibleAcceptors = getPossibleAcceptorConnections(); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if(connectionMapContainsSide(possibleTransmitters, side)) { TileEntity tileEntity = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - + if(TransmissionType.checkTransmissionType(tileEntity, getTransmissionType())) { ((DynamicNetwork)getTransmitterNetwork()).merge(((IGridTransmitter)tileEntity).getTransmitterNetwork()); @@ -58,20 +58,20 @@ public abstract class PartTransmitter> extends Pa ((DynamicNetwork)getTransmitterNetwork()).refresh(); } - + @Override public void onRefresh() { refreshTransmitterNetwork(); } - + @Override public void onRedstoneSplit() { getTransmitterNetwork().split((IGridTransmitter)tile()); setTransmitterNetwork(null); } - + @Override public void setTransmitterNetwork(N network) { @@ -81,19 +81,19 @@ public abstract class PartTransmitter> extends Pa theNetwork = network; } } - + @Override public boolean areTransmitterNetworksEqual(TileEntity tileEntity) { return tileEntity instanceof IGridTransmitter && getTransmissionType() == ((IGridTransmitter)tileEntity).getTransmissionType(); } - + @Override public N getTransmitterNetwork() { return getTransmitterNetwork(true); } - + @Override public N getTransmitterNetwork(boolean createIfNull) { @@ -101,20 +101,20 @@ public abstract class PartTransmitter> extends Pa { byte possibleTransmitters = getPossibleTransmitterConnections(); HashSet connectedNets = new HashSet(); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { if(connectionMapContainsSide(possibleTransmitters, side)) { TileEntity cable = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - + if(TransmissionType.checkTransmissionType(cable, getTransmissionType()) && ((IGridTransmitter)cable).getTransmitterNetwork(false) != null) { connectedNets.add(((IGridTransmitter)cable).getTransmitterNetwork()); } } } - + if(connectedNets.size() == 0) { theNetwork = createNetworkFromSingleTransmitter((IGridTransmitter)tile()); @@ -132,12 +132,12 @@ public abstract class PartTransmitter> extends Pa theNetwork.transmitters.add((IGridTransmitter)tile()); } } - + return theNetwork; } - + public void preSingleMerge(N network) {} - + @Override public void removeFromTransmitterNetwork() { @@ -152,18 +152,18 @@ public abstract class PartTransmitter> extends Pa { getTransmitterNetwork().fixMessedUpNetwork((IGridTransmitter) tile()); } - + public abstract N createNetworkFromSingleTransmitter(IGridTransmitter transmitter); - + public abstract N createNetworkByMergingSet(Set networks); - + @Override public void onChunkUnload() { super.onChunkUnload(); - + getTransmitterNetwork().split(this); - + if(!world().isRemote) { TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks(); @@ -174,14 +174,14 @@ public abstract class PartTransmitter> extends Pa } catch(Exception e) {} } } - + @Override public void preRemove() { if(tile() instanceof IGridTransmitter) { getTransmitterNetwork().split((IGridTransmitter)tile()); - + if(!world().isRemote) { TransmitterNetworkRegistry.getInstance().pruneEmptyNetworks(); @@ -195,23 +195,23 @@ public abstract class PartTransmitter> extends Pa super.preRemove(); } - + @Override protected void onModeChange(ForgeDirection side) { super.onModeChange(side); - + if(!world().isRemote) { PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketTransmitterUpdate().setParams(PacketType.UPDATE, tile()), world().provider.dimensionId); } } - + @Override public void onNeighborChanged() { super.onNeighborChanged(); - + if(!world().isRemote) { PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketTransmitterUpdate().setParams(PacketType.UPDATE, tile()), world().provider.dimensionId); diff --git a/common/mekanism/common/multipart/PartUniversalCable.java b/common/mekanism/common/multipart/PartUniversalCable.java index 2eab0da0d..89600ee6d 100644 --- a/common/mekanism/common/multipart/PartUniversalCable.java +++ b/common/mekanism/common/multipart/PartUniversalCable.java @@ -39,14 +39,14 @@ public class PartUniversalCable extends PartTransmitter implement /** A fake power handler used to initiate energy transfer calculations. */ public PowerHandler powerHandler; - - public static TransmitterIcons cableIcons = new TransmitterIcons(4, 1); - - public double currentPower = 0; - - public double cacheEnergy = 0; - public double lastWrite = 0; - + + public static TransmitterIcons cableIcons = new TransmitterIcons(4, 1); + + public double currentPower = 0; + + public double cacheEnergy = 0; + public double lastWrite = 0; + public PartUniversalCable(Tier.CableTier cableTier) { tier = cableTier; @@ -55,78 +55,78 @@ public class PartUniversalCable extends PartTransmitter implement powerHandler.configure(0, 0, 0, 0); } - @Override - public void update() - { - if(world().isRemote) - { - double targetPower = getTransmitterNetwork().clientEnergyScale; - - if(Math.abs(currentPower - targetPower) > 0.01) - { - currentPower = (9*currentPower + targetPower)/10; - } - } - else { - if(getTransmitterNetwork(false) != null && getTransmitterNetwork(false).getSize() > 0) - { - double last = lastWrite; - - if(last != getSaveShare()) - { - MekanismUtils.saveChunk(tile()); - } - } - - if(cacheEnergy > 0) - { - getTransmitterNetwork().electricityStored += cacheEnergy; - cacheEnergy = 0; - } - } - - super.update(); - } - + @Override + public void update() + { + if(world().isRemote) + { + double targetPower = getTransmitterNetwork().clientEnergyScale; + + if(Math.abs(currentPower - targetPower) > 0.01) + { + currentPower = (9*currentPower + targetPower)/10; + } + } + else { + if(getTransmitterNetwork(false) != null && getTransmitterNetwork(false).getSize() > 0) + { + double last = lastWrite; + + if(last != getSaveShare()) + { + MekanismUtils.saveChunk(tile()); + } + } + + if(cacheEnergy > 0) + { + getTransmitterNetwork().electricityStored += cacheEnergy; + cacheEnergy = 0; + } + } + + super.update(); + } + private double getSaveShare() { return EnergyNetwork.round(getTransmitterNetwork().electricityStored*(1F/getTransmitterNetwork().transmitters.size())); } - + @Override public void refreshTransmitterNetwork() { super.refreshTransmitterNetwork(); - + reconfigure(); } - - @Override - public TransmitterType getTransmitter() - { - return tier.type; - } - - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); - - cacheEnergy = nbtTags.getDouble("cacheEnergy"); + + @Override + public TransmitterType getTransmitter() + { + return tier.type; + } + + @Override + public void load(NBTTagCompound nbtTags) + { + super.load(nbtTags); + + cacheEnergy = nbtTags.getDouble("cacheEnergy"); tier = Tier.CableTier.values()[nbtTags.getInteger("tier")]; - } - - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); - - double toSave = getSaveShare(); - - lastWrite = toSave; - nbtTags.setDouble("cacheEnergy", toSave); + } + + @Override + public void save(NBTTagCompound nbtTags) + { + super.save(nbtTags); + + double toSave = getSaveShare(); + + lastWrite = toSave; + nbtTags.setDouble("cacheEnergy", toSave); nbtTags.setInteger("tier", tier.ordinal()); - } + } @Override public String getType() @@ -134,44 +134,44 @@ public class PartUniversalCable extends PartTransmitter implement return "mekanism:universal_cable_" + tier.name().toLowerCase(); } - public static void registerIcons(IconRegister register) - { - cableIcons.registerCenterIcons(register, new String[] {"UniversalCableBasic", "UniversalCableAdvanced", + public static void registerIcons(IconRegister register) + { + cableIcons.registerCenterIcons(register, new String[] {"UniversalCableBasic", "UniversalCableAdvanced", "UniversalCableElite", "UniversalCableUltimate"}); - cableIcons.registerSideIcons(register, new String[] {"TransmitterSideSmall"}); - } - - @Override - public void preSingleMerge(EnergyNetwork network) - { - network.electricityStored += cacheEnergy; - cacheEnergy = 0; - } + cableIcons.registerSideIcons(register, new String[] {"TransmitterSideSmall"}); + } - @Override - public Icon getCenterIcon() - { - return cableIcons.getCenterIcon(tier.ordinal()); - } + @Override + public void preSingleMerge(EnergyNetwork network) + { + network.electricityStored += cacheEnergy; + cacheEnergy = 0; + } - @Override - public Icon getSideIcon() - { - return cableIcons.getSideIcon(0); - } + @Override + public Icon getCenterIcon() + { + return cableIcons.getCenterIcon(tier.ordinal()); + } + + @Override + public Icon getSideIcon() + { + return cableIcons.getSideIcon(0); + } @Override public TransmissionType getTransmissionType() { return TransmissionType.ENERGY; } - + @Override public EnergyNetwork createNetworkFromSingleTransmitter(IGridTransmitter transmitter) { return new EnergyNetwork(transmitter); } - + @Override public EnergyNetwork createNetworkByMergingSet(Set networks) { @@ -183,7 +183,7 @@ public class PartUniversalCable extends PartTransmitter implement { return CableUtils.getConnections(tile())[side.ordinal()]; } - + @Override @SideOnly(Side.CLIENT) public void renderDynamic(Vector3 pos, float frame, int pass) @@ -193,7 +193,7 @@ public class PartUniversalCable extends PartTransmitter implement RenderPartTransmitter.getInstance().renderContents(this, pos); } } - + public void register() { if(!world().isRemote) @@ -211,38 +211,38 @@ public class PartUniversalCable extends PartTransmitter implement { register(); } - + @Override public void preRemove() - { + { if(!world().isRemote) - { + { Mekanism.ic2Registered.remove(Coord4D.get(tile())); MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)tile())); } - + super.preRemove(); } - + @Override public void onAdded() { super.onAdded(); - + register(); } - + @Override public void onChunkUnload() - { + { if(!world().isRemote) - { + { Mekanism.ic2Registered.remove(Coord4D.get(tile())); MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)tile())); - + getTransmitterNetwork().electricityStored -= lastWrite; } - + super.onChunkUnload(); } @@ -263,13 +263,13 @@ public class PartUniversalCable extends PartTransmitter implement { return getTransmitterNetwork().getNeeded(); } - + @Override public String getTransmitterNetworkFlow() { return getTransmitterNetwork().getFlow(); } - + @Override public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { @@ -281,7 +281,7 @@ public class PartUniversalCable extends PartTransmitter implement { return getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_IC2; } - + @Override public int getMaxSafeInput() { @@ -289,36 +289,36 @@ public class PartUniversalCable extends PartTransmitter implement } @Override - public double injectEnergyUnits(ForgeDirection direction, double i) - { - return getTransmitterNetwork().emit(i*Mekanism.FROM_IC2)*Mekanism.TO_IC2; - } - + public double injectEnergyUnits(ForgeDirection direction, double i) + { + return getTransmitterNetwork().emit(i*Mekanism.FROM_IC2)*Mekanism.TO_IC2; + } + @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { if(!simulate) { - return maxReceive - (int)Math.round(getTransmitterNetwork().emit(maxReceive*Mekanism.FROM_TE)*Mekanism.TO_TE); + return maxReceive - (int)Math.round(getTransmitterNetwork().emit(maxReceive*Mekanism.FROM_TE)*Mekanism.TO_TE); } - + return 0; } @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { return 0; } @Override - public boolean canInterface(ForgeDirection from) + public boolean canInterface(ForgeDirection from) { return true; } @Override - public int getEnergyStored(ForgeDirection from) + public int getEnergyStored(ForgeDirection from) { return 0; } @@ -329,11 +329,11 @@ public class PartUniversalCable extends PartTransmitter implement return (int)Math.round(getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_TE); } - @Override - public int getCapacity() - { - return tier.cableCapacity; - } + @Override + public int getCapacity() + { + return tier.cableCapacity; + } @Override public double transferEnergyToAcceptor(ForgeDirection side, double amount) @@ -342,11 +342,11 @@ public class PartUniversalCable extends PartTransmitter implement { return 0; } - - double toUse = Math.min(getMaxEnergy()-getEnergy(), amount); - setEnergy(getEnergy() + toUse); - - return toUse; + + double toUse = Math.min(getMaxEnergy()-getEnergy(), amount); + setEnergy(getEnergy() + toUse); + + return toUse; } @Override @@ -354,42 +354,42 @@ public class PartUniversalCable extends PartTransmitter implement { return getConnectionType(side) == ConnectionType.NORMAL || getConnectionType(side) == ConnectionType.PULL; } - + @Override public double getMaxEnergy() { return getTransmitterNetwork().getCapacity(); } - + @Override public double getEnergy() { return getTransmitterNetwork().electricityStored; } - + @Override public void setEnergy(double energy) { getTransmitterNetwork().electricityStored = energy; } - + @Override - public PowerReceiver getPowerReceiver(ForgeDirection side) + public PowerReceiver getPowerReceiver(ForgeDirection side) { if(getTransmitterNetwork().getEnergyNeeded() == 0) { return null; } - + return powerHandler.getPowerReceiver(); } - + @Override public World getWorld() { return world(); } - + private void reconfigure() { if(MekanismUtils.useBuildCraft()) @@ -400,7 +400,7 @@ public class PartUniversalCable extends PartTransmitter implement } @Override - public void doWork(PowerHandler workProvider) + public void doWork(PowerHandler workProvider) { if(MekanismUtils.useBuildCraft()) { @@ -408,7 +408,7 @@ public class PartUniversalCable extends PartTransmitter implement { getTransmitterNetwork().emit(powerHandler.getEnergyStored()*Mekanism.FROM_BC); } - + powerHandler.setEnergy(0); reconfigure(); } diff --git a/common/mekanism/common/multipart/TransmitterIcons.java b/common/mekanism/common/multipart/TransmitterIcons.java index 38b742082..514d17716 100644 --- a/common/mekanism/common/multipart/TransmitterIcons.java +++ b/common/mekanism/common/multipart/TransmitterIcons.java @@ -5,38 +5,38 @@ import net.minecraft.util.Icon; public class TransmitterIcons { - private Icon[] sideIcons; - private Icon[] centerIcons; + private Icon[] sideIcons; + private Icon[] centerIcons; - public TransmitterIcons(int numCentres, int numSides) - { - sideIcons = new Icon[numSides]; - centerIcons = new Icon[numCentres]; - } + public TransmitterIcons(int numCentres, int numSides) + { + sideIcons = new Icon[numSides]; + centerIcons = new Icon[numCentres]; + } - public void registerCenterIcons(IconRegister register, String[] filenames) - { - for(int i = 0; i < centerIcons.length; i++) - { - centerIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]); - } - } + public void registerCenterIcons(IconRegister register, String[] filenames) + { + for(int i = 0; i < centerIcons.length; i++) + { + centerIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]); + } + } - public void registerSideIcons(IconRegister register, String[] filenames) - { - for(int i = 0; i < sideIcons.length; i++) - { - sideIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]); - } - } + public void registerSideIcons(IconRegister register, String[] filenames) + { + for(int i = 0; i < sideIcons.length; i++) + { + sideIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]); + } + } - public Icon getSideIcon(int n) - { - return sideIcons[n]; - } + public Icon getSideIcon(int n) + { + return sideIcons[n]; + } - public Icon getCenterIcon(int n) - { - return centerIcons[n]; - } + public Icon getCenterIcon(int n) + { + return centerIcons[n]; + } } diff --git a/common/mekanism/common/multipart/TransmitterType.java b/common/mekanism/common/multipart/TransmitterType.java index b06fd55b4..251b1816d 100644 --- a/common/mekanism/common/multipart/TransmitterType.java +++ b/common/mekanism/common/multipart/TransmitterType.java @@ -33,17 +33,17 @@ public enum TransmitterType centerIndex = center; sideIndex = side; } - + public String getName() { return unlocalizedName; } - + public Size getSize() { return size; } - + public TransmissionType getTransmission() { return transmissionType; @@ -58,17 +58,17 @@ public enum TransmitterType { return transmitterIcons.getSideIcon(sideIndex); } - - public static enum Size - { - SMALL(6), - LARGE(8); - public int centerSize; + public static enum Size + { + SMALL(6), + LARGE(8); - private Size(int size) - { - centerSize = size; - } - } + public int centerSize; + + private Size(int size) + { + centerSize = size; + } + } } diff --git a/common/mekanism/common/network/IMekanismPacket.java b/common/mekanism/common/network/IMekanismPacket.java index aacd50c3f..32f2e1a18 100644 --- a/common/mekanism/common/network/IMekanismPacket.java +++ b/common/mekanism/common/network/IMekanismPacket.java @@ -14,13 +14,13 @@ public interface IMekanismPacket * @return this packet's identifier */ public String getName(); - + /** * Sets the parameters of this packet for writing. * @param data - data to set */ public IMekanismPacket setParams(Object... data); - + /** * Reads this packet's data from a ByteArrayDataInput, and handles it as needed. * @param dataStream - data stream being sent @@ -29,7 +29,7 @@ public interface IMekanismPacket * @throws Exception - the exception thrown in case anything goes wrong */ public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception; - + /** * Writes this packet's data to a DataOutputStream. * @param dataStream - data stream being sent diff --git a/common/mekanism/common/network/PacketBoxBlacklist.java b/common/mekanism/common/network/PacketBoxBlacklist.java index 1a92ebf85..405d094c3 100644 --- a/common/mekanism/common/network/PacketBoxBlacklist.java +++ b/common/mekanism/common/network/PacketBoxBlacklist.java @@ -12,11 +12,11 @@ import com.google.common.io.ByteArrayDataInput; public class PacketBoxBlacklist implements IMekanismPacket { @Override - public String getName() + public String getName() { return "BoxBlacklist"; } - + @Override public IMekanismPacket setParams(Object... data) { @@ -24,17 +24,17 @@ public class PacketBoxBlacklist implements IMekanismPacket } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { MekanismAPI.getBoxIgnore().clear(); - + int amount = dataStream.readInt(); - + for(int i = 0; i < amount; i++) { MekanismAPI.addBoxBlacklist(dataStream.readInt(), dataStream.readInt()); } - + System.out.println("[Mekanism] Received Cardboard Box blacklist entries from server (" + amount + " total)"); } @@ -42,7 +42,7 @@ public class PacketBoxBlacklist implements IMekanismPacket public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(MekanismAPI.getBoxIgnore().size()); - + for(ItemInfo info : MekanismAPI.getBoxIgnore()) { dataStream.writeInt(info.id); diff --git a/common/mekanism/common/network/PacketConfigSync.java b/common/mekanism/common/network/PacketConfigSync.java index 70d21a688..a9abe3d0f 100644 --- a/common/mekanism/common/network/PacketConfigSync.java +++ b/common/mekanism/common/network/PacketConfigSync.java @@ -12,11 +12,11 @@ import com.google.common.io.ByteArrayDataInput; public class PacketConfigSync implements IMekanismPacket { @Override - public String getName() + public String getName() { return "ConfigSync"; } - + @Override public IMekanismPacket setParams(Object... data) { @@ -24,37 +24,37 @@ public class PacketConfigSync implements IMekanismPacket } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { - Mekanism.osmiumGenerationEnabled = dataStream.readBoolean(); - Mekanism.copperGenerationEnabled = dataStream.readBoolean(); - Mekanism.tinGenerationEnabled = dataStream.readBoolean(); - Mekanism.disableBCSteelCrafting = dataStream.readBoolean(); - Mekanism.disableBCBronzeCrafting = dataStream.readBoolean(); - Mekanism.updateNotifications = dataStream.readBoolean(); - Mekanism.controlCircuitOreDict = dataStream.readBoolean(); - Mekanism.logPackets = dataStream.readBoolean(); - Mekanism.dynamicTankEasterEgg = dataStream.readBoolean(); - Mekanism.voiceServerEnabled = dataStream.readBoolean(); - Mekanism.forceBuildcraft = dataStream.readBoolean(); - Mekanism.cardboardSpawners = dataStream.readBoolean(); - Mekanism.obsidianTNTDelay = dataStream.readInt(); - Mekanism.obsidianTNTBlastRadius = dataStream.readInt(); - Mekanism.UPDATE_DELAY = dataStream.readInt(); - Mekanism.osmiumGenerationAmount = dataStream.readInt(); - Mekanism.copperGenerationAmount = dataStream.readInt(); - Mekanism.tinGenerationAmount = dataStream.readInt(); - Mekanism.FROM_IC2 = dataStream.readDouble(); - Mekanism.TO_IC2 = dataStream.readDouble(); - Mekanism.FROM_BC = dataStream.readDouble(); - Mekanism.TO_BC = dataStream.readDouble(); - Mekanism.ENERGY_PER_REDSTONE = dataStream.readDouble(); - Mekanism.VOICE_PORT = dataStream.readInt(); - Mekanism.maxUpgradeMultiplier = dataStream.readInt(); - - Mekanism.TO_TE = Mekanism.TO_BC*10; - Mekanism.FROM_TE = Mekanism.FROM_BC/10; - + Mekanism.osmiumGenerationEnabled = dataStream.readBoolean(); + Mekanism.copperGenerationEnabled = dataStream.readBoolean(); + Mekanism.tinGenerationEnabled = dataStream.readBoolean(); + Mekanism.disableBCSteelCrafting = dataStream.readBoolean(); + Mekanism.disableBCBronzeCrafting = dataStream.readBoolean(); + Mekanism.updateNotifications = dataStream.readBoolean(); + Mekanism.controlCircuitOreDict = dataStream.readBoolean(); + Mekanism.logPackets = dataStream.readBoolean(); + Mekanism.dynamicTankEasterEgg = dataStream.readBoolean(); + Mekanism.voiceServerEnabled = dataStream.readBoolean(); + Mekanism.forceBuildcraft = dataStream.readBoolean(); + Mekanism.cardboardSpawners = dataStream.readBoolean(); + Mekanism.obsidianTNTDelay = dataStream.readInt(); + Mekanism.obsidianTNTBlastRadius = dataStream.readInt(); + Mekanism.UPDATE_DELAY = dataStream.readInt(); + Mekanism.osmiumGenerationAmount = dataStream.readInt(); + Mekanism.copperGenerationAmount = dataStream.readInt(); + Mekanism.tinGenerationAmount = dataStream.readInt(); + Mekanism.FROM_IC2 = dataStream.readDouble(); + Mekanism.TO_IC2 = dataStream.readDouble(); + Mekanism.FROM_BC = dataStream.readDouble(); + Mekanism.TO_BC = dataStream.readDouble(); + Mekanism.ENERGY_PER_REDSTONE = dataStream.readDouble(); + Mekanism.VOICE_PORT = dataStream.readInt(); + Mekanism.maxUpgradeMultiplier = dataStream.readInt(); + + Mekanism.TO_TE = Mekanism.TO_BC*10; + Mekanism.FROM_TE = Mekanism.FROM_BC/10; + Mekanism.enrichmentChamberUsage = dataStream.readDouble(); Mekanism.osmiumCompressorUsage = dataStream.readDouble(); Mekanism.combinerUsage = dataStream.readDouble(); @@ -73,7 +73,7 @@ public class PacketConfigSync implements IMekanismPacket Mekanism.chemicalDissolutionChamberUsage = dataStream.readDouble(); Mekanism.chemicalWasherUsage = dataStream.readDouble(); Mekanism.chemicalCrystalizerUsage = dataStream.readDouble(); - + for(IModule module : Mekanism.modulesLoaded) { module.readConfig(dataStream); @@ -84,34 +84,34 @@ public class PacketConfigSync implements IMekanismPacket @Override public void write(DataOutputStream dataStream) throws Exception - { + { dataStream.writeBoolean(Mekanism.osmiumGenerationEnabled); - dataStream.writeBoolean(Mekanism.copperGenerationEnabled); - dataStream.writeBoolean(Mekanism.tinGenerationEnabled); - dataStream.writeBoolean(Mekanism.disableBCSteelCrafting); - dataStream.writeBoolean(Mekanism.disableBCBronzeCrafting); - dataStream.writeBoolean(Mekanism.updateNotifications); - dataStream.writeBoolean(Mekanism.controlCircuitOreDict); - dataStream.writeBoolean(Mekanism.logPackets); - dataStream.writeBoolean(Mekanism.dynamicTankEasterEgg); - dataStream.writeBoolean(Mekanism.voiceServerEnabled); - dataStream.writeBoolean(Mekanism.forceBuildcraft); - dataStream.writeBoolean(Mekanism.cardboardSpawners); - dataStream.writeInt(Mekanism.obsidianTNTDelay); - dataStream.writeInt(Mekanism.obsidianTNTBlastRadius); - dataStream.writeInt(Mekanism.UPDATE_DELAY); - dataStream.writeInt(Mekanism.osmiumGenerationAmount); - dataStream.writeInt(Mekanism.copperGenerationAmount); - dataStream.writeInt(Mekanism.tinGenerationAmount); - dataStream.writeDouble(Mekanism.FROM_IC2); - dataStream.writeDouble(Mekanism.TO_IC2); - dataStream.writeDouble(Mekanism.FROM_BC); - dataStream.writeDouble(Mekanism.TO_BC); - dataStream.writeDouble(Mekanism.ENERGY_PER_REDSTONE); - dataStream.writeInt(Mekanism.VOICE_PORT); - dataStream.writeInt(Mekanism.maxUpgradeMultiplier); - - dataStream.writeDouble(Mekanism.enrichmentChamberUsage); + dataStream.writeBoolean(Mekanism.copperGenerationEnabled); + dataStream.writeBoolean(Mekanism.tinGenerationEnabled); + dataStream.writeBoolean(Mekanism.disableBCSteelCrafting); + dataStream.writeBoolean(Mekanism.disableBCBronzeCrafting); + dataStream.writeBoolean(Mekanism.updateNotifications); + dataStream.writeBoolean(Mekanism.controlCircuitOreDict); + dataStream.writeBoolean(Mekanism.logPackets); + dataStream.writeBoolean(Mekanism.dynamicTankEasterEgg); + dataStream.writeBoolean(Mekanism.voiceServerEnabled); + dataStream.writeBoolean(Mekanism.forceBuildcraft); + dataStream.writeBoolean(Mekanism.cardboardSpawners); + dataStream.writeInt(Mekanism.obsidianTNTDelay); + dataStream.writeInt(Mekanism.obsidianTNTBlastRadius); + dataStream.writeInt(Mekanism.UPDATE_DELAY); + dataStream.writeInt(Mekanism.osmiumGenerationAmount); + dataStream.writeInt(Mekanism.copperGenerationAmount); + dataStream.writeInt(Mekanism.tinGenerationAmount); + dataStream.writeDouble(Mekanism.FROM_IC2); + dataStream.writeDouble(Mekanism.TO_IC2); + dataStream.writeDouble(Mekanism.FROM_BC); + dataStream.writeDouble(Mekanism.TO_BC); + dataStream.writeDouble(Mekanism.ENERGY_PER_REDSTONE); + dataStream.writeInt(Mekanism.VOICE_PORT); + dataStream.writeInt(Mekanism.maxUpgradeMultiplier); + + dataStream.writeDouble(Mekanism.enrichmentChamberUsage); dataStream.writeDouble(Mekanism.osmiumCompressorUsage); dataStream.writeDouble(Mekanism.combinerUsage); dataStream.writeDouble(Mekanism.crusherUsage); @@ -129,7 +129,7 @@ public class PacketConfigSync implements IMekanismPacket dataStream.writeDouble(Mekanism.chemicalDissolutionChamberUsage); dataStream.writeDouble(Mekanism.chemicalWasherUsage); dataStream.writeDouble(Mekanism.chemicalCrystalizerUsage); - + for(IModule module : Mekanism.modulesLoaded) { module.writeConfig(dataStream); diff --git a/common/mekanism/common/network/PacketConfigurationUpdate.java b/common/mekanism/common/network/PacketConfigurationUpdate.java index 5e6228013..00dcbb052 100644 --- a/common/mekanism/common/network/PacketConfigurationUpdate.java +++ b/common/mekanism/common/network/PacketConfigurationUpdate.java @@ -21,61 +21,61 @@ import com.google.common.io.ByteArrayDataInput; public class PacketConfigurationUpdate implements IMekanismPacket { public Coord4D object3D; - + public int configIndex; - + public int inputSide; - + public int clickType; - + public ConfigurationPacket packetType; - + @Override public String getName() { return "ConfigurationUpdate"; } - + @Override public IMekanismPacket setParams(Object... data) { packetType = (ConfigurationPacket)data[0]; - + object3D = (Coord4D)data[1]; - + if(packetType == ConfigurationPacket.EJECT_COLOR) { clickType = (Integer)data[2]; } - + if(packetType == ConfigurationPacket.SIDE_DATA) { clickType = (Integer)data[2]; configIndex = (Integer)data[3]; } - + if(packetType == ConfigurationPacket.INPUT_COLOR) { clickType = (Integer)data[2]; inputSide = (Integer)data[3]; } - + return this; } - + @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { packetType = ConfigurationPacket.values()[dataStream.readInt()]; - + object3D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - + TileEntity tile = object3D.getTileEntity(world); - + if(tile instanceof IInvConfiguration) { IInvConfiguration config = (IInvConfiguration)tile; - + if(packetType == ConfigurationPacket.EJECT) { config.getEjector().setEjecting(!config.getEjector().isEjecting()); @@ -84,7 +84,7 @@ public class PacketConfigurationUpdate implements IMekanismPacket { clickType = dataStream.readInt(); configIndex = dataStream.readInt(); - + if(clickType == 0) { MekanismUtils.incrementOutput((IInvConfiguration)tile, configIndex); @@ -97,13 +97,13 @@ public class PacketConfigurationUpdate implements IMekanismPacket { ((IInvConfiguration)tile).getConfiguration()[configIndex] = 0; } - + PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(object3D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), object3D, 50D); } else if(packetType == ConfigurationPacket.EJECT_COLOR) { clickType = dataStream.readInt(); - + if(clickType == 0) { config.getEjector().setOutputColor(TransporterUtils.increment(config.getEjector().getOutputColor())); @@ -121,9 +121,9 @@ public class PacketConfigurationUpdate implements IMekanismPacket { clickType = dataStream.readInt(); inputSide = dataStream.readInt(); - + ForgeDirection side = ForgeDirection.getOrientation(inputSide); - + if(clickType == 0) { config.getEjector().setInputColor(side, TransporterUtils.increment(config.getEjector().getInputColor(side))); @@ -141,41 +141,41 @@ public class PacketConfigurationUpdate implements IMekanismPacket { config.getEjector().setStrictInput(!config.getEjector().hasStrictInput()); } - + for(EntityPlayer p : ((TileEntityBasicBlock)config).playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(object3D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), p); } } } - + @Override public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(packetType.ordinal()); - + dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + dataStream.writeInt(object3D.dimensionId); - + if(packetType != ConfigurationPacket.EJECT && packetType != ConfigurationPacket.STRICT_INPUT) { dataStream.writeInt(clickType); } - + if(packetType == ConfigurationPacket.SIDE_DATA) { dataStream.writeInt(configIndex); } - + if(packetType == ConfigurationPacket.INPUT_COLOR) { dataStream.writeInt(inputSide); } } - + public static enum ConfigurationPacket { EJECT, SIDE_DATA, EJECT_COLOR, INPUT_COLOR, STRICT_INPUT diff --git a/common/mekanism/common/network/PacketConfiguratorState.java b/common/mekanism/common/network/PacketConfiguratorState.java index d3753a863..d8a710ada 100644 --- a/common/mekanism/common/network/PacketConfiguratorState.java +++ b/common/mekanism/common/network/PacketConfiguratorState.java @@ -12,28 +12,28 @@ import com.google.common.io.ByteArrayDataInput; public class PacketConfiguratorState implements IMekanismPacket { public byte state; - + @Override public String getName() { return "ConfiguratorState"; } - + @Override public IMekanismPacket setParams(Object... data) { state = (Byte)data[0]; - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { - byte state = dataStream.readByte(); - + byte state = dataStream.readByte(); + ItemStack itemstack = player.getCurrentEquippedItem(); - + if(itemstack != null && itemstack.getItem() instanceof ItemConfigurator) { ((ItemConfigurator)itemstack.getItem()).setState(itemstack, (byte)state); diff --git a/common/mekanism/common/network/PacketDataRequest.java b/common/mekanism/common/network/PacketDataRequest.java index ad1c86478..bae00d5f9 100644 --- a/common/mekanism/common/network/PacketDataRequest.java +++ b/common/mekanism/common/network/PacketDataRequest.java @@ -21,51 +21,51 @@ import cpw.mods.fml.common.FMLCommonHandler; public class PacketDataRequest implements IMekanismPacket { public Coord4D object3D; - + @Override public String getName() { return "DataRequest"; } - + @Override public IMekanismPacket setParams(Object... data) { object3D = (Coord4D)data[0]; - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { int x = dataStream.readInt(); int y = dataStream.readInt(); int z = dataStream.readInt(); - + int id = dataStream.readInt(); - + World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(id); - + if(worldServer != null && worldServer.getBlockTileEntity(x, y, z) instanceof ITileNetwork) { TileEntity tileEntity = worldServer.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof TileEntityDynamicTank) { ((TileEntityDynamicTank)tileEntity).sendStructure = true; } - + if(tileEntity instanceof IGridTransmitter) { IGridTransmitter transmitter = (IGridTransmitter)tileEntity; - + if(transmitter.getTransmitterNetwork() instanceof DynamicNetwork) { ((DynamicNetwork)transmitter.getTransmitterNetwork()).addUpdate(player); } } - + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(worldServer.getBlockTileEntity(x, y, z)), ((ITileNetwork)worldServer.getBlockTileEntity(x, y, z)).getNetworkedData(new ArrayList()))); } } @@ -76,7 +76,7 @@ public class PacketDataRequest implements IMekanismPacket dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + dataStream.writeInt(object3D.dimensionId); } } diff --git a/common/mekanism/common/network/PacketDigitUpdate.java b/common/mekanism/common/network/PacketDigitUpdate.java index fa41b1fae..6c9ee36a1 100644 --- a/common/mekanism/common/network/PacketDigitUpdate.java +++ b/common/mekanism/common/network/PacketDigitUpdate.java @@ -13,30 +13,30 @@ public class PacketDigitUpdate implements IMekanismPacket { public int index; public int digit; - + @Override - public String getName() + public String getName() { return "DigitUpdate"; } - + @Override public IMekanismPacket setParams(Object... data) { index = (Integer)data[0]; digit = (Integer)data[1]; - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { int index = dataStream.readInt(); int digit = dataStream.readInt(); - + ItemStack currentStack = player.getCurrentEquippedItem(); - + if(currentStack != null && currentStack.getItem() instanceof ItemPortableTeleporter) { ItemPortableTeleporter item = (ItemPortableTeleporter)currentStack.getItem(); diff --git a/common/mekanism/common/network/PacketDigitalMinerGui.java b/common/mekanism/common/network/PacketDigitalMinerGui.java index 6222d0d99..78514ce88 100644 --- a/common/mekanism/common/network/PacketDigitalMinerGui.java +++ b/common/mekanism/common/network/PacketDigitalMinerGui.java @@ -30,26 +30,26 @@ import cpw.mods.fml.relauncher.SideOnly; public class PacketDigitalMinerGui implements IMekanismPacket { public Coord4D object3D; - + public MinerGuiPacket packetType; - + public int type; - + public int windowId = -1; - + public int index = -1; - + @Override public String getName() { return "DigitalMinerGui"; } - + @Override public IMekanismPacket setParams(Object... data) { packetType = (MinerGuiPacket)data[0]; - + object3D = (Coord4D)data[1]; type = (Integer)data[2]; @@ -66,33 +66,33 @@ public class PacketDigitalMinerGui implements IMekanismPacket windowId = (Integer)data[3]; index = (Integer)data[4]; } - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { packetType = MinerGuiPacket.values()[dataStream.readInt()]; - + object3D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - + type = dataStream.readInt(); - + if(packetType == MinerGuiPacket.CLIENT || packetType == MinerGuiPacket.CLIENT_INDEX) { windowId = dataStream.readInt(); } - + if(packetType == MinerGuiPacket.SERVER_INDEX || packetType == MinerGuiPacket.CLIENT_INDEX) { index = dataStream.readInt(); } - + if(!world.isRemote) - { + { World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(object3D.dimensionId); - + if(worldServer != null && object3D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { openServerGui(packetType, type, worldServer, (EntityPlayerMP)player, object3D, index); @@ -110,7 +110,7 @@ public class PacketDigitalMinerGui implements IMekanismPacket { FMLCommonHandler.instance().showGuiScreen(getGui(packetType, type, player, world, object3D.xCoord, object3D.yCoord, object3D.zCoord, index)); } - + player.openContainer.windowId = windowId; } catch(Exception e) { e.printStackTrace(); @@ -118,13 +118,13 @@ public class PacketDigitalMinerGui implements IMekanismPacket } } } - + public static void openServerGui(MinerGuiPacket t, int guiType, World world, EntityPlayerMP playerMP, Coord4D obj, int i) { Container container = null; - + playerMP.closeContainer(); - + if(guiType == 0) { container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world)); @@ -137,34 +137,34 @@ public class PacketDigitalMinerGui implements IMekanismPacket { container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world)); } - - playerMP.incrementWindowID(); - int window = playerMP.currentWindowId; - - if(t == MinerGuiPacket.SERVER) - { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketDigitalMinerGui().setParams(MinerGuiPacket.CLIENT, obj, guiType, window), playerMP); - } - else if(t == MinerGuiPacket.SERVER_INDEX) - { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketDigitalMinerGui().setParams(MinerGuiPacket.CLIENT_INDEX, obj, guiType, window, i), playerMP); - } - - playerMP.openContainer = container; - playerMP.openContainer.windowId = window; - playerMP.openContainer.addCraftingToCrafters(playerMP); - - if(guiType == 0) - { - TileEntityDigitalMiner tile = (TileEntityDigitalMiner)obj.getTileEntity(world); - - for(EntityPlayer player : tile.playersUsing) - { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(obj, tile.getFilterPacket(new ArrayList())), player); - } - } + + playerMP.incrementWindowID(); + int window = playerMP.currentWindowId; + + if(t == MinerGuiPacket.SERVER) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketDigitalMinerGui().setParams(MinerGuiPacket.CLIENT, obj, guiType, window), playerMP); + } + else if(t == MinerGuiPacket.SERVER_INDEX) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketDigitalMinerGui().setParams(MinerGuiPacket.CLIENT_INDEX, obj, guiType, window, i), playerMP); + } + + playerMP.openContainer = container; + playerMP.openContainer.windowId = window; + playerMP.openContainer.addCraftingToCrafters(playerMP); + + if(guiType == 0) + { + TileEntityDigitalMiner tile = (TileEntityDigitalMiner)obj.getTileEntity(world); + + for(EntityPlayer player : tile.playersUsing) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(obj, tile.getFilterPacket(new ArrayList())), player); + } + } } - + @SideOnly(Side.CLIENT) public GuiScreen getGui(MinerGuiPacket packetType, int type, EntityPlayer player, World world, int x, int y, int z, int index) { @@ -200,7 +200,7 @@ public class PacketDigitalMinerGui implements IMekanismPacket } } } - + return null; } @@ -208,26 +208,26 @@ public class PacketDigitalMinerGui implements IMekanismPacket public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(packetType.ordinal()); - + dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + dataStream.writeInt(object3D.dimensionId); - + dataStream.writeInt(type); - + if(packetType == MinerGuiPacket.CLIENT || packetType == MinerGuiPacket.CLIENT_INDEX) { dataStream.writeInt(windowId); } - + if(packetType == MinerGuiPacket.SERVER_INDEX || packetType == MinerGuiPacket.CLIENT_INDEX) { dataStream.writeInt(index); } } - + public static enum MinerGuiPacket { SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX diff --git a/common/mekanism/common/network/PacketEditFilter.java b/common/mekanism/common/network/PacketEditFilter.java index 59f61efd2..a1cb10c7c 100644 --- a/common/mekanism/common/network/PacketEditFilter.java +++ b/common/mekanism/common/network/PacketEditFilter.java @@ -20,67 +20,67 @@ import cpw.mods.fml.common.FMLCommonHandler; public class PacketEditFilter implements IMekanismPacket { public Coord4D object3D; - + public TransporterFilter tFilter; public TransporterFilter tEdited; - + public MinerFilter mFilter; public MinerFilter mEdited; - + public byte type = -1; - + public boolean delete; - + @Override public String getName() { return "EditFilter"; } - + @Override public IMekanismPacket setParams(Object... data) { object3D = (Coord4D)data[0]; delete = (Boolean)data[1]; - + if(data[2] instanceof TransporterFilter) { tFilter = (TransporterFilter)data[2]; - + if(!delete) { tEdited = (TransporterFilter)data[3]; } - + type = 0; } else if(data[2] instanceof MinerFilter) { mFilter = (MinerFilter)data[2]; - + if(!delete) { mEdited = (MinerFilter)data[3]; } - + type = 1; } - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { object3D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - + type = dataStream.readByte(); delete = dataStream.readBoolean(); - + if(type == 0) { tFilter = TransporterFilter.readFromPacket(dataStream); - + if(!delete) { tEdited = TransporterFilter.readFromPacket(dataStream); @@ -89,35 +89,35 @@ public class PacketEditFilter implements IMekanismPacket else if(type == 1) { mFilter = MinerFilter.readFromPacket(dataStream); - + if(!delete) { mEdited = MinerFilter.readFromPacket(dataStream); } } - + World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(object3D.dimensionId); - + if(worldServer != null) { if(type == 0 && object3D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) { TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)object3D.getTileEntity(worldServer); - + if(!sorter.filters.contains(tFilter)) { return; } - + int index = sorter.filters.indexOf(tFilter); - + sorter.filters.remove(index); - + if(!delete) { sorter.filters.add(index, tEdited); } - + for(EntityPlayer iterPlayer : sorter.playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(sorter), sorter.getFilterPacket(new ArrayList())), iterPlayer); @@ -126,21 +126,21 @@ public class PacketEditFilter implements IMekanismPacket else if(type == 1 && object3D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { TileEntityDigitalMiner miner = (TileEntityDigitalMiner)object3D.getTileEntity(worldServer); - + if(!miner.filters.contains(mFilter)) { return; } - + int index = miner.filters.indexOf(mFilter); - + miner.filters.remove(index); - + if(!delete) { miner.filters.add(index, mEdited); } - + for(EntityPlayer iterPlayer : miner.playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(miner), miner.getFilterPacket(new ArrayList())), iterPlayer); @@ -155,19 +155,19 @@ public class PacketEditFilter implements IMekanismPacket dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + dataStream.writeInt(object3D.dimensionId); - + dataStream.writeByte(type); - + dataStream.writeBoolean(delete); - + ArrayList data = new ArrayList(); - + if(type == 0) { tFilter.write(data); - + if(!delete) { tEdited.write(data); @@ -176,13 +176,13 @@ public class PacketEditFilter implements IMekanismPacket else if(type == 1) { mFilter.write(data); - + if(!delete) { mEdited.write(data); } } - + PacketHandler.encode(data.toArray(), dataStream); } } diff --git a/common/mekanism/common/network/PacketElectricBowState.java b/common/mekanism/common/network/PacketElectricBowState.java index 52444f0bc..5de7471fa 100644 --- a/common/mekanism/common/network/PacketElectricBowState.java +++ b/common/mekanism/common/network/PacketElectricBowState.java @@ -12,28 +12,28 @@ import com.google.common.io.ByteArrayDataInput; public class PacketElectricBowState implements IMekanismPacket { public boolean fireMode; - + @Override - public String getName() + public String getName() { return "ElectricBowState"; } - + @Override public IMekanismPacket setParams(Object... data) { fireMode = (Boolean)data[0]; - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { - boolean state = dataStream.readBoolean(); - + boolean state = dataStream.readBoolean(); + ItemStack itemstack = player.getCurrentEquippedItem(); - + if(itemstack != null && itemstack.getItem() instanceof ItemElectricBow) { ((ItemElectricBow)itemstack.getItem()).setFireState(itemstack, state); diff --git a/common/mekanism/common/network/PacketElectricChest.java b/common/mekanism/common/network/PacketElectricChest.java index 7d595bd0e..7ed6b622b 100644 --- a/common/mekanism/common/network/PacketElectricChest.java +++ b/common/mekanism/common/network/PacketElectricChest.java @@ -20,267 +20,267 @@ import com.google.common.io.ByteArrayDataInput; public class PacketElectricChest implements IMekanismPacket { public ElectricChestPacketType activeType; - + public boolean isBlock; - + public boolean locked; - + public String password; - + public int guiType; public int windowId; - + public boolean useEnergy; - + public Coord4D obj; - + @Override - public String getName() + public String getName() { return "ElectricChest"; } - + @Override public IMekanismPacket setParams(Object... data) { activeType = (ElectricChestPacketType)data[0]; - + switch(activeType) { case LOCK: locked = (Boolean)data[1]; isBlock = (Boolean)data[2]; - + if(isBlock) { obj = (Coord4D)data[3]; } - + break; case PASSWORD: password = (String)data[1]; isBlock = (Boolean)data[2]; - + if(isBlock) { obj = (Coord4D)data[3]; } - + break; case CLIENT_OPEN: guiType = (Integer)data[1]; windowId = (Integer)data[2]; isBlock = (Boolean)data[3]; - + if(isBlock) { obj = (Coord4D)data[4]; } - + break; case SERVER_OPEN: useEnergy = (Boolean)data[1]; isBlock = (Boolean)data[2]; - + if(isBlock) { obj = (Coord4D)data[3]; } - + break; } - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { ElectricChestPacketType packetType = ElectricChestPacketType.values()[dataStream.readInt()]; - - if(packetType == ElectricChestPacketType.SERVER_OPEN) - { - try { - boolean energy = dataStream.readBoolean(); - boolean block = dataStream.readBoolean(); - - if(block) - { - int x = dataStream.readInt(); - int y = dataStream.readInt(); - int z = dataStream.readInt(); - - TileEntityElectricChest tileEntity = (TileEntityElectricChest)world.getBlockTileEntity(x, y, z); - - if(energy) - { - tileEntity.setEnergy(tileEntity.getEnergy() - 100); - } - - MekanismUtils.openElectricChestGui((EntityPlayerMP)player, tileEntity, null, true); - } - else { - ItemStack stack = player.getCurrentEquippedItem(); - - if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) - { - if(energy) - { - ((IEnergizedItem)stack.getItem()).setEnergy(stack, ((IEnergizedItem)stack.getItem()).getEnergy(stack) - 100); - } - - InventoryElectricChest inventory = new InventoryElectricChest(player); - MekanismUtils.openElectricChestGui((EntityPlayerMP)player, null, inventory, false); - } - } - } catch(Exception e) { - System.err.println("[Mekanism] Error while handling electric chest open packet."); - e.printStackTrace(); - } - } - else if(packetType == ElectricChestPacketType.CLIENT_OPEN) - { - try { - int type = dataStream.readInt(); - int id = dataStream.readInt(); - boolean block = dataStream.readBoolean(); - - int x = 0; - int y = 0; - int z = 0; - - if(block) - { - x = dataStream.readInt(); - y = dataStream.readInt(); - z = dataStream.readInt(); - } - - Mekanism.proxy.openElectricChest(player, type, id, block, x, y, z); - } catch(Exception e) { - System.err.println("[Mekanism] Error while handling electric chest open packet."); - e.printStackTrace(); - } - } - else if(packetType == ElectricChestPacketType.PASSWORD) - { - try { - String pass = dataStream.readUTF(); - boolean block = dataStream.readBoolean(); - - if(block) - { - int x = dataStream.readInt(); - int y = dataStream.readInt(); - int z = dataStream.readInt(); - - TileEntityElectricChest tileEntity = (TileEntityElectricChest)world.getBlockTileEntity(x, y, z); - tileEntity.password = pass; - tileEntity.authenticated = true; - } - else { - ItemStack stack = player.getCurrentEquippedItem(); - - if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) - { - ((IElectricChest)stack.getItem()).setPassword(stack, pass); - ((IElectricChest)stack.getItem()).setAuthenticated(stack, true); - } - } - } catch(Exception e) { - System.err.println("[Mekanism] Error while handling electric chest password packet."); - e.printStackTrace(); - } - } - else if(packetType == ElectricChestPacketType.LOCK) - { - try { - boolean lock = dataStream.readBoolean(); - boolean block = dataStream.readBoolean(); - - if(block) - { - int x = dataStream.readInt(); - int y = dataStream.readInt(); - int z = dataStream.readInt(); - - TileEntityElectricChest tileEntity = (TileEntityElectricChest)world.getBlockTileEntity(x, y, z); - tileEntity.locked = lock; - } - else { - ItemStack stack = player.getCurrentEquippedItem(); - - if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) - { - ((IElectricChest)stack.getItem()).setLocked(stack, lock); - } - } - } catch(Exception e) { - System.err.println("[Mekanism] Error while handling electric chest password packet."); - e.printStackTrace(); - } - } + + if(packetType == ElectricChestPacketType.SERVER_OPEN) + { + try { + boolean energy = dataStream.readBoolean(); + boolean block = dataStream.readBoolean(); + + if(block) + { + int x = dataStream.readInt(); + int y = dataStream.readInt(); + int z = dataStream.readInt(); + + TileEntityElectricChest tileEntity = (TileEntityElectricChest)world.getBlockTileEntity(x, y, z); + + if(energy) + { + tileEntity.setEnergy(tileEntity.getEnergy() - 100); + } + + MekanismUtils.openElectricChestGui((EntityPlayerMP)player, tileEntity, null, true); + } + else { + ItemStack stack = player.getCurrentEquippedItem(); + + if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) + { + if(energy) + { + ((IEnergizedItem)stack.getItem()).setEnergy(stack, ((IEnergizedItem)stack.getItem()).getEnergy(stack) - 100); + } + + InventoryElectricChest inventory = new InventoryElectricChest(player); + MekanismUtils.openElectricChestGui((EntityPlayerMP)player, null, inventory, false); + } + } + } catch(Exception e) { + System.err.println("[Mekanism] Error while handling electric chest open packet."); + e.printStackTrace(); + } + } + else if(packetType == ElectricChestPacketType.CLIENT_OPEN) + { + try { + int type = dataStream.readInt(); + int id = dataStream.readInt(); + boolean block = dataStream.readBoolean(); + + int x = 0; + int y = 0; + int z = 0; + + if(block) + { + x = dataStream.readInt(); + y = dataStream.readInt(); + z = dataStream.readInt(); + } + + Mekanism.proxy.openElectricChest(player, type, id, block, x, y, z); + } catch(Exception e) { + System.err.println("[Mekanism] Error while handling electric chest open packet."); + e.printStackTrace(); + } + } + else if(packetType == ElectricChestPacketType.PASSWORD) + { + try { + String pass = dataStream.readUTF(); + boolean block = dataStream.readBoolean(); + + if(block) + { + int x = dataStream.readInt(); + int y = dataStream.readInt(); + int z = dataStream.readInt(); + + TileEntityElectricChest tileEntity = (TileEntityElectricChest)world.getBlockTileEntity(x, y, z); + tileEntity.password = pass; + tileEntity.authenticated = true; + } + else { + ItemStack stack = player.getCurrentEquippedItem(); + + if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) + { + ((IElectricChest)stack.getItem()).setPassword(stack, pass); + ((IElectricChest)stack.getItem()).setAuthenticated(stack, true); + } + } + } catch(Exception e) { + System.err.println("[Mekanism] Error while handling electric chest password packet."); + e.printStackTrace(); + } + } + else if(packetType == ElectricChestPacketType.LOCK) + { + try { + boolean lock = dataStream.readBoolean(); + boolean block = dataStream.readBoolean(); + + if(block) + { + int x = dataStream.readInt(); + int y = dataStream.readInt(); + int z = dataStream.readInt(); + + TileEntityElectricChest tileEntity = (TileEntityElectricChest)world.getBlockTileEntity(x, y, z); + tileEntity.locked = lock; + } + else { + ItemStack stack = player.getCurrentEquippedItem(); + + if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) + { + ((IElectricChest)stack.getItem()).setLocked(stack, lock); + } + } + } catch(Exception e) { + System.err.println("[Mekanism] Error while handling electric chest password packet."); + e.printStackTrace(); + } + } } @Override public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(activeType.ordinal()); - + switch(activeType) { case LOCK: dataStream.writeBoolean(locked); dataStream.writeBoolean(isBlock); - + if(isBlock) { dataStream.writeInt(obj.xCoord); dataStream.writeInt(obj.yCoord); dataStream.writeInt(obj.zCoord); } - + break; case PASSWORD: dataStream.writeUTF(password); dataStream.writeBoolean(isBlock); - + if(isBlock) { dataStream.writeInt(obj.xCoord); dataStream.writeInt(obj.yCoord); dataStream.writeInt(obj.zCoord); } - + break; case CLIENT_OPEN: dataStream.writeInt(guiType); dataStream.writeInt(windowId); dataStream.writeBoolean(isBlock); - + if(isBlock) { dataStream.writeInt(obj.xCoord); dataStream.writeInt(obj.yCoord); dataStream.writeInt(obj.zCoord); } - + break; case SERVER_OPEN: dataStream.writeBoolean(useEnergy); dataStream.writeBoolean(isBlock); - + if(isBlock) { dataStream.writeInt(obj.xCoord); dataStream.writeInt(obj.yCoord); dataStream.writeInt(obj.zCoord); } - + break; } } - + public static enum ElectricChestPacketType { LOCK, diff --git a/common/mekanism/common/network/PacketJetpackData.java b/common/mekanism/common/network/PacketJetpackData.java index bb31b3073..1eb25aafc 100644 --- a/common/mekanism/common/network/PacketJetpackData.java +++ b/common/mekanism/common/network/PacketJetpackData.java @@ -15,27 +15,27 @@ import com.google.common.io.ByteArrayDataInput; public class PacketJetpackData implements IMekanismPacket { public JetpackPacket packetType; - + public String username; public boolean value; - + @Override - public String getName() + public String getName() { return "JetpackData"; } - + @Override public IMekanismPacket setParams(Object... data) { packetType = (JetpackPacket)data[0]; - + if(packetType == JetpackPacket.UPDATE) { username = (String)data[1]; value = (Boolean)data[2]; } - + return this; } @@ -43,9 +43,9 @@ public class PacketJetpackData implements IMekanismPacket public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { packetType = JetpackPacket.values()[dataStream.readInt()]; - - if(packetType == JetpackPacket.FULL) - { + + if(packetType == JetpackPacket.FULL) + { Mekanism.jetpackOn.clear(); int amount = dataStream.readInt(); @@ -54,12 +54,12 @@ public class PacketJetpackData implements IMekanismPacket { Mekanism.jetpackOn.add(dataStream.readUTF()); } - } - else if(packetType == JetpackPacket.UPDATE) + } + else if(packetType == JetpackPacket.UPDATE) { String username = dataStream.readUTF(); boolean value = dataStream.readBoolean(); - + if(value) { Mekanism.jetpackOn.add(username); @@ -67,7 +67,7 @@ public class PacketJetpackData implements IMekanismPacket else { Mekanism.jetpackOn.remove(username); } - + if(!world.isRemote) { PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketJetpackData().setParams(JetpackPacket.UPDATE, username, value), world.provider.dimensionId); @@ -76,7 +76,7 @@ public class PacketJetpackData implements IMekanismPacket else if(packetType == JetpackPacket.MODE) { ItemStack stack = player.getCurrentItemOrArmor(3); - + if(stack != null && stack.getItem() instanceof ItemJetpack) { ((ItemJetpack)stack.getItem()).incrementMode(stack); @@ -88,7 +88,7 @@ public class PacketJetpackData implements IMekanismPacket public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(packetType.ordinal()); - + if(packetType == JetpackPacket.UPDATE) { dataStream.writeUTF(username); @@ -104,7 +104,7 @@ public class PacketJetpackData implements IMekanismPacket } } } - + public static enum JetpackPacket { UPDATE, diff --git a/common/mekanism/common/network/PacketKey.java b/common/mekanism/common/network/PacketKey.java index e8178ff55..3d60c3ea0 100644 --- a/common/mekanism/common/network/PacketKey.java +++ b/common/mekanism/common/network/PacketKey.java @@ -12,35 +12,35 @@ public class PacketKey implements IMekanismPacket { public int key; public boolean add; - + @Override - public String getName() + public String getName() { return "Key"; } - + @Override public IMekanismPacket setParams(Object... data) { key = (Integer)data[0]; add = (Boolean)data[1]; - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { - key = dataStream.readInt(); - add = dataStream.readBoolean(); - - if(add) - { - Mekanism.keyMap.add(player, key); - } - else { - Mekanism.keyMap.remove(player, key); - } + key = dataStream.readInt(); + add = dataStream.readBoolean(); + + if(add) + { + Mekanism.keyMap.add(player, key); + } + else { + Mekanism.keyMap.remove(player, key); + } } @Override diff --git a/common/mekanism/common/network/PacketLogisticalSorterGui.java b/common/mekanism/common/network/PacketLogisticalSorterGui.java index e1ed27d37..b7b78b121 100644 --- a/common/mekanism/common/network/PacketLogisticalSorterGui.java +++ b/common/mekanism/common/network/PacketLogisticalSorterGui.java @@ -28,26 +28,26 @@ import cpw.mods.fml.relauncher.SideOnly; public class PacketLogisticalSorterGui implements IMekanismPacket { public Coord4D object3D; - + public SorterGuiPacket packetType; - + public int type; - + public int windowId = -1; - + public int index = -1; - + @Override public String getName() { return "LogisticalSorterGui"; } - + @Override public IMekanismPacket setParams(Object... data) { packetType = (SorterGuiPacket)data[0]; - + object3D = (Coord4D)data[1]; type = (Integer)data[2]; @@ -64,33 +64,33 @@ public class PacketLogisticalSorterGui implements IMekanismPacket windowId = (Integer)data[3]; index = (Integer)data[4]; } - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { packetType = SorterGuiPacket.values()[dataStream.readInt()]; - + object3D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - + type = dataStream.readInt(); - + if(packetType == SorterGuiPacket.CLIENT || packetType == SorterGuiPacket.CLIENT_INDEX) { windowId = dataStream.readInt(); } - + if(packetType == SorterGuiPacket.SERVER_INDEX || packetType == SorterGuiPacket.CLIENT_INDEX) { index = dataStream.readInt(); } - + if(!world.isRemote) - { + { World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(object3D.dimensionId); - + if(worldServer != null && object3D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) { openServerGui(packetType, type, worldServer, (EntityPlayerMP)player, object3D, index); @@ -108,7 +108,7 @@ public class PacketLogisticalSorterGui implements IMekanismPacket { FMLCommonHandler.instance().showGuiScreen(getGui(packetType, type, player, world, object3D.xCoord, object3D.yCoord, object3D.zCoord, index)); } - + player.openContainer.windowId = windowId; } catch(Exception e) { e.printStackTrace(); @@ -116,13 +116,13 @@ public class PacketLogisticalSorterGui implements IMekanismPacket } } } - + public static void openServerGui(SorterGuiPacket t, int guiType, World world, EntityPlayerMP playerMP, Coord4D obj, int i) { Container container = null; - - playerMP.closeContainer(); - + + playerMP.closeContainer(); + if(guiType == 0) { container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world)); @@ -131,24 +131,24 @@ public class PacketLogisticalSorterGui implements IMekanismPacket { container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world)); } - - playerMP.incrementWindowID(); - int window = playerMP.currentWindowId; - - if(t == SorterGuiPacket.SERVER) - { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.CLIENT, obj, guiType, window), playerMP); - } - else if(t == SorterGuiPacket.SERVER_INDEX) - { - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.CLIENT_INDEX, obj, guiType, window, i), playerMP); - } - - playerMP.openContainer = container; - playerMP.openContainer.windowId = window; - playerMP.openContainer.addCraftingToCrafters(playerMP); + + playerMP.incrementWindowID(); + int window = playerMP.currentWindowId; + + if(t == SorterGuiPacket.SERVER) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.CLIENT, obj, guiType, window), playerMP); + } + else if(t == SorterGuiPacket.SERVER_INDEX) + { + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.CLIENT_INDEX, obj, guiType, window, i), playerMP); + } + + playerMP.openContainer = container; + playerMP.openContainer.windowId = window; + playerMP.openContainer.addCraftingToCrafters(playerMP); } - + @SideOnly(Side.CLIENT) public GuiScreen getGui(SorterGuiPacket packetType, int type, EntityPlayer player, World world, int x, int y, int z, int index) { @@ -180,7 +180,7 @@ public class PacketLogisticalSorterGui implements IMekanismPacket } } } - + return null; } @@ -188,26 +188,26 @@ public class PacketLogisticalSorterGui implements IMekanismPacket public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(packetType.ordinal()); - + dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + dataStream.writeInt(object3D.dimensionId); - + dataStream.writeInt(type); - + if(packetType == SorterGuiPacket.CLIENT || packetType == SorterGuiPacket.CLIENT_INDEX) { dataStream.writeInt(windowId); } - + if(packetType == SorterGuiPacket.SERVER_INDEX || packetType == SorterGuiPacket.CLIENT_INDEX) { dataStream.writeInt(index); } } - + public static enum SorterGuiPacket { SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX diff --git a/common/mekanism/common/network/PacketNewFilter.java b/common/mekanism/common/network/PacketNewFilter.java index 2d1a1b56e..bb279afe6 100644 --- a/common/mekanism/common/network/PacketNewFilter.java +++ b/common/mekanism/common/network/PacketNewFilter.java @@ -20,24 +20,24 @@ import cpw.mods.fml.common.FMLCommonHandler; public class PacketNewFilter implements IMekanismPacket { public Coord4D object3D; - + public TransporterFilter tFilter; - + public MinerFilter mFilter; - + public byte type = -1; - + @Override public String getName() { return "NewFilter"; } - + @Override public IMekanismPacket setParams(Object... data) { object3D = (Coord4D)data[0]; - + if(data[1] instanceof TransporterFilter) { tFilter = (TransporterFilter)data[1]; @@ -48,27 +48,27 @@ public class PacketNewFilter implements IMekanismPacket mFilter = (MinerFilter)data[1]; type = 1; } - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { object3D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); type = dataStream.readByte(); - + World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(object3D.dimensionId); - + if(worldServer != null) { if(type == 0 && object3D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) { TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)object3D.getTileEntity(worldServer); TransporterFilter filter = TransporterFilter.readFromPacket(dataStream); - + sorter.filters.add(filter); - + for(EntityPlayer iterPlayer : sorter.playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(sorter), sorter.getFilterPacket(new ArrayList())), iterPlayer); @@ -78,9 +78,9 @@ public class PacketNewFilter implements IMekanismPacket { TileEntityDigitalMiner miner = (TileEntityDigitalMiner)object3D.getTileEntity(worldServer); MinerFilter filter = MinerFilter.readFromPacket(dataStream); - + miner.filters.add(filter); - + for(EntityPlayer iterPlayer : miner.playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(miner), miner.getFilterPacket(new ArrayList())), iterPlayer); @@ -95,13 +95,13 @@ public class PacketNewFilter implements IMekanismPacket dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + dataStream.writeInt(object3D.dimensionId); - + dataStream.writeByte(type); - + ArrayList data = new ArrayList(); - + if(type == 0) { tFilter.write(data); @@ -110,7 +110,7 @@ public class PacketNewFilter implements IMekanismPacket { mFilter.write(data); } - + PacketHandler.encode(data.toArray(), dataStream); } } diff --git a/common/mekanism/common/network/PacketPortableTeleport.java b/common/mekanism/common/network/PacketPortableTeleport.java index db5624731..12533446e 100644 --- a/common/mekanism/common/network/PacketPortableTeleport.java +++ b/common/mekanism/common/network/PacketPortableTeleport.java @@ -25,7 +25,7 @@ public class PacketPortableTeleport implements IMekanismPacket { return "PortableTeleport"; } - + @Override public IMekanismPacket setParams(Object... data) { @@ -33,35 +33,35 @@ public class PacketPortableTeleport implements IMekanismPacket } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { ItemStack itemstack = player.getCurrentEquippedItem(); - + if(itemstack != null && itemstack.getItem() instanceof ItemPortableTeleporter) { ItemPortableTeleporter item = (ItemPortableTeleporter)itemstack.getItem(); - + if(item.getStatus(itemstack) == 1) { Coord4D coords = MekanismUtils.getClosestCoords(new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3)), player); - + World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coords.dimensionId); TileEntityTeleporter teleporter = (TileEntityTeleporter)coords.getTileEntity(teleWorld); - + if(teleporter != null) { teleporter.didTeleport.add(player); teleporter.teleDelay = 5; - + item.setEnergy(itemstack, item.getEnergy(itemstack) - item.calculateEnergyCost(player, coords)); - + if(world.provider.dimensionId != coords.dimensionId) { ((EntityPlayerMP)player).travelToDimension(coords.dimensionId); } - + ((EntityPlayerMP)player).playerNetServerHandler.setPlayerLocation(coords.xCoord+0.5, coords.yCoord+1, coords.zCoord+0.5, player.rotationYaw, player.rotationPitch); - + world.playSoundAtEntity(player, "mob.endermen.portal", 1.0F, 1.0F); PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketPortalFX().setParams(coords), coords, 40D); } diff --git a/common/mekanism/common/network/PacketPortalFX.java b/common/mekanism/common/network/PacketPortalFX.java index 52d1bfed4..966f263ce 100644 --- a/common/mekanism/common/network/PacketPortalFX.java +++ b/common/mekanism/common/network/PacketPortalFX.java @@ -12,18 +12,18 @@ import com.google.common.io.ByteArrayDataInput; public class PacketPortalFX implements IMekanismPacket { public Coord4D object3D; - + @Override - public String getName() + public String getName() { return "PortalFX"; } - + @Override public IMekanismPacket setParams(Object... data) { object3D = (Coord4D)data[0]; - + return this; } @@ -31,11 +31,11 @@ public class PacketPortalFX implements IMekanismPacket public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { Random random = new Random(); - + int x = dataStream.readInt(); int y = dataStream.readInt(); int z = dataStream.readInt(); - + for(int i = 0; i < 50; i++) { world.spawnParticle("portal", x + random.nextFloat(), y + random.nextFloat(), z + random.nextFloat(), 0.0F, 0.0F, 0.0F); diff --git a/common/mekanism/common/network/PacketRedstoneControl.java b/common/mekanism/common/network/PacketRedstoneControl.java index 17b35cbb3..93bd80d60 100644 --- a/common/mekanism/common/network/PacketRedstoneControl.java +++ b/common/mekanism/common/network/PacketRedstoneControl.java @@ -15,19 +15,19 @@ public class PacketRedstoneControl implements IMekanismPacket { public Coord4D coord; public RedstoneControl value; - + @Override - public String getName() + public String getName() { return "RedstoneControl"; } - + @Override public IMekanismPacket setParams(Object... data) { coord = (Coord4D)data[0]; value = (RedstoneControl)data[1]; - + return this; } @@ -36,9 +36,9 @@ public class PacketRedstoneControl implements IMekanismPacket { Coord4D obj = Coord4D.read(dataStream); RedstoneControl control = RedstoneControl.values()[dataStream.readInt()]; - + TileEntity tileEntity = obj.getTileEntity(world); - + if(tileEntity instanceof IRedstoneControl) { ((IRedstoneControl)tileEntity).setControlType(control); @@ -52,7 +52,7 @@ public class PacketRedstoneControl implements IMekanismPacket dataStream.writeInt(coord.yCoord); dataStream.writeInt(coord.zCoord); dataStream.writeInt(coord.dimensionId); - + dataStream.writeInt(value.ordinal()); } } diff --git a/common/mekanism/common/network/PacketRemoveUpgrade.java b/common/mekanism/common/network/PacketRemoveUpgrade.java index 64389a065..8eb0f3838 100644 --- a/common/mekanism/common/network/PacketRemoveUpgrade.java +++ b/common/mekanism/common/network/PacketRemoveUpgrade.java @@ -16,21 +16,21 @@ import com.google.common.io.ByteArrayDataInput; public class PacketRemoveUpgrade implements IMekanismPacket { public Coord4D object3D; - + public byte upgradeType; - + @Override - public String getName() + public String getName() { return "RemoveUpgrade"; } - + @Override public IMekanismPacket setParams(Object... data) { object3D = (Coord4D)data[0]; upgradeType = (Byte)data[1]; - + return this; } @@ -40,15 +40,15 @@ public class PacketRemoveUpgrade implements IMekanismPacket int x = dataStream.readInt(); int y = dataStream.readInt(); int z = dataStream.readInt(); - + byte type = dataStream.readByte(); - + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof IUpgradeManagement && tileEntity instanceof TileEntityBasicBlock) { IUpgradeManagement upgradeTile = (IUpgradeManagement)tileEntity; - + if(type == 0) { if(upgradeTile.getSpeedMultiplier() > 0) @@ -78,7 +78,7 @@ public class PacketRemoveUpgrade implements IMekanismPacket dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + dataStream.writeByte(upgradeType); } } diff --git a/common/mekanism/common/network/PacketRobit.java b/common/mekanism/common/network/PacketRobit.java index 9084f6b79..8ea7e8104 100644 --- a/common/mekanism/common/network/PacketRobit.java +++ b/common/mekanism/common/network/PacketRobit.java @@ -12,23 +12,23 @@ import com.google.common.io.ByteArrayDataInput; public class PacketRobit implements IMekanismPacket { public RobitPacketType activeType; - + public int guiType; public int entityId; - + public String name; - + @Override - public String getName() + public String getName() { return "Robit"; } - + @Override public IMekanismPacket setParams(Object... data) { activeType = (RobitPacketType)data[0]; - + switch(activeType) { case GUI: @@ -49,93 +49,93 @@ public class PacketRobit implements IMekanismPacket entityId = (Integer)data[1]; break; } - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { int subType = dataStream.readInt(); - + if(subType == 0) { int type = dataStream.readInt(); int id = dataStream.readInt(); - - if(type == 0) - { - player.openGui(Mekanism.instance, 21, world, id, 0, 0); - } - else if(type == 1) - { - player.openGui(Mekanism.instance, 22, world, id, 0, 0); - } - else if(type == 2) - { - player.openGui(Mekanism.instance, 23, world, id, 0, 0); - } - else if(type == 3) - { - player.openGui(Mekanism.instance, 24, world, id, 0, 0); - } - else if(type == 4) - { - player.openGui(Mekanism.instance, 25, world, id, 0, 0); - } + + if(type == 0) + { + player.openGui(Mekanism.instance, 21, world, id, 0, 0); + } + else if(type == 1) + { + player.openGui(Mekanism.instance, 22, world, id, 0, 0); + } + else if(type == 2) + { + player.openGui(Mekanism.instance, 23, world, id, 0, 0); + } + else if(type == 3) + { + player.openGui(Mekanism.instance, 24, world, id, 0, 0); + } + else if(type == 4) + { + player.openGui(Mekanism.instance, 25, world, id, 0, 0); + } } else if(subType == 1) { int id = dataStream.readInt(); - - EntityRobit robit = (EntityRobit)world.getEntityByID(id); - - if(robit != null) - { - robit.setFollowing(!robit.getFollowing()); - } + + EntityRobit robit = (EntityRobit)world.getEntityByID(id); + + if(robit != null) + { + robit.setFollowing(!robit.getFollowing()); + } } else if(subType == 2) { - String name = dataStream.readUTF(); - int id = dataStream.readInt(); - - EntityRobit robit = (EntityRobit)world.getEntityByID(id); - - if(robit != null) - { - robit.setName(name); - } + String name = dataStream.readUTF(); + int id = dataStream.readInt(); + + EntityRobit robit = (EntityRobit)world.getEntityByID(id); + + if(robit != null) + { + robit.setName(name); + } } else if(subType == 3) { - int id = dataStream.readInt(); - - EntityRobit robit = (EntityRobit)world.getEntityByID(id); - - if(robit != null) - { - robit.goHome(); - } + int id = dataStream.readInt(); + + EntityRobit robit = (EntityRobit)world.getEntityByID(id); + + if(robit != null) + { + robit.goHome(); + } } else if(subType == 4) { - int id = dataStream.readInt(); - - EntityRobit robit = (EntityRobit)world.getEntityByID(id); - - if(robit != null) - { - robit.setDropPickup(!robit.getDropPickup()); - } + int id = dataStream.readInt(); + + EntityRobit robit = (EntityRobit)world.getEntityByID(id); + + if(robit != null) + { + robit.setDropPickup(!robit.getDropPickup()); + } } } @Override - public void write(DataOutputStream dataStream) throws Exception + public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(activeType.ordinal()); - + switch(activeType) { case GUI: @@ -157,7 +157,7 @@ public class PacketRobit implements IMekanismPacket break; } } - + public static enum RobitPacketType { GUI, diff --git a/common/mekanism/common/network/PacketScubaTankData.java b/common/mekanism/common/network/PacketScubaTankData.java index 78df284e2..393d8794b 100644 --- a/common/mekanism/common/network/PacketScubaTankData.java +++ b/common/mekanism/common/network/PacketScubaTankData.java @@ -15,27 +15,27 @@ import com.google.common.io.ByteArrayDataInput; public class PacketScubaTankData implements IMekanismPacket { public ScubaTankPacket packetType; - + public String username; public boolean value; - + @Override - public String getName() + public String getName() { return "ScubaTankData"; } - + @Override public IMekanismPacket setParams(Object... data) { packetType = (ScubaTankPacket)data[0]; - + if(packetType == ScubaTankPacket.UPDATE) { username = (String)data[1]; value = (Boolean)data[2]; } - + return this; } @@ -43,9 +43,9 @@ public class PacketScubaTankData implements IMekanismPacket public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { packetType = ScubaTankPacket.values()[dataStream.readInt()]; - - if(packetType == ScubaTankPacket.FULL) - { + + if(packetType == ScubaTankPacket.FULL) + { Mekanism.gasmaskOn.clear(); int amount = dataStream.readInt(); @@ -54,12 +54,12 @@ public class PacketScubaTankData implements IMekanismPacket { Mekanism.gasmaskOn.add(dataStream.readUTF()); } - } - else if(packetType == ScubaTankPacket.UPDATE) + } + else if(packetType == ScubaTankPacket.UPDATE) { String username = dataStream.readUTF(); boolean value = dataStream.readBoolean(); - + if(value) { Mekanism.gasmaskOn.add(username); @@ -67,7 +67,7 @@ public class PacketScubaTankData implements IMekanismPacket else { Mekanism.gasmaskOn.remove(username); } - + if(!world.isRemote) { PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketScubaTankData().setParams(ScubaTankPacket.UPDATE, username, value), world.provider.dimensionId); @@ -76,7 +76,7 @@ public class PacketScubaTankData implements IMekanismPacket else if(packetType == ScubaTankPacket.MODE) { ItemStack stack = player.getCurrentItemOrArmor(3); - + if(stack != null && stack.getItem() instanceof ItemScubaTank) { ((ItemScubaTank)stack.getItem()).toggleFlowing(stack); @@ -88,7 +88,7 @@ public class PacketScubaTankData implements IMekanismPacket public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(packetType.ordinal()); - + if(packetType == ScubaTankPacket.UPDATE) { dataStream.writeUTF(username); @@ -104,7 +104,7 @@ public class PacketScubaTankData implements IMekanismPacket } } } - + public static enum ScubaTankPacket { UPDATE, diff --git a/common/mekanism/common/network/PacketSimpleGui.java b/common/mekanism/common/network/PacketSimpleGui.java index 9d6167de7..76616fdbb 100644 --- a/common/mekanism/common/network/PacketSimpleGui.java +++ b/common/mekanism/common/network/PacketSimpleGui.java @@ -21,42 +21,42 @@ import cpw.mods.fml.relauncher.SideOnly; public class PacketSimpleGui implements IMekanismPacket { public Coord4D object3D; - + public int guiId; - + @Override public String getName() { return "SimpleGui"; } - + @Override public IMekanismPacket setParams(Object... data) { object3D = (Coord4D)data[0]; guiId = (Integer)data[1]; - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { object3D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - + guiId = dataStream.readInt(); - + if(!world.isRemote) { World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(object3D.dimensionId); - + if(worldServer != null && object3D.getTileEntity(worldServer) instanceof TileEntityBasicBlock) { if(guiId == -1) { return; } - + openServerGui(guiId, (EntityPlayerMP)player, world, object3D); } } @@ -64,21 +64,21 @@ public class PacketSimpleGui implements IMekanismPacket FMLCommonHandler.instance().showGuiScreen(getGui(guiId, player, world, object3D)); } } - + public static void openServerGui(int id, EntityPlayerMP playerMP, World world, Coord4D obj) { playerMP.closeContainer(); - playerMP.incrementWindowID(); - - int window = playerMP.currentWindowId; - - PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketSimpleGui().setParams(obj, id), playerMP); - - playerMP.openContainer = Mekanism.proxy.getServerGui(id, playerMP, world, obj.xCoord, obj.yCoord, obj.zCoord); - playerMP.openContainer.windowId = window; - playerMP.openContainer.addCraftingToCrafters(playerMP); + playerMP.incrementWindowID(); + + int window = playerMP.currentWindowId; + + PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketSimpleGui().setParams(obj, id), playerMP); + + playerMP.openContainer = Mekanism.proxy.getServerGui(id, playerMP, world, obj.xCoord, obj.yCoord, obj.zCoord); + playerMP.openContainer.windowId = window; + playerMP.openContainer.addCraftingToCrafters(playerMP); } - + @SideOnly(Side.CLIENT) public GuiScreen getGui(int id, EntityPlayer player, World world, Coord4D obj) { @@ -91,9 +91,9 @@ public class PacketSimpleGui implements IMekanismPacket dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + dataStream.writeInt(object3D.dimensionId); - + dataStream.writeInt(guiId); } } diff --git a/common/mekanism/common/network/PacketStatusUpdate.java b/common/mekanism/common/network/PacketStatusUpdate.java index 4b6a1a36f..3cb4ce296 100644 --- a/common/mekanism/common/network/PacketStatusUpdate.java +++ b/common/mekanism/common/network/PacketStatusUpdate.java @@ -12,26 +12,26 @@ import com.google.common.io.ByteArrayDataInput; public class PacketStatusUpdate implements IMekanismPacket { public int status; - + @Override - public String getName() + public String getName() { return "StatusUpdate"; } - + @Override public IMekanismPacket setParams(Object... data) { status = (Integer)data[0]; - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { ItemStack currentStack = player.getCurrentEquippedItem(); - + if(currentStack != null && currentStack.getItem() instanceof ItemPortableTeleporter) { ItemPortableTeleporter item = (ItemPortableTeleporter)currentStack.getItem(); @@ -40,7 +40,7 @@ public class PacketStatusUpdate implements IMekanismPacket } @Override - public void write(DataOutputStream dataStream) throws Exception + public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(status); } diff --git a/common/mekanism/common/network/PacketTileEntity.java b/common/mekanism/common/network/PacketTileEntity.java index a46282a1c..7366e65c8 100644 --- a/common/mekanism/common/network/PacketTileEntity.java +++ b/common/mekanism/common/network/PacketTileEntity.java @@ -15,21 +15,21 @@ import com.google.common.io.ByteArrayDataInput; public class PacketTileEntity implements IMekanismPacket { public Coord4D object3D; - + public ArrayList parameters; - + @Override - public String getName() + public String getName() { return "TileEntity"; } - + @Override public IMekanismPacket setParams(Object... data) { object3D = (Coord4D)data[0]; parameters = (ArrayList)data[1]; - + return this; } @@ -39,9 +39,9 @@ public class PacketTileEntity implements IMekanismPacket int x = dataStream.readInt(); int y = dataStream.readInt(); int z = dataStream.readInt(); - + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof ITileNetwork) { ((ITileNetwork)tileEntity).handlePacketData(dataStream); @@ -54,7 +54,7 @@ public class PacketTileEntity implements IMekanismPacket dataStream.writeInt(object3D.xCoord); dataStream.writeInt(object3D.yCoord); dataStream.writeInt(object3D.zCoord); - + PacketHandler.encode(new Object[] {parameters}, dataStream); } } diff --git a/common/mekanism/common/network/PacketTransmitterUpdate.java b/common/mekanism/common/network/PacketTransmitterUpdate.java index 427ab390d..62d60cb0b 100644 --- a/common/mekanism/common/network/PacketTransmitterUpdate.java +++ b/common/mekanism/common/network/PacketTransmitterUpdate.java @@ -21,29 +21,29 @@ import com.google.common.io.ByteArrayDataInput; public class PacketTransmitterUpdate implements IMekanismPacket { public PacketType packetType; - + public TileEntity tileEntity; - + public double power; - + public GasStack gasStack; public boolean didGasTransfer; - + public FluidStack fluidStack; public boolean didFluidTransfer; - + @Override - public String getName() + public String getName() { return "TransmitterUpdate"; } - + @Override public IMekanismPacket setParams(Object... data) { packetType = (PacketType)data[0]; tileEntity = (TileEntity)data[1]; - + switch(packetType) { case ENERGY: @@ -58,7 +58,7 @@ public class PacketTransmitterUpdate implements IMekanismPacket didFluidTransfer = (Boolean)data[3]; break; } - + return this; } @@ -66,15 +66,15 @@ public class PacketTransmitterUpdate implements IMekanismPacket public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { int transmitterType = dataStream.readInt(); - + int x = dataStream.readInt(); int y = dataStream.readInt(); int z = dataStream.readInt(); - + if(transmitterType == 0) { IGridTransmitter transmitter = (IGridTransmitter)world.getBlockTileEntity(x, y, z); - + if(transmitter != null) { transmitter.refreshTransmitterNetwork(); @@ -83,81 +83,81 @@ public class PacketTransmitterUpdate implements IMekanismPacket if(transmitterType == 1) { double powerLevel = dataStream.readDouble(); - + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity != null) { ((IGridTransmitter)tileEntity).getTransmitterNetwork().clientEnergyScale = powerLevel; } } else if(transmitterType == 2) - { - TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - - Gas gasType = GasRegistry.getGas(dataStream.readInt()); - int amount = dataStream.readInt(); - GasStack stack = null; - didGasTransfer = dataStream.readBoolean(); - - if(gasType != null) - { - stack = new GasStack(gasType, amount); - } - - if(tileEntity != null) - { - GasNetwork net = ((IGridTransmitter)tileEntity).getTransmitterNetwork(); - - if(gasType != null) - { - net.refGas = gasType; - } - - net.gasStored = stack; - net.didTransfer = didGasTransfer; - } - } - else if(transmitterType == 3) - { - TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - - int type = dataStream.readInt(); - Fluid fluidType = type != -1 ? FluidRegistry.getFluid(type) : null; - int amount = dataStream.readInt(); - FluidStack stack = null; - didFluidTransfer = dataStream.readBoolean(); - - if(fluidType != null) - { - stack = new FluidStack(fluidType, amount); - } - - if(tileEntity != null) - { - FluidNetwork net = ((IGridTransmitter)tileEntity).getTransmitterNetwork(); - - if(fluidType != null) - { - net.refFluid = fluidType; - } - - net.fluidStored = stack; - net.didTransfer = didFluidTransfer; - net.fluidScale = net.getScale(); - } - } + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + Gas gasType = GasRegistry.getGas(dataStream.readInt()); + int amount = dataStream.readInt(); + GasStack stack = null; + didGasTransfer = dataStream.readBoolean(); + + if(gasType != null) + { + stack = new GasStack(gasType, amount); + } + + if(tileEntity != null) + { + GasNetwork net = ((IGridTransmitter)tileEntity).getTransmitterNetwork(); + + if(gasType != null) + { + net.refGas = gasType; + } + + net.gasStored = stack; + net.didTransfer = didGasTransfer; + } + } + else if(transmitterType == 3) + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + int type = dataStream.readInt(); + Fluid fluidType = type != -1 ? FluidRegistry.getFluid(type) : null; + int amount = dataStream.readInt(); + FluidStack stack = null; + didFluidTransfer = dataStream.readBoolean(); + + if(fluidType != null) + { + stack = new FluidStack(fluidType, amount); + } + + if(tileEntity != null) + { + FluidNetwork net = ((IGridTransmitter)tileEntity).getTransmitterNetwork(); + + if(fluidType != null) + { + net.refFluid = fluidType; + } + + net.fluidStored = stack; + net.didTransfer = didFluidTransfer; + net.fluidScale = net.getScale(); + } + } } @Override - public void write(DataOutputStream dataStream) throws Exception + public void write(DataOutputStream dataStream) throws Exception { dataStream.writeInt(packetType.ordinal()); - + dataStream.writeInt(tileEntity.xCoord); dataStream.writeInt(tileEntity.yCoord); dataStream.writeInt(tileEntity.zCoord); - + switch(packetType) { case ENERGY: @@ -175,7 +175,7 @@ public class PacketTransmitterUpdate implements IMekanismPacket break; } } - + public static enum PacketType { UPDATE, diff --git a/common/mekanism/common/network/PacketWalkieTalkieState.java b/common/mekanism/common/network/PacketWalkieTalkieState.java index 2f6a82547..225d73c76 100644 --- a/common/mekanism/common/network/PacketWalkieTalkieState.java +++ b/common/mekanism/common/network/PacketWalkieTalkieState.java @@ -12,28 +12,28 @@ import com.google.common.io.ByteArrayDataInput; public class PacketWalkieTalkieState implements IMekanismPacket { public int channel; - + @Override - public String getName() + public String getName() { return "WalkieTalkieState"; } - + @Override public IMekanismPacket setParams(Object... data) { channel = (Integer)data[0]; - + return this; } @Override - public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception + public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception { - int chan = dataStream.readInt(); - + int chan = dataStream.readInt(); + ItemStack itemstack = player.getCurrentEquippedItem(); - + if(itemstack != null && itemstack.getItem() instanceof ItemWalkieTalkie) { ((ItemWalkieTalkie)itemstack.getItem()).setChannel(itemstack, chan); diff --git a/common/mekanism/common/recipe/BinRecipe.java b/common/mekanism/common/recipe/BinRecipe.java index db9891e42..717cdf2b4 100644 --- a/common/mekanism/common/recipe/BinRecipe.java +++ b/common/mekanism/common/recipe/BinRecipe.java @@ -19,20 +19,20 @@ public class BinRecipe implements IRecipe, ICraftingHandler { GameRegistry.registerCraftingHandler(this); } - + @Override - public boolean matches(InventoryCrafting inv, World world) + public boolean matches(InventoryCrafting inv, World world) { return getCraftingResult(inv) != null; } - + private boolean isBin(ItemStack itemStack) { if(itemStack == null) { return false; } - + return itemStack.getItem() instanceof ItemBlockBasic && itemStack.getItemDamage() == 6; } @@ -41,59 +41,59 @@ public class BinRecipe implements IRecipe, ICraftingHandler { return getResult(inv); } - + public ItemStack getResult(IInventory inv) { ItemStack bin = null; - + for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - + if(isBin(stack)) { if(bin != null) { return null; } - + bin = stack.copy(); } } - + if(bin == null) { return null; } - + ItemStack addStack = null; - + for(int i = 0; i < 9; i++) { ItemStack stack = inv.getStackInSlot(i); - + if(stack != null && !isBin(stack)) { if(addStack != null) { return null; } - + addStack = stack.copy(); } } - + InventoryBin binInv = new InventoryBin(bin); - + if(addStack != null) { if(binInv.getItemType() != null && !binInv.getItemType().isItemEqual(addStack)) { return null; } - + binInv.add(addStack); - + return bin; } else { @@ -102,19 +102,19 @@ public class BinRecipe implements IRecipe, ICraftingHandler } @Override - public int getRecipeSize() + public int getRecipeSize() { return 0; } @Override - public ItemStack getRecipeOutput() + public ItemStack getRecipeOutput() { return null; } @Override - public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) + public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { if(getResult(craftMatrix) != null) { @@ -126,11 +126,11 @@ public class BinRecipe implements IRecipe, ICraftingHandler { ItemStack bin = craftMatrix.getStackInSlot(i); InventoryBin inv = new InventoryBin(bin.copy()); - + int size = inv.getItemCount(); - + ItemStack testRemove = inv.removeStack(); - + bin.stackTagCompound.setInteger("newCount", size-(testRemove != null ? testRemove.stackSize : 0)); } } @@ -138,7 +138,7 @@ public class BinRecipe implements IRecipe, ICraftingHandler else { int bin = -1; int other = -1; - + for(int i = 0; i < craftMatrix.getSizeInventory(); i++) { if(isBin(craftMatrix.getStackInSlot(i))) @@ -150,12 +150,12 @@ public class BinRecipe implements IRecipe, ICraftingHandler other = i; } } - + ItemStack binStack = craftMatrix.getStackInSlot(bin); ItemStack otherStack = craftMatrix.getStackInSlot(other); - + ItemStack testRemain = new InventoryBin(binStack.copy()).add(otherStack.copy()); - + if(testRemain != null && testRemain.stackSize > 0) { ItemStack proxy = new ItemStack(Mekanism.ItemProxy); @@ -165,7 +165,7 @@ public class BinRecipe implements IRecipe, ICraftingHandler else { craftMatrix.setInventorySlotContents(other, null); } - + craftMatrix.setInventorySlotContents(bin, null); } } diff --git a/common/mekanism/common/recipe/MekanismRecipe.java b/common/mekanism/common/recipe/MekanismRecipe.java index 2439eca9d..8f9638aba 100644 --- a/common/mekanism/common/recipe/MekanismRecipe.java +++ b/common/mekanism/common/recipe/MekanismRecipe.java @@ -23,324 +23,324 @@ import net.minecraftforge.oredict.OreDictionary; */ public class MekanismRecipe implements IRecipe { - private static final int MAX_CRAFT_GRID_WIDTH = 3; - private static final int MAX_CRAFT_GRID_HEIGHT = 3; + private static final int MAX_CRAFT_GRID_WIDTH = 3; + private static final int MAX_CRAFT_GRID_HEIGHT = 3; - private ItemStack output = null; - private Object[] input = null; - - public int width = 0; - public int height = 0; - - private boolean mirrored = true; - - public MekanismRecipe(ItemStack result, Object... recipe) - { - output = result.copy(); + private ItemStack output = null; + private Object[] input = null; - String shape = ""; - int idx = 0; + public int width = 0; + public int height = 0; - if(recipe[idx] instanceof Boolean) - { - mirrored = (Boolean)recipe[idx]; - - if(recipe[idx+1] instanceof Object[]) - { - recipe = (Object[])recipe[idx+1]; - } - else { - idx = 1; - } - } + private boolean mirrored = true; - if(recipe[idx] instanceof String[]) - { - String[] parts = ((String[])recipe[idx++]); + public MekanismRecipe(ItemStack result, Object... recipe) + { + output = result.copy(); - for(String s : parts) - { - width = s.length(); - shape += s; - } + String shape = ""; + int idx = 0; - height = parts.length; - } - else { - while(recipe[idx] instanceof String) - { - String s = (String)recipe[idx++]; - shape += s; - width = s.length(); - height++; - } - } + if(recipe[idx] instanceof Boolean) + { + mirrored = (Boolean)recipe[idx]; - if(width * height != shape.length()) - { - String ret = "Invalid shaped ore recipe: "; - - for(Object tmp : recipe) - { - ret += tmp + ", "; - } - - ret += output; - - throw new RuntimeException(ret); - } + if(recipe[idx+1] instanceof Object[]) + { + recipe = (Object[])recipe[idx+1]; + } + else { + idx = 1; + } + } - HashMap itemMap = new HashMap(); + if(recipe[idx] instanceof String[]) + { + String[] parts = ((String[])recipe[idx++]); - for(; idx < recipe.length; idx += 2) - { - Character chr = (Character)recipe[idx]; - Object in = recipe[idx + 1]; + for(String s : parts) + { + width = s.length(); + shape += s; + } - if(in instanceof ItemStack) - { - itemMap.put(chr, ((ItemStack)in).copy()); - } - else if(in instanceof Item) - { - itemMap.put(chr, new ItemStack((Item)in)); - } - else if(in instanceof Block) - { - itemMap.put(chr, new ItemStack((Block)in, 1, OreDictionary.WILDCARD_VALUE)); - } - else if(in instanceof String) - { - itemMap.put(chr, OreDictionary.getOres((String)in)); - } - else { - String ret = "Invalid shaped ore recipe: "; - - for(Object tmp : recipe) - { - ret += tmp + ", "; - } - - ret += output; - throw new RuntimeException(ret); - } - } + height = parts.length; + } + else { + while(recipe[idx] instanceof String) + { + String s = (String)recipe[idx++]; + shape += s; + width = s.length(); + height++; + } + } - input = new Object[width * height]; - int x = 0; - - for(char chr : shape.toCharArray()) - { - input[x++] = itemMap.get(chr); - } - } + if(width * height != shape.length()) + { + String ret = "Invalid shaped ore recipe: "; - @Override - public ItemStack getCraftingResult(InventoryCrafting inv) - { - ItemStack toReturn = output.copy(); - - if(toReturn.getItem() instanceof IEnergizedItem) - { - double energyFound = 0; - - for(int i = 0; i < 9; i++) - { - ItemStack itemstack = inv.getStackInSlot(i); - - if(itemstack != null) - { - if(itemstack.getItem() instanceof IEnergizedItem) - { - energyFound += ((IEnergizedItem)itemstack.getItem()).getEnergy(itemstack); - } - } - } - - ((IEnergizedItem)toReturn.getItem()).setEnergy(toReturn, Math.min(((IEnergizedItem)toReturn.getItem()).getMaxEnergy(toReturn), energyFound)); - } - - if(toReturn.getItem() instanceof IUpgradeManagement && ((IUpgradeManagement)toReturn.getItem()).supportsUpgrades(toReturn)) - { - int speedUpgrades = 0; - int energyUpgrades = 0; - - for(int i = 0; i < 9; i++) - { - ItemStack itemstack = inv.getStackInSlot(i); - - if(itemstack != null) - { - if(itemstack.getItem() instanceof IUpgradeManagement && ((IUpgradeManagement)itemstack.getItem()).supportsUpgrades(toReturn)) - { - speedUpgrades = Math.min(8, speedUpgrades + ((IUpgradeManagement)itemstack.getItem()).getSpeedMultiplier(itemstack)); - energyUpgrades = Math.min(8, energyUpgrades + ((IUpgradeManagement)itemstack.getItem()).getEnergyMultiplier(itemstack)); - } - } - } - - ((IUpgradeManagement)toReturn.getItem()).setSpeedMultiplier(speedUpgrades, toReturn); - ((IUpgradeManagement)toReturn.getItem()).setEnergyMultiplier(energyUpgrades, toReturn); - } - - return toReturn; - } + for(Object tmp : recipe) + { + ret += tmp + ", "; + } - @Override - public int getRecipeSize() - { - return input.length; - } + ret += output; - @Override - public ItemStack getRecipeOutput() - { - return output; - } + throw new RuntimeException(ret); + } - @Override - public boolean matches(InventoryCrafting inv, World world) - { - for(int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) - { - for(int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) - { - if(checkMatch(inv, x, y, true)) - { - return true; - } + HashMap itemMap = new HashMap(); - if(mirrored && checkMatch(inv, x, y, false)) - { - return true; - } - } - } + for(; idx < recipe.length; idx += 2) + { + Character chr = (Character)recipe[idx]; + Object in = recipe[idx + 1]; - return false; - } + if(in instanceof ItemStack) + { + itemMap.put(chr, ((ItemStack)in).copy()); + } + else if(in instanceof Item) + { + itemMap.put(chr, new ItemStack((Item)in)); + } + else if(in instanceof Block) + { + itemMap.put(chr, new ItemStack((Block)in, 1, OreDictionary.WILDCARD_VALUE)); + } + else if(in instanceof String) + { + itemMap.put(chr, OreDictionary.getOres((String)in)); + } + else { + String ret = "Invalid shaped ore recipe: "; - private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) - { - for(int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) - { - for(int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) - { - int subX = x - startX; - int subY = y - startY; - Object target = null; + for(Object tmp : recipe) + { + ret += tmp + ", "; + } - if(subX >= 0 && subY >= 0 && subX < width && subY < height) - { - if(mirror) - { - target = input[width - subX - 1 + subY * width]; - } - else { - target = input[subX + subY * width]; - } - } + ret += output; + throw new RuntimeException(ret); + } + } - ItemStack slot = inv.getStackInRowAndColumn(x, y); + input = new Object[width * height]; + int x = 0; - if(target instanceof ItemStack) - { - if(!checkItemEquals((ItemStack)target, slot)) - { - return false; - } - } - else if(target instanceof ArrayList) - { - boolean matched = false; + for(char chr : shape.toCharArray()) + { + input[x++] = itemMap.get(chr); + } + } - for(ItemStack item : (ArrayList)target) - { - matched = matched || checkItemEquals(item, slot); - } + @Override + public ItemStack getCraftingResult(InventoryCrafting inv) + { + ItemStack toReturn = output.copy(); - if(!matched) - { - return false; - } - } - else if(target == null && slot != null) - { - return false; - } - } - } + if(toReturn.getItem() instanceof IEnergizedItem) + { + double energyFound = 0; - return true; - } + for(int i = 0; i < 9; i++) + { + ItemStack itemstack = inv.getStackInSlot(i); - private boolean checkItemEquals(ItemStack target, ItemStack input) - { - if(input == null && target != null || input != null && target == null) - { - return false; - } - else if(input == null && target == null) - { - return true; - } - - if(target.itemID != input.itemID) - { - return false; - } - - if(!(target.getItem() instanceof IEnergizedItem) && !(input.getItem() instanceof IEnergizedItem)) - { - if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE) - { - return false; - } - } - else { - if(((IEnergizedItem)target.getItem()).isMetadataSpecific() && ((IEnergizedItem)input.getItem()).isMetadataSpecific()) - { - if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE) - { - return false; - } - } - - if(target.getItem() instanceof IEnergyCube && input.getItem() instanceof IEnergyCube) - { - if(((IEnergyCube)target.getItem()).getEnergyCubeTier(target) != ((IEnergyCube)input.getItem()).getEnergyCubeTier(input)) - { - return false; - } - } - else if(target.getItem() instanceof IFactory && input.getItem() instanceof IFactory) - { - if(isFactory(target) && isFactory(input)) - { - if(((IFactory)target.getItem()).getRecipeType(target) != ((IFactory)input.getItem()).getRecipeType(input)) - { - return false; - } - } - } - } - - return true; - } - - private static boolean isFactory(ItemStack stack) - { - return MachineType.get(stack) == MachineType.BASIC_FACTORY || MachineType.get(stack) == MachineType.ADVANCED_FACTORY || MachineType.get(stack) == MachineType.ELITE_FACTORY; - } + if(itemstack != null) + { + if(itemstack.getItem() instanceof IEnergizedItem) + { + energyFound += ((IEnergizedItem)itemstack.getItem()).getEnergy(itemstack); + } + } + } - public MekanismRecipe setMirrored(boolean mirror) - { - mirrored = mirror; - return this; - } + ((IEnergizedItem)toReturn.getItem()).setEnergy(toReturn, Math.min(((IEnergizedItem)toReturn.getItem()).getMaxEnergy(toReturn), energyFound)); + } - public Object[] getInput() - { - return input; - } + if(toReturn.getItem() instanceof IUpgradeManagement && ((IUpgradeManagement)toReturn.getItem()).supportsUpgrades(toReturn)) + { + int speedUpgrades = 0; + int energyUpgrades = 0; + + for(int i = 0; i < 9; i++) + { + ItemStack itemstack = inv.getStackInSlot(i); + + if(itemstack != null) + { + if(itemstack.getItem() instanceof IUpgradeManagement && ((IUpgradeManagement)itemstack.getItem()).supportsUpgrades(toReturn)) + { + speedUpgrades = Math.min(8, speedUpgrades + ((IUpgradeManagement)itemstack.getItem()).getSpeedMultiplier(itemstack)); + energyUpgrades = Math.min(8, energyUpgrades + ((IUpgradeManagement)itemstack.getItem()).getEnergyMultiplier(itemstack)); + } + } + } + + ((IUpgradeManagement)toReturn.getItem()).setSpeedMultiplier(speedUpgrades, toReturn); + ((IUpgradeManagement)toReturn.getItem()).setEnergyMultiplier(energyUpgrades, toReturn); + } + + return toReturn; + } + + @Override + public int getRecipeSize() + { + return input.length; + } + + @Override + public ItemStack getRecipeOutput() + { + return output; + } + + @Override + public boolean matches(InventoryCrafting inv, World world) + { + for(int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) + { + for(int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) + { + if(checkMatch(inv, x, y, true)) + { + return true; + } + + if(mirrored && checkMatch(inv, x, y, false)) + { + return true; + } + } + } + + return false; + } + + private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) + { + for(int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) + { + for(int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) + { + int subX = x - startX; + int subY = y - startY; + Object target = null; + + if(subX >= 0 && subY >= 0 && subX < width && subY < height) + { + if(mirror) + { + target = input[width - subX - 1 + subY * width]; + } + else { + target = input[subX + subY * width]; + } + } + + ItemStack slot = inv.getStackInRowAndColumn(x, y); + + if(target instanceof ItemStack) + { + if(!checkItemEquals((ItemStack)target, slot)) + { + return false; + } + } + else if(target instanceof ArrayList) + { + boolean matched = false; + + for(ItemStack item : (ArrayList)target) + { + matched = matched || checkItemEquals(item, slot); + } + + if(!matched) + { + return false; + } + } + else if(target == null && slot != null) + { + return false; + } + } + } + + return true; + } + + private boolean checkItemEquals(ItemStack target, ItemStack input) + { + if(input == null && target != null || input != null && target == null) + { + return false; + } + else if(input == null && target == null) + { + return true; + } + + if(target.itemID != input.itemID) + { + return false; + } + + if(!(target.getItem() instanceof IEnergizedItem) && !(input.getItem() instanceof IEnergizedItem)) + { + if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE) + { + return false; + } + } + else { + if(((IEnergizedItem)target.getItem()).isMetadataSpecific() && ((IEnergizedItem)input.getItem()).isMetadataSpecific()) + { + if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE) + { + return false; + } + } + + if(target.getItem() instanceof IEnergyCube && input.getItem() instanceof IEnergyCube) + { + if(((IEnergyCube)target.getItem()).getEnergyCubeTier(target) != ((IEnergyCube)input.getItem()).getEnergyCubeTier(input)) + { + return false; + } + } + else if(target.getItem() instanceof IFactory && input.getItem() instanceof IFactory) + { + if(isFactory(target) && isFactory(input)) + { + if(((IFactory)target.getItem()).getRecipeType(target) != ((IFactory)input.getItem()).getRecipeType(input)) + { + return false; + } + } + } + } + + return true; + } + + private static boolean isFactory(ItemStack stack) + { + return MachineType.get(stack) == MachineType.BASIC_FACTORY || MachineType.get(stack) == MachineType.ADVANCED_FACTORY || MachineType.get(stack) == MachineType.ELITE_FACTORY; + } + + public MekanismRecipe setMirrored(boolean mirror) + { + mirrored = mirror; + return this; + } + + public Object[] getInput() + { + return input; + } } diff --git a/common/mekanism/common/recipe/RecipeHandler.java b/common/mekanism/common/recipe/RecipeHandler.java index c857e6eab..44667606b 100644 --- a/common/mekanism/common/recipe/RecipeHandler.java +++ b/common/mekanism/common/recipe/RecipeHandler.java @@ -18,18 +18,18 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -/** +/** * Class used to handle machine recipes. This is used for both adding recipes and checking outputs. * @author AidanBrady * */ public final class RecipeHandler -{ +{ public static void addRecipe(Recipe recipe, Object input, Object output) { recipe.put(input, output); } - + /** * Add an Enrichment Chamber recipe. * @param input - input ItemStack @@ -39,7 +39,7 @@ public final class RecipeHandler { Recipe.ENRICHMENT_CHAMBER.put(input, output); } - + /** * Add an Osmium Compressor recipe. * @param input - input ItemStack @@ -49,7 +49,7 @@ public final class RecipeHandler { Recipe.OSMIUM_COMPRESSOR.put(new AdvancedInput(input, GasRegistry.getGas("liquidOsmium")), output); } - + /** * Add a Combiner recipe. * @param input - input ItemStack @@ -59,7 +59,7 @@ public final class RecipeHandler { Recipe.COMBINER.put(new AdvancedInput(input, GasRegistry.getGas("liquidStone")), output); } - + /** * Add a Crusher recipe. * @param input - input ItemStack @@ -69,7 +69,7 @@ public final class RecipeHandler { Recipe.CRUSHER.put(input, output); } - + /** * Add a Purification Chamber recipe. * @param input - input ItemStack @@ -79,7 +79,7 @@ public final class RecipeHandler { Recipe.PURIFICATION_CHAMBER.put(new AdvancedInput(input, GasRegistry.getGas("oxygen")), output); } - + /** * Add a Metallurgic Infuser recipe. * @param input - input Infusion @@ -89,7 +89,7 @@ public final class RecipeHandler { Recipe.METALLURGIC_INFUSER.put(input, InfusionOutput.getInfusion(input, output)); } - + /** * Add a Chemical Infuser recipe. * @param input - input ChemicalPair @@ -109,7 +109,7 @@ public final class RecipeHandler { Recipe.CHEMICAL_OXIDIZER.put(input, output); } - + /** * Add a Chemical Injection Chamber recipe. * @param input - input ItemStack @@ -129,7 +129,7 @@ public final class RecipeHandler { Recipe.ELECTROLYTIC_SEPARATOR.put(fluid, products); } - + /** * Add an Precision Sawmill recipe. * @param input - input ItemStack @@ -139,7 +139,7 @@ public final class RecipeHandler { Recipe.PRECISION_SAWMILL.put(input, output); } - + /** * Add a Chemical Dissolution Chamber recipe. * @param input - input ItemStack @@ -149,7 +149,7 @@ public final class RecipeHandler { Recipe.CHEMICAL_DISSOLUTION_CHAMBER.put(input, output); } - + /** * Add a Chemical Washer recipe. * @param input - input GasStack @@ -159,7 +159,7 @@ public final class RecipeHandler { Recipe.CHEMICAL_WASHER.put(input, output); } - + /** * Add a Chemical Crystalizer recipe. * @param input - input GasStack @@ -177,15 +177,15 @@ public final class RecipeHandler * @return InfusionOutput */ public static InfusionOutput getMetallurgicInfuserOutput(InfusionInput infusion, boolean stackDecrease) - { + { if(infusion != null && infusion.inputStack != null) { HashMap recipes = Recipe.METALLURGIC_INFUSER.get(); - + for(Map.Entry entry : recipes.entrySet()) { InfusionInput input = (InfusionInput)entry.getKey(); - + if(StackUtils.equalsWildcard(input.inputStack, infusion.inputStack) && infusion.inputStack.stackSize >= input.inputStack.stackSize) { if(infusion.infusionType == input.infusionType) @@ -194,16 +194,16 @@ public final class RecipeHandler { infusion.inputStack.stackSize -= ((InfusionInput)entry.getKey()).inputStack.stackSize; } - + return ((InfusionOutput)entry.getValue()).copy(); } } } } - + return null; } - + /** * Gets the GasStack of the ChemicalInput in the parameters. * @param leftTank - first GasTank @@ -214,30 +214,30 @@ public final class RecipeHandler public static GasStack getChemicalInfuserOutput(GasTank leftTank, GasTank rightTank, boolean doRemove) { ChemicalPair input = new ChemicalPair(leftTank.getGas(), rightTank.getGas()); - + if(input.isValid()) { HashMap recipes = Recipe.CHEMICAL_INFUSER.get(); - + for(Map.Entry entry : recipes.entrySet()) { ChemicalPair key = (ChemicalPair)entry.getKey(); - + if(key.meetsInput(input)) { if(doRemove) { key.draw(leftTank, rightTank); } - + return entry.getValue().copy(); } } } - + return null; } - + /** * Gets the Chemical Crystalizer ItemStack output of the defined GasTank input. * @param itemstack - input GasTank @@ -259,7 +259,7 @@ public final class RecipeHandler if(key != null && key.getGas() == gas.getGas() && gas.amount >= key.amount) { gasTank.draw(key.amount, removeGas); - + return entry.getValue().copy(); } } @@ -267,7 +267,7 @@ public final class RecipeHandler return null; } - + /** * Gets the Chemical Washer GasStack output of the defined GasTank input. * @param gasTank - input GasTank @@ -289,7 +289,7 @@ public final class RecipeHandler if(key != null && key.getGas() == gas.getGas() && gas.amount >= key.amount) { gasTank.draw(key.amount, removeGas); - + return entry.getValue().copy(); } } @@ -311,22 +311,22 @@ public final class RecipeHandler for(Map.Entry entry : recipes.entrySet()) { ItemStack stack = (ItemStack)entry.getKey(); - + if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize) { if(stackDecrease) { itemstack.stackSize -= stack.stackSize; } - + return entry.getValue().copy(); } } } - + return null; } - + /** * Gets the output ChanceOutput of the ItemStack in the parameters. * @param itemstack - input ItemStack @@ -341,22 +341,22 @@ public final class RecipeHandler for(Map.Entry entry : recipes.entrySet()) { ItemStack stack = (ItemStack)entry.getKey(); - + if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize) { if(stackDecrease) { itemstack.stackSize -= stack.stackSize; } - + return ((ChanceOutput)entry.getValue()).copy(); } } } - + return null; } - + /** * Gets the output ItemStack of the ItemStack in the parameters. * @param itemstack - input ItemStack @@ -371,19 +371,19 @@ public final class RecipeHandler for(Map.Entry entry : recipes.entrySet()) { ItemStack stack = (ItemStack)entry.getKey(); - + if(StackUtils.equalsWildcard(stack, itemstack) && itemstack.stackSize >= stack.stackSize) { if(stackDecrease) { itemstack.stackSize -= stack.stackSize; } - + return ((ItemStack)entry.getValue()).copy(); } } } - + return null; } /** @@ -405,15 +405,15 @@ public final class RecipeHandler { input.itemStack.stackSize -= entry.getKey().itemStack.stackSize; } - + return entry.getValue().copy(); } } } - + return null; } - + /** * Get the result of electrolysing a given fluid * @param fluidTank - the FluidTank to electrolyse fluid from @@ -441,7 +441,7 @@ public final class RecipeHandler return null; } - + /** * Gets the output ItemStack of the ItemStack in the parameters. * @param itemstack - input ItemStack @@ -482,19 +482,19 @@ public final class RecipeHandler CHEMICAL_DISSOLUTION_CHAMBER(new HashMap()), CHEMICAL_WASHER(new HashMap()), CHEMICAL_CRYSTALIZER(new HashMap()); - + private HashMap recipes; - + private Recipe(HashMap map) { recipes = map; } - + public void put(Object input, Object output) { recipes.put(input, output); } - + public boolean containsRecipe(ItemStack input) { for(Object obj : get().entrySet()) @@ -502,11 +502,11 @@ public final class RecipeHandler if(obj instanceof Map.Entry) { Map.Entry entry = (Map.Entry)obj; - + if(entry.getKey() instanceof ItemStack) { ItemStack stack = (ItemStack)entry.getKey(); - + if(StackUtils.equalsWildcard(stack, input)) { return true; @@ -522,7 +522,7 @@ public final class RecipeHandler else if(entry.getKey() instanceof AdvancedInput) { ItemStack stack = ((AdvancedInput)entry.getKey()).itemStack; - + if(StackUtils.equalsWildcard(stack, input)) { return true; @@ -530,10 +530,10 @@ public final class RecipeHandler } } } - + return false; } - + public boolean containsRecipe(Fluid input) { for(Object obj : get().entrySet()) diff --git a/common/mekanism/common/tank/DynamicFluidTank.java b/common/mekanism/common/tank/DynamicFluidTank.java index c8c9afd81..6a9bc57a4 100644 --- a/common/mekanism/common/tank/DynamicFluidTank.java +++ b/common/mekanism/common/tank/DynamicFluidTank.java @@ -11,14 +11,14 @@ import net.minecraftforge.fluids.IFluidTank; public class DynamicFluidTank implements IFluidTank { public TileEntityDynamicTank dynamicTank; - + public DynamicFluidTank(TileEntityDynamicTank tileEntity) { dynamicTank = tileEntity; } @Override - public FluidStack getFluid() + public FluidStack getFluid() { return dynamicTank.structure != null ? dynamicTank.structure.fluidStored : null; } @@ -29,172 +29,172 @@ public class DynamicFluidTank implements IFluidTank return dynamicTank.structure != null ? dynamicTank.structure.volume*TankUpdateProtocol.FLUID_PER_TANK : 0; } - @Override - public int fill(FluidStack resource, boolean doFill) - { - if(dynamicTank.structure != null && !dynamicTank.worldObj.isRemote) - { - if(resource == null || resource.fluidID <= 0) - { - return 0; - } - - if(dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.fluidID <= 0) - { - if(resource.amount <= getCapacity()) - { - if(doFill) - { - dynamicTank.structure.fluidStored = resource.copy(); - } - - if(resource.amount > 0 && doFill) - { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(true); - dynamicTank.sendPacketToRenderer(); - updateValveData(false); - } - - return resource.amount; - } - else { - if(doFill) - { - dynamicTank.structure.fluidStored = resource.copy(); - dynamicTank.structure.fluidStored.amount = getCapacity(); - } - - if(getCapacity() > 0 && doFill) - { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(true); - dynamicTank.sendPacketToRenderer(); - updateValveData(false); - } - - return getCapacity(); - } - } - - if(!dynamicTank.structure.fluidStored.isFluidEqual(resource)) - { - return 0; - } - - int space = getCapacity() - dynamicTank.structure.fluidStored.amount; - - if(resource.amount <= space) - { - if(doFill) - { - dynamicTank.structure.fluidStored.amount += resource.amount; - } - - if(resource.amount > 0 && doFill) - { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(true); - dynamicTank.sendPacketToRenderer(); - updateValveData(false); - } - - return resource.amount; - } - else { - if(doFill) - { - dynamicTank.structure.fluidStored.amount = getCapacity(); - } - - if(space > 0 && doFill) - { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(true); - dynamicTank.sendPacketToRenderer(); - updateValveData(false); - } - - return space; - } - } - - return 0; - } - - public void updateValveData(boolean value) - { - if(dynamicTank.structure != null) - { - for(ValveData data : dynamicTank.structure.valves) - { - if(data.location.equals(Coord4D.get(dynamicTank))) - { - data.serverFluid = value; - } - } - } - } + @Override + public int fill(FluidStack resource, boolean doFill) + { + if(dynamicTank.structure != null && !dynamicTank.worldObj.isRemote) + { + if(resource == null || resource.fluidID <= 0) + { + return 0; + } - @Override - public FluidStack drain(int maxDrain, boolean doDrain) - { - if(dynamicTank.structure != null && !dynamicTank.worldObj.isRemote) - { - if(dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.fluidID <= 0) - { - return null; - } - - if(dynamicTank.structure.fluidStored.amount <= 0) - { - return null; - } - - int used = maxDrain; - - if(dynamicTank.structure.fluidStored.amount < used) - { - used = dynamicTank.structure.fluidStored.amount; - } - - if(doDrain) - { - dynamicTank.structure.fluidStored.amount -= used; - } - - FluidStack drained = new FluidStack(dynamicTank.structure.fluidStored.fluidID, used); - - if(dynamicTank.structure.fluidStored.amount <= 0) - { - dynamicTank.structure.fluidStored = null; - } - - if(drained.amount > 0 && doDrain) - { - MekanismUtils.saveChunk(dynamicTank); - dynamicTank.sendPacketToRenderer(); - } - - return drained; - } - - return null; - } + if(dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.fluidID <= 0) + { + if(resource.amount <= getCapacity()) + { + if(doFill) + { + dynamicTank.structure.fluidStored = resource.copy(); + } + + if(resource.amount > 0 && doFill) + { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(true); + dynamicTank.sendPacketToRenderer(); + updateValveData(false); + } + + return resource.amount; + } + else { + if(doFill) + { + dynamicTank.structure.fluidStored = resource.copy(); + dynamicTank.structure.fluidStored.amount = getCapacity(); + } + + if(getCapacity() > 0 && doFill) + { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(true); + dynamicTank.sendPacketToRenderer(); + updateValveData(false); + } + + return getCapacity(); + } + } + + if(!dynamicTank.structure.fluidStored.isFluidEqual(resource)) + { + return 0; + } + + int space = getCapacity() - dynamicTank.structure.fluidStored.amount; + + if(resource.amount <= space) + { + if(doFill) + { + dynamicTank.structure.fluidStored.amount += resource.amount; + } + + if(resource.amount > 0 && doFill) + { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(true); + dynamicTank.sendPacketToRenderer(); + updateValveData(false); + } + + return resource.amount; + } + else { + if(doFill) + { + dynamicTank.structure.fluidStored.amount = getCapacity(); + } + + if(space > 0 && doFill) + { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(true); + dynamicTank.sendPacketToRenderer(); + updateValveData(false); + } + + return space; + } + } + + return 0; + } + + public void updateValveData(boolean value) + { + if(dynamicTank.structure != null) + { + for(ValveData data : dynamicTank.structure.valves) + { + if(data.location.equals(Coord4D.get(dynamicTank))) + { + data.serverFluid = value; + } + } + } + } @Override - public int getFluidAmount() + public FluidStack drain(int maxDrain, boolean doDrain) + { + if(dynamicTank.structure != null && !dynamicTank.worldObj.isRemote) + { + if(dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.fluidID <= 0) + { + return null; + } + + if(dynamicTank.structure.fluidStored.amount <= 0) + { + return null; + } + + int used = maxDrain; + + if(dynamicTank.structure.fluidStored.amount < used) + { + used = dynamicTank.structure.fluidStored.amount; + } + + if(doDrain) + { + dynamicTank.structure.fluidStored.amount -= used; + } + + FluidStack drained = new FluidStack(dynamicTank.structure.fluidStored.fluidID, used); + + if(dynamicTank.structure.fluidStored.amount <= 0) + { + dynamicTank.structure.fluidStored = null; + } + + if(drained.amount > 0 && doDrain) + { + MekanismUtils.saveChunk(dynamicTank); + dynamicTank.sendPacketToRenderer(); + } + + return drained; + } + + return null; + } + + @Override + public int getFluidAmount() { if(dynamicTank.structure != null) { return dynamicTank.structure.fluidStored.amount; } - + return 0; } @Override - public FluidTankInfo getInfo() + public FluidTankInfo getInfo() { return new FluidTankInfo(this); } diff --git a/common/mekanism/common/tank/DynamicTankCache.java b/common/mekanism/common/tank/DynamicTankCache.java index 2174cf8bb..c6b155e32 100644 --- a/common/mekanism/common/tank/DynamicTankCache.java +++ b/common/mekanism/common/tank/DynamicTankCache.java @@ -6,10 +6,10 @@ import mekanism.api.Coord4D; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -public class DynamicTankCache +public class DynamicTankCache { public ItemStack[] inventory = new ItemStack[2]; public FluidStack fluid; - + public HashSet locations = new HashSet(); } diff --git a/common/mekanism/common/tank/SynchronizedTankData.java b/common/mekanism/common/tank/SynchronizedTankData.java index acba89884..0f51fb87e 100644 --- a/common/mekanism/common/tank/SynchronizedTankData.java +++ b/common/mekanism/common/tank/SynchronizedTankData.java @@ -8,30 +8,30 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class SynchronizedTankData +public class SynchronizedTankData { public Set locations = new HashSet(); - + public int volLength; - + public int volWidth; - + public int volHeight; - + public int volume; - + public FluidStack fluidStored; - + public ItemStack[] inventory = new ItemStack[2]; - + public boolean didTick; - + public boolean hasRenderer; - + public Coord4D renderLocation; - + public Set valves = new HashSet(); - + @Override public int hashCode() { @@ -43,7 +43,7 @@ public class SynchronizedTankData code = 31 * volume; return code; } - + @Override public boolean equals(Object obj) { @@ -51,33 +51,33 @@ public class SynchronizedTankData { return false; } - + SynchronizedTankData data = (SynchronizedTankData)obj; - + if(!data.locations.equals(locations)) { return false; } - + if(data.volLength != volLength || data.volWidth != volWidth || data.volHeight != volHeight) { return false; } - + if(data.volume != volume) { return false; } - + return true; } - + public static class ValveData { public ForgeDirection side; public Coord4D location; public boolean serverFluid; - + @Override public int hashCode() { @@ -86,7 +86,7 @@ public class SynchronizedTankData code = 31 * code + location.hashCode(); return code; } - + @Override public boolean equals(Object obj) { diff --git a/common/mekanism/common/tank/TankUpdateProtocol.java b/common/mekanism/common/tank/TankUpdateProtocol.java index 979df2715..4def5284d 100644 --- a/common/mekanism/common/tank/TankUpdateProtocol.java +++ b/common/mekanism/common/tank/TankUpdateProtocol.java @@ -13,168 +13,168 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; -public class TankUpdateProtocol +public class TankUpdateProtocol { public static final int FLUID_PER_TANK = 16000; - + /** The dynamic tank nodes that have already been iterated over. */ public Set iteratedNodes = new HashSet(); - + /** The structures found, all connected by some nodes to the pointer. */ public SynchronizedTankData structureFound = null; - + /** The original block the calculation is getting run from. */ public TileEntity pointer; - + public TankUpdateProtocol(TileEntity tileEntity) { pointer = tileEntity; } - + /** * Recursively loops through each node connected to the given TileEntity. * @param tile - the TileEntity to loop over */ public void loopThrough(TileEntity tile) { - World worldObj = tile.worldObj; - + World worldObj = tile.worldObj; + int origX = tile.xCoord, origY = tile.yCoord, origZ = tile.zCoord; - + boolean isCorner = true; boolean isHollow = true; boolean rightBlocks = true; boolean rightFrame = true; - + Set locations = new HashSet(); - + int xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0; - + int x = 0, y = 0, z = 0; - + int volume = 0; - + if((isViableNode(origX + 1, origY, origZ) && isViableNode(origX - 1, origY, origZ)) || (isViableNode(origX, origY + 1, origZ) && isViableNode(origX, origY - 1, origZ)) || (isViableNode(origX, origY, origZ + 1) && isViableNode(origX, origY, origZ - 1))) { - isCorner = false; + isCorner = false; } - + if(isCorner) { - if(isViableNode(origX+1, origY, origZ)) - { - xmin = 0; - - while(isViableNode(origX+x+1, origY, origZ)) - { - x++; - } - - xmax = x; - } - else { - xmax = 0; - - while(isViableNode(origX+x-1, origY, origZ)) - { - x--; - } - - xmin = x; - } - - if(isViableNode(origX, origY+1, origZ)) - { - ymin = 0; - - while(isViableNode(origX, origY+y+1, origZ)) - { - y++; - } - - ymax = y; - } - else { - ymax = 0; - - while(isViableNode(origX, origY+y-1 ,origZ)) - { - y--; - } - - ymin = y; - } - - if(isViableNode(origX, origY, origZ+1)) - { - zmin = 0; - - while(isViableNode(origX, origY, origZ+z+1)) - { - z++; - } - - zmax = z; - } - else { - zmax = 0; - - while(isViableNode(origX, origY, origZ+z-1)) - { - z--; - } - - zmin = z; - } - - for(x = xmin; x <= xmax; x++) - { - for(y = ymin; y <= ymax; y++) - { - for(z = zmin; z <= zmax; z++) - { - if(x == xmin || x == xmax || y == ymin || y == ymax || z == zmin || z == zmax) - { - if(!isViableNode(origX+x, origY+y, origZ+z)) - { - rightBlocks = false; - break; - } - else if(isFrame(Coord4D.get(tile).translate(x, y, z), origX+xmin, origX+xmax, origY+ymin, origY+ymax, origZ+zmin, origZ+zmax) && !isValidFrame(origX+x, origY+y, origZ+z)) - { - rightFrame = false; - break; - } - else { - locations.add(Coord4D.get(tile).translate(x, y, z)); - } - } - else { - if(!isAir(origX+x, origY+y, origZ+z)) - { - isHollow = false; - break; - } - - volume++; - } - } - if(!isHollow || !rightBlocks || !rightFrame) - { - break; - } - } - if(!isHollow || !rightBlocks || !rightFrame) - { - break; - } - } - } - + if(isViableNode(origX+1, origY, origZ)) + { + xmin = 0; + + while(isViableNode(origX+x+1, origY, origZ)) + { + x++; + } + + xmax = x; + } + else { + xmax = 0; + + while(isViableNode(origX+x-1, origY, origZ)) + { + x--; + } + + xmin = x; + } + + if(isViableNode(origX, origY+1, origZ)) + { + ymin = 0; + + while(isViableNode(origX, origY+y+1, origZ)) + { + y++; + } + + ymax = y; + } + else { + ymax = 0; + + while(isViableNode(origX, origY+y-1 ,origZ)) + { + y--; + } + + ymin = y; + } + + if(isViableNode(origX, origY, origZ+1)) + { + zmin = 0; + + while(isViableNode(origX, origY, origZ+z+1)) + { + z++; + } + + zmax = z; + } + else { + zmax = 0; + + while(isViableNode(origX, origY, origZ+z-1)) + { + z--; + } + + zmin = z; + } + + for(x = xmin; x <= xmax; x++) + { + for(y = ymin; y <= ymax; y++) + { + for(z = zmin; z <= zmax; z++) + { + if(x == xmin || x == xmax || y == ymin || y == ymax || z == zmin || z == zmax) + { + if(!isViableNode(origX+x, origY+y, origZ+z)) + { + rightBlocks = false; + break; + } + else if(isFrame(Coord4D.get(tile).translate(x, y, z), origX+xmin, origX+xmax, origY+ymin, origY+ymax, origZ+zmin, origZ+zmax) && !isValidFrame(origX+x, origY+y, origZ+z)) + { + rightFrame = false; + break; + } + else { + locations.add(Coord4D.get(tile).translate(x, y, z)); + } + } + else { + if(!isAir(origX+x, origY+y, origZ+z)) + { + isHollow = false; + break; + } + + volume++; + } + } + if(!isHollow || !rightBlocks || !rightFrame) + { + break; + } + } + if(!isHollow || !rightBlocks || !rightFrame) + { + break; + } + } + } + volume += locations.size(); - + if(volume >= 27 && volume <= 5832 && locations.size() >= 26) { if(rightBlocks && rightFrame && isHollow && isCorner) @@ -186,7 +186,7 @@ public class TankUpdateProtocol structure.volWidth = Math.abs(zmax-zmin)+1; structure.volume = volume; structure.renderLocation = Coord4D.get(tile).translate(0, 1, 0); - + for(Coord4D obj : structure.locations) { if(obj.getTileEntity(pointer.worldObj) instanceof TileEntityDynamicValve) @@ -194,11 +194,11 @@ public class TankUpdateProtocol ValveData data = new ValveData(); data.location = obj; data.side = getSide(obj, origX+xmin, origX+xmax, origY+ymin, origY+ymax, origZ+zmin, origZ+zmax); - + structure.valves.add(data); } } - + if(structure.locations.contains(Coord4D.get(pointer)) && isCorrectCorner(Coord4D.get(tile), origX+xmin, origY+ymin, origZ+zmin)) { structureFound = structure; @@ -206,13 +206,13 @@ public class TankUpdateProtocol } } } - + iteratedNodes.add((TileEntityDynamicTank)tile); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tileEntity = Coord4D.get(tile).getFromSide(side).getTileEntity(tile.worldObj); - + if(tileEntity instanceof TileEntityDynamicTank) { if(!iteratedNodes.contains(tileEntity)) @@ -222,7 +222,7 @@ public class TankUpdateProtocol } } } - + public ForgeDirection getSide(Coord4D obj, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) { if(obj.xCoord == xmin) @@ -249,10 +249,10 @@ public class TankUpdateProtocol { return ForgeDirection.SOUTH; } - + return ForgeDirection.UNKNOWN; } - + /** * Whether or not the block at the specified location is an air block. * @param x - x coordinate @@ -264,7 +264,7 @@ public class TankUpdateProtocol { return pointer.worldObj.isAirBlock(x, y, z); } - + /** * Whether or not the block at the specified location is a viable node for a dynamic tank. * @param x - x coordinate @@ -278,10 +278,10 @@ public class TankUpdateProtocol { return true; } - + return false; } - + /** * If the block at the specified location is on the minimum of all angles of this dynamic tank, and the one to use for the * actual calculation. @@ -297,10 +297,10 @@ public class TankUpdateProtocol { return true; } - + return false; } - + /** * Whether or not the block at the specified location is considered a frame on the dynamic tank. * @param obj - location to check @@ -322,7 +322,7 @@ public class TankUpdateProtocol return true; if(obj.xCoord == xmax && obj.yCoord == ymax) return true; - + if(obj.xCoord == xmin && obj.zCoord == zmin) return true; if(obj.xCoord == xmax && obj.zCoord == zmin) @@ -331,7 +331,7 @@ public class TankUpdateProtocol return true; if(obj.xCoord == xmax && obj.zCoord == zmax) return true; - + if(obj.yCoord == ymin && obj.zCoord == zmin) return true; if(obj.yCoord == ymax && obj.zCoord == zmin) @@ -340,10 +340,10 @@ public class TankUpdateProtocol return true; if(obj.yCoord == ymax && obj.zCoord == zmax) return true; - + return false; } - + /** * Whether or not the block at the specified location serves as a frame for a dynamic tank. * @param x - x coordinate @@ -355,14 +355,14 @@ public class TankUpdateProtocol { return pointer.worldObj.getBlockId(x, y, z) == Mekanism.basicBlockID && pointer.worldObj.getBlockMetadata(x, y, z) == 9; } - + /** * Runs the protocol and updates all tanks that make a part of the dynamic tank. */ public void updateTanks() { loopThrough(pointer); - + if(structureFound != null) { for(TileEntityDynamicTank tileEntity : iteratedNodes) @@ -373,26 +373,26 @@ public class TankUpdateProtocol { ((TileEntityDynamicTank)tileEntity).structure = null; } - + return; } } - + int idFound = -1; - + for(Coord4D obj : structureFound.locations) { TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(pointer.worldObj); - + if(tileEntity.inventoryID != -1) { idFound = tileEntity.inventoryID; break; } } - + DynamicTankCache cache = new DynamicTankCache(); - + if(idFound != -1) { if(Mekanism.dynamicInventories.get(idFound) != null) @@ -403,19 +403,19 @@ public class TankUpdateProtocol else { idFound = MekanismUtils.getUniqueInventoryID(); } - + structureFound.fluidStored = cache.fluid; structureFound.inventory = cache.inventory; - + if(structureFound.fluidStored != null) { structureFound.fluidStored.amount = Math.min(structureFound.fluidStored.amount, structureFound.volume*FLUID_PER_TANK); } - + for(Coord4D obj : structureFound.locations) { TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(pointer.worldObj); - + tileEntity.inventoryID = idFound; tileEntity.structure = structureFound; tileEntity.cachedFluid = structureFound.fluidStored; diff --git a/common/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java b/common/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java index b630eaf62..a7396e0e7 100644 --- a/common/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java +++ b/common/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java @@ -24,134 +24,134 @@ import dan200.computer.api.IPeripheral; public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral { @Override - public int getSizeInventory() + public int getSizeInventory() { if(getInv() == null) { return 0; } - + return getInv().getSizeInventory(); } @Override - public ItemStack getStackInSlot(int i) + public ItemStack getStackInSlot(int i) { if(getInv() == null) { return null; } - + return getInv().getStackInSlot(i); } @Override - public ItemStack decrStackSize(int i, int j) + public ItemStack decrStackSize(int i, int j) { if(getInv() == null) { return null; } - + return getInv().decrStackSize(i, j); } @Override - public ItemStack getStackInSlotOnClosing(int i) + public ItemStack getStackInSlotOnClosing(int i) { if(getInv() == null) { return null; } - + return getInv().getStackInSlotOnClosing(i); } @Override - public void setInventorySlotContents(int i, ItemStack itemstack) + public void setInventorySlotContents(int i, ItemStack itemstack) { if(getInv() == null) { return; } - + getInv().setInventorySlotContents(i, itemstack); } @Override - public String getInvName() + public String getInvName() { if(getInv() == null) { return null; } - + return getInv().getInvName(); } @Override - public boolean isInvNameLocalized() + public boolean isInvNameLocalized() { if(getInv() == null) { return false; } - + return getInv().isInvNameLocalized(); } @Override - public int getInventoryStackLimit() + public int getInventoryStackLimit() { if(getInv() == null) { return 0; } - + return getInv().getInventoryStackLimit(); } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) + public boolean isUseableByPlayer(EntityPlayer entityplayer) { if(getInv() == null) { return false; } - + return getInv().isUseableByPlayer(entityplayer); } @Override - public void openChest() + public void openChest() { if(getInv() == null) { return; } - + getInv().openChest(); } @Override - public void closeChest() + public void closeChest() { if(getInv() == null) { return; } - + getInv().closeChest(); } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) + public boolean isItemValidForSlot(int i, ItemStack itemstack) { if(getInv() == null) { return false; } - + return getInv().canBoundInsert(Coord4D.get(this), i, itemstack); } @@ -162,7 +162,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return InventoryUtils.EMPTY; } - + return getInv().getBoundSlots(Coord4D.get(this), slotID); } @@ -173,24 +173,24 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) + public boolean canExtractItem(int i, ItemStack itemstack, int j) { if(getInv() == null) { return false; } - + return getInv().canBoundExtract(Coord4D.get(this), i, itemstack, j); } @Override - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { if(getInv() == null) { return false; } - + return getInv().acceptsEnergyFrom(emitter, direction); } @@ -201,7 +201,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return 0; } - + return getInv().receiveEnergy(from, maxReceive, simulate); } @@ -212,193 +212,193 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return 0; } - + return getInv().extractEnergy(from, maxExtract, simulate); } @Override - public boolean canInterface(ForgeDirection from) + public boolean canInterface(ForgeDirection from) { if(getInv() == null) { return false; } - + return getInv().canInterface(from); } @Override - public int getEnergyStored(ForgeDirection from) + public int getEnergyStored(ForgeDirection from) { if(getInv() == null) { return 0; } - + return getInv().getEnergyStored(from); } @Override - public int getMaxEnergyStored(ForgeDirection from) + public int getMaxEnergyStored(ForgeDirection from) { if(getInv() == null) { return 0; } - + return getInv().getMaxEnergyStored(from); } @Override - public double getEnergy() + public double getEnergy() { if(getInv() == null) { return 0; } - + return getInv().getEnergy(); } @Override - public void setEnergy(double energy) + public void setEnergy(double energy) { if(getInv() == null) { return; } - + getInv().setEnergy(energy); } @Override - public double getMaxEnergy() + public double getMaxEnergy() { if(getInv() == null) { return 0; } - + return getInv().getMaxEnergy(); } @Override - public PowerReceiver getPowerReceiver(ForgeDirection side) + public PowerReceiver getPowerReceiver(ForgeDirection side) { if(getInv() == null) { return null; } - + return getInv().getPowerReceiver(side); } @Override - public void doWork(PowerHandler workProvider) + public void doWork(PowerHandler workProvider) { if(getInv() == null) { return; } - + getInv().doWork(workProvider); } @Override - public World getWorld() + public World getWorld() { if(getInv() == null) { return null; } - + return getInv().getWorld(); } @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { if(getInv() == null) { return 0; } - + return getInv().transferEnergyToAcceptor(side, amount); } @Override - public boolean canReceiveEnergy(ForgeDirection side) + public boolean canReceiveEnergy(ForgeDirection side) { if(getInv() == null) { return false; } - + return getInv().canReceiveEnergy(side); } @Override - public double demandedEnergyUnits() + public double demandedEnergyUnits() { if(getInv() == null) { return 0; } - + return getInv().demandedEnergyUnits(); } @Override - public double injectEnergyUnits(ForgeDirection directionFrom, double amount) + public double injectEnergyUnits(ForgeDirection directionFrom, double amount) { if(getInv() == null) { return amount; } - + return getInv().injectEnergyUnits(directionFrom, amount); } @Override - public int getMaxSafeInput() + public int getMaxSafeInput() { if(getInv() == null) { return 0; } - + return getInv().getMaxSafeInput(); } - + public IAdvancedBoundingBlock getInv() { TileEntity tile = new Coord4D(mainX, mainY, mainZ, worldObj.provider.dimensionId).getTileEntity(worldObj); - + if(!(tile instanceof IAdvancedBoundingBlock)) { worldObj.setBlockToAir(xCoord, yCoord, zCoord); return null; } - + return (IAdvancedBoundingBlock)new Coord4D(mainX, mainY, mainZ, worldObj.provider.dimensionId).getTileEntity(worldObj); } - + @Override public void onPower() { super.onPower(); - + if(getInv() != null) { getInv().onPower(); } } - + @Override public void onNoPower() { super.onNoPower(); - + if(getInv() != null) { getInv().onNoPower(); @@ -412,7 +412,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return null; } - + return getInv().getType(); } @@ -423,7 +423,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return null; } - + return getInv().getMethodNames(); } @@ -434,7 +434,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return null; } - + return getInv().callMethod(computer, context, method, arguments); } @@ -445,7 +445,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return false; } - + return getInv().canAttachToSide(side); } @@ -456,7 +456,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return; } - + getInv().attach(computer); } @@ -467,7 +467,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { return; } - + getInv().detach(computer); } } diff --git a/common/mekanism/common/tile/TileEntityAdvancedElectricMachine.java b/common/mekanism/common/tile/TileEntityAdvancedElectricMachine.java index 055169175..6a343eba1 100644 --- a/common/mekanism/common/tile/TileEntityAdvancedElectricMachine.java +++ b/common/mekanism/common/tile/TileEntityAdvancedElectricMachine.java @@ -33,16 +33,16 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM { /** How much secondary energy (fuel) this machine uses per tick. */ public int SECONDARY_ENERGY_PER_TICK; - + public static int MAX_GAS = 200; - + public GasTank gasTank; - + /** - * Advanced Electric Machine -- a machine like this has a total of 4 slots. Input slot (0), fuel slot (1), output slot (2), + * Advanced Electric Machine -- a machine like this has a total of 4 slots. Input slot (0), fuel slot (1), output slot (2), * energy slot (3), and the upgrade slot (4). The machine will not run if it does not have enough electricity, or if it doesn't have enough * fuel ticks. - * + * * @param soundPath - location of the sound effect * @param name - full name of this machine * @param location - GUI texture path of this machine @@ -55,61 +55,61 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM public TileEntityAdvancedElectricMachine(String soundPath, String name, ResourceLocation location, double perTick, int secondaryPerTick, int ticksRequired, double maxEnergy) { super(soundPath, name, location, perTick, ticksRequired, maxEnergy); - + sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0})); sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {1})); sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {2})); sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {3})); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {4})); - + sideConfig = new byte[] {2, 1, 0, 4, 5, 3}; - + gasTank = new GasTank(MAX_GAS); - + inventory = new ItemStack[5]; - + SECONDARY_ENERGY_PER_TICK = secondaryPerTick; - + upgradeComponent = new TileComponentUpgrade(this, 4); ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3)); } - - /** - * Gets the amount of ticks the declared itemstack can fuel this machine. - * @param itemstack - itemstack to check with - * @return fuel ticks - */ - public abstract GasStack getItemGas(ItemStack itemstack); - - public abstract boolean isValidGas(Gas gas); - - @Override + + /** + * Gets the amount of ticks the declared itemstack can fuel this machine. + * @param itemstack - itemstack to check with + * @return fuel ticks + */ + public abstract GasStack getItemGas(ItemStack itemstack); + + public abstract boolean isValidGas(Gas gas); + + @Override public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { ChargeUtils.discharge(3, this); - + handleSecondaryFuel(); - + boolean changed = false; - + if(canOperate() && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK) && gasTank.getStored() >= SECONDARY_ENERGY_PER_TICK) { - setActive(true); - + setActive(true); + operatingTicks++; - + if(operatingTicks >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) { operate(); - + operatingTicks = 0; } - + gasTank.draw(SECONDARY_ENERGY_PER_TICK, true); electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK); } @@ -120,62 +120,62 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM setActive(false); } } - + if(changed && !canOperate() && !hasRecipe(inventory[0])) { operatingTicks = 0; } - + prevEnergy = getEnergy(); } } - - private boolean hasRecipe(ItemStack itemStack) - { - if(itemStack == null) - { - return false; - } - - for(Object obj : getRecipes().entrySet()) - { - if(((Map.Entry)obj).getKey() instanceof AdvancedInput) + + private boolean hasRecipe(ItemStack itemStack) + { + if(itemStack == null) + { + return false; + } + + for(Object obj : getRecipes().entrySet()) + { + if(((Map.Entry)obj).getKey() instanceof AdvancedInput) { - Map.Entry entry = (Map.Entry)obj; - + Map.Entry entry = (Map.Entry)obj; + ItemStack stack = ((AdvancedInput)entry.getKey()).itemStack; - + if(StackUtils.equalsWildcard(stack, itemStack)) { return true; } } - } - - return false; - } - - public void handleSecondaryFuel() - { + } + + return false; + } + + public void handleSecondaryFuel() + { if(inventory[1] != null) { GasStack stack = getItemGas(inventory[1]); int gasNeeded = gasTank.getNeeded(); - + if(stack != null && stack.amount <= gasNeeded) { gasTank.receive(stack, true); - + inventory[1].stackSize--; - + if(inventory[1].stackSize == 0) { inventory[1] = null; } } } - } - + } + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -199,66 +199,66 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM { return getItemGas(itemstack) != null; } - + return false; } - @Override - public void operate() - { - ItemStack itemstack = RecipeHandler.getOutput(new AdvancedInput(inventory[0], gasTank.getGas().getGas()), true, getRecipes()); + @Override + public void operate() + { + ItemStack itemstack = RecipeHandler.getOutput(new AdvancedInput(inventory[0], gasTank.getGas().getGas()), true, getRecipes()); - if(inventory[0].stackSize <= 0) - { - inventory[0] = null; - } + if(inventory[0].stackSize <= 0) + { + inventory[0] = null; + } - if(inventory[2] == null) - { - inventory[2] = itemstack; - } - else { - inventory[2].stackSize += itemstack.stackSize; - } - - onInventoryChanged(); - ejectorComponent.onOutput(); - } + if(inventory[2] == null) + { + inventory[2] = itemstack; + } + else { + inventory[2].stackSize += itemstack.stackSize; + } - @Override - public boolean canOperate() - { - if(inventory[0] == null || gasTank.getGas() == null) - { - return false; - } + onInventoryChanged(); + ejectorComponent.onOutput(); + } - ItemStack itemstack = RecipeHandler.getOutput(new AdvancedInput(inventory[0], gasTank.getGas().getGas()), false, getRecipes()); + @Override + public boolean canOperate() + { + if(inventory[0] == null || gasTank.getGas() == null) + { + return false; + } - if(itemstack == null) - { - return false; - } + ItemStack itemstack = RecipeHandler.getOutput(new AdvancedInput(inventory[0], gasTank.getGas().getGas()), false, getRecipes()); - if(inventory[2] == null) - { - return true; - } + if(itemstack == null) + { + return false; + } + + if(inventory[2] == null) + { + return true; + } + + if(!inventory[2].isItemEqual(itemstack)) + { + return false; + } + else { + return inventory[2].stackSize + itemstack.stackSize <= inventory[2].getMaxStackSize(); + } + } - if(!inventory[2].isItemEqual(itemstack)) - { - return false; - } - else { - return inventory[2].stackSize + itemstack.stackSize <= inventory[2].getMaxStackSize(); - } - } - @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + if(dataStream.readBoolean()) { gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); @@ -267,12 +267,12 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM gasTank.setGas(null); } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + if(gasTank.getGas() != null) { data.add(true); @@ -282,26 +282,26 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM else { data.add(false); } - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - gasTank.read(nbtTags.getCompoundTag("gasTank")); - } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); - } - + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + gasTank.read(nbtTags.getCompoundTag("gasTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); + } + /** * Gets the scaled secondary energy level for the GUI. * @param i - multiplier @@ -311,7 +311,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM { return gasTank.getStored()*i / gasTank.getMaxGas(); } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -323,10 +323,10 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM { return true; } - + return false; } - + @Override public boolean canTubeConnect(ForgeDirection side) { @@ -358,13 +358,13 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getSecondaryStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { diff --git a/common/mekanism/common/tile/TileEntityAdvancedFactory.java b/common/mekanism/common/tile/TileEntityAdvancedFactory.java index 9ad75b660..2983c3c53 100644 --- a/common/mekanism/common/tile/TileEntityAdvancedFactory.java +++ b/common/mekanism/common/tile/TileEntityAdvancedFactory.java @@ -12,14 +12,14 @@ public class TileEntityAdvancedFactory extends TileEntityFactory public TileEntityAdvancedFactory() { super(FactoryTier.ADVANCED, MachineType.ADVANCED_FACTORY); - + sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0})); sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1})); sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {4})); sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7, 8, 9})); sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {10, 11, 12, 13, 14})); - + ejectorComponent = new TileComponentEjector(this, sideOutputs.get(5)); } } diff --git a/common/mekanism/common/tile/TileEntityBasicBlock.java b/common/mekanism/common/tile/TileEntityBasicBlock.java index 523d7538b..d60569465 100644 --- a/common/mekanism/common/tile/TileEntityBasicBlock.java +++ b/common/mekanism/common/tile/TileEntityBasicBlock.java @@ -26,23 +26,23 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench { /** The direction this block is facing. */ public int facing; - + public int clientFacing; - + public Set openedThisTick = new HashSet(); - + /** The players currently using this block. */ public Set playersUsing = new HashSet(); - + /** A timer used to send packets to clients. */ public int ticker; - + public boolean redstone = false; - + public boolean doAutoSync = true; - + public List components = new ArrayList(); - + @Override public void updateEntity() { @@ -50,13 +50,13 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench { component.tick(); } - + onUpdate(); - + if(!worldObj.isRemote) { openedThisTick.clear(); - + if(doAutoSync && playersUsing.size() > 0) { for(EntityPlayer player : playersUsing) @@ -65,96 +65,96 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench } } } - + ticker++; } - + public void open(EntityPlayer player) { playersUsing.add(player); } - + public void close(EntityPlayer player) { playersUsing.remove(player); } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { facing = dataStream.readInt(); redstone = dataStream.readBoolean(); - + if(clientFacing != facing) { MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); clientFacing = facing; } - + for(ITileComponent component : components) { component.read(dataStream); } } - + @Override public ArrayList getNetworkedData(ArrayList data) - { + { data.add(facing); data.add(redstone); - + for(ITileComponent component : components) { component.write(data); } - + return data; } - + @Override public void validate() { super.validate(); - + if(worldObj.isRemote) { PacketHandler.sendPacket(Transmission.SERVER, new PacketDataRequest().setParams(Coord4D.get(this))); } } - + /** * Update call for machines. Use instead of updateEntity -- it's called every tick. */ public abstract void onUpdate(); - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - facing = nbtTags.getInteger("facing"); - redstone = nbtTags.getBoolean("redstone"); - - for(ITileComponent component : components) - { - component.read(nbtTags); - } - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("facing", facing); - nbtTags.setBoolean("redstone", redstone); - - for(ITileComponent component : components) - { - component.write(nbtTags); - } - } + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + facing = nbtTags.getInteger("facing"); + redstone = nbtTags.getBoolean("redstone"); + + for(ITileComponent component : components) + { + component.read(nbtTags); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("facing", facing); + nbtTags.setBoolean("redstone", redstone); + + for(ITileComponent component : components) + { + component.write(nbtTags); + } + } @Override public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) @@ -163,19 +163,19 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench } @Override - public short getFacing() + public short getFacing() { return (short)facing; } @Override - public void setFacing(short direction) + public void setFacing(short direction) { if(canSetFacing(direction)) { facing = direction; } - + if(facing != clientFacing) { PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), worldObj.provider.dimensionId); @@ -183,7 +183,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench clientFacing = facing; } } - + /** * Whether or not this block's orientation can be changed to a specific direction. True by default. * @param facing - facing to check @@ -195,34 +195,34 @@ public abstract class TileEntityBasicBlock extends TileEntity implements IWrench } @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { return true; } @Override - public float getWrenchDropRate() + public float getWrenchDropRate() { return 1.0F; } - + @Override public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { return getBlockType().getPickBlock(null, worldObj, xCoord, yCoord, zCoord); } - + public boolean isPowered() { return redstone; } - + public void onNeighborChange(int id) { if(!worldObj.isRemote) { boolean power = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); - + if(redstone != power) { redstone = power; diff --git a/common/mekanism/common/tile/TileEntityBasicMachine.java b/common/mekanism/common/tile/TileEntityBasicMachine.java index a755ee6cc..ab9027fff 100644 --- a/common/mekanism/common/tile/TileEntityBasicMachine.java +++ b/common/mekanism/common/tile/TileEntityBasicMachine.java @@ -30,43 +30,43 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp { /** This machine's side configuration. */ public byte[] sideConfig; - + /** An arraylist of SideData for this machine. */ public ArrayList sideOutputs = new ArrayList(); - + /** The bundled URL of this machine's sound effect */ public String soundURL; - + /** How much energy this machine uses per tick. */ public double ENERGY_PER_TICK; - + /** How many ticks this machine has operated for. */ public int operatingTicks = 0; - + /** Ticks required to operate -- or smelt an item. */ public int TICKS_REQUIRED; - + /** How many ticks must pass until this block's active state can sync with the client. */ public int updateDelay; - + /** Whether or not this block is in it's active state. */ public boolean isActive; - + /** The client's current active state. */ public boolean clientActive; - + /** The GUI texture path for this machine. */ public ResourceLocation guiLocation; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - + /** This machine's previous amount of energy. */ public double prevEnergy; - + public TileComponentUpgrade upgradeComponent; public TileComponentEjector ejectorComponent; - + /** * The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound effect, and animated texture. * @param soundPath - location of the sound effect @@ -85,20 +85,20 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp guiLocation = location; isActive = false; } - + @Override public void onUpdate() { super.onUpdate(); - + if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -106,13 +106,13 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); @@ -120,47 +120,47 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp } } } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - operatingTicks = nbtTags.getInteger("operatingTicks"); - clientActive = isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - if(nbtTags.hasKey("sideDataStored")) - { - for(int i = 0; i < 6; i++) - { - sideConfig[i] = nbtTags.getByte("config"+i); - } - } - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - - nbtTags.setBoolean("sideDataStored", true); - - for(int i = 0; i < 6; i++) - { - nbtTags.setByte("config"+i, sideConfig[i]); - } - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + operatingTicks = nbtTags.getInteger("operatingTicks"); + clientActive = isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + if(nbtTags.hasKey("sideDataStored")) + { + for(int i = 0; i < 6; i++) + { + sideConfig[i] = nbtTags.getByte("config"+i); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + + nbtTags.setBoolean("sideDataStored", true); + + for(int i = 0; i < 6; i++) + { + nbtTags.setByte("config"+i, sideConfig[i]); + } + } + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + operatingTicks = dataStream.readInt(); clientActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; @@ -169,7 +169,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp { sideConfig[i] = dataStream.readByte(); } - + if(updateDelay == 0 && clientActive != isActive) { updateDelay = Mekanism.UPDATE_DELAY; @@ -177,25 +177,25 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(operatingTicks); data.add(isActive); data.add(controlType.ordinal()); data.add(sideConfig); - + return data; } - + @Override public void invalidate() { super.invalidate(); - + if(worldObj.isRemote) { Mekanism.proxy.unregisterSound(this); @@ -208,16 +208,16 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp * @return */ public int getScaledProgress(int i) - { + { return operatingTicks*i / MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED); } - + @Override - public double getMaxEnergy() + public double getMaxEnergy() { return MekanismUtils.getMaxEnergy(getEnergyMultiplier(), MAX_ELECTRICITY); } - + @Override public boolean getActive() { @@ -225,31 +225,31 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp } @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public String getType() - { - return getInvName(); - } + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } @Override - public boolean canAttachToSide(int side) + public String getType() + { + return getInvName(); + } + + @Override + public boolean canAttachToSide(int side) { return true; } - + @Override public boolean canSetFacing(int facing) { @@ -261,77 +261,77 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp @Override public void detach(IComputerAccess computer) {} - + @Override public int[] getAccessibleSlotsFromSide(int side) { return sideOutputs.get(sideConfig[MekanismUtils.getBaseOrientation(side, facing)]).availableSlots; } - + @Override public ArrayList getSideData() { return sideOutputs; } - + @Override public byte[] getConfiguration() { return sideConfig; } - + @Override public int getOrientation() { return facing; } - + @Override - public int getEnergyMultiplier(Object... data) + public int getEnergyMultiplier(Object... data) { return upgradeComponent.energyMultiplier; } @Override - public void setEnergyMultiplier(int multiplier, Object... data) + public void setEnergyMultiplier(int multiplier, Object... data) { upgradeComponent.energyMultiplier = multiplier; MekanismUtils.saveChunk(this); } @Override - public int getSpeedMultiplier(Object... data) + public int getSpeedMultiplier(Object... data) { return upgradeComponent.speedMultiplier; } @Override - public void setSpeedMultiplier(int multiplier, Object... data) + public void setSpeedMultiplier(int multiplier, Object... data) { upgradeComponent.speedMultiplier = multiplier; MekanismUtils.saveChunk(this); } - + @Override public boolean supportsUpgrades(Object... data) { return true; } - + @Override public String getSoundPath() { return soundURL; } - + @Override public float getVolumeMultiplier() { return 1; } - + @Override - public boolean renderUpdate() + public boolean renderUpdate() { return true; } @@ -341,26 +341,26 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp { return true; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); } - + @Override public TileComponentUpgrade getComponent() { return upgradeComponent; } - + @Override public IEjector getEjector() { diff --git a/common/mekanism/common/tile/TileEntityBin.java b/common/mekanism/common/tile/TileEntityBin.java index b78569021..559a51f06 100644 --- a/common/mekanism/common/tile/TileEntityBin.java +++ b/common/mekanism/common/tile/TileEntityBin.java @@ -29,28 +29,28 @@ import com.google.common.io.ByteArrayDataInput; public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IDeepStorageUnit, IConfigurable { public boolean isActive; - + public boolean clientActive; - + public final int MAX_DELAY = 10; - + public int addTicks = 0; - + public int delayTicks; - + public int cacheCount; - + public final int MAX_STORAGE = 4096; - + public ItemStack itemType; - + public ItemStack topStack; public ItemStack bottomStack; - + public int prevCount; - + public int clientAmount; - + public void sortStacks() { if(getItemCount() == 0 || itemType == null) @@ -59,13 +59,13 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento topStack = null; bottomStack = null; cacheCount = 0; - + return; } - + int count = getItemCount(); int remain = MAX_STORAGE-count; - + if(remain >= itemType.getMaxStackSize()) { topStack = null; @@ -74,47 +74,47 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento topStack = itemType.copy(); topStack.stackSize = itemType.getMaxStackSize()-remain; } - + count -= StackUtils.getSize(topStack); - + bottomStack = itemType.copy(); bottomStack.stackSize = Math.min(itemType.getMaxStackSize(), count); - + count -= StackUtils.getSize(bottomStack); - + cacheCount = count; } - + public boolean isValid(ItemStack stack) { if(stack == null || stack.stackSize <= 0) { return false; } - + if(stack.isItemStackDamageable() && stack.isItemDamaged()) { return false; } - + if(stack.getItem() instanceof ItemBlockBasic && stack.getItemDamage() == 6) { return false; } - + if(itemType == null) { return true; } - + if(!stack.isItemEqual(itemType) || !ItemStack.areItemStackTagsEqual(stack, itemType)) { return false; } - + return true; } - + public ItemStack add(ItemStack stack) { if(isValid(stack) && getItemCount() != MAX_STORAGE) @@ -123,7 +123,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { setItemType(stack); } - + if(getItemCount() + stack.stackSize <= MAX_STORAGE) { setItemCount(getItemCount() + stack.stackSize); @@ -132,74 +132,74 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento else { ItemStack rejects = itemType.copy(); rejects.stackSize = (getItemCount()+stack.stackSize) - MAX_STORAGE; - + setItemCount(MAX_STORAGE); - + return rejects; } } - + return stack; } - + public ItemStack removeStack() { if(getItemCount() == 0) { return null; } - + return remove(bottomStack.stackSize); } - + public ItemStack remove(int amount) { if(getItemCount() == 0) { return null; } - + ItemStack ret = itemType.copy(); ret.stackSize = Math.min(Math.min(amount, itemType.getMaxStackSize()), getItemCount()); - + setItemCount(getItemCount() - ret.stackSize); - + return ret; } - + public int getItemCount() { return StackUtils.getSize(bottomStack) + cacheCount + StackUtils.getSize(topStack); } - + @Override - public void onUpdate() + public void onUpdate() { if(!worldObj.isRemote) { addTicks = Math.max(0, addTicks-1); delayTicks = Math.max(0, delayTicks-1); - + sortStacks(); - + if(getItemCount() != prevCount) { onInventoryChanged(); MekanismUtils.saveChunk(this); } - + if(delayTicks == 0) { if(bottomStack != null && isActive) { TileEntity tile = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(0)).getTileEntity(worldObj); - + if(tile instanceof ILogisticalTransporter) { ILogisticalTransporter transporter = (ILogisticalTransporter)tile; - + ItemStack rejects = TransporterUtils.insert(this, transporter, bottomStack, null, true, 0); - + if(TransporterManager.didEmit(bottomStack, rejects)) { setInventorySlotContents(0, rejects); @@ -209,7 +209,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { setInventorySlotContents(0, InventoryUtils.putStackInInventory((IInventory)tile, bottomStack, 0, false)); } - + delayTicks = 10; } } @@ -218,73 +218,73 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } } } - + @Override public void writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - + nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("itemCount", cacheCount); - + if(bottomStack != null) { nbtTags.setCompoundTag("bottomStack", bottomStack.writeToNBT(new NBTTagCompound())); } - + if(topStack != null) { nbtTags.setCompoundTag("topStack", topStack.writeToNBT(new NBTTagCompound())); } - + if(getItemCount() > 0) { nbtTags.setCompoundTag("itemType", itemType.writeToNBT(new NBTTagCompound())); } } - + @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - + isActive = nbtTags.getBoolean("isActive"); cacheCount = nbtTags.getInteger("itemCount"); - + bottomStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("bottomStack")); topStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("topStack")); - + if(getItemCount() > 0) { itemType = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemType")); } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(getItemCount()); - + if(getItemCount() > 0) { data.add(itemType.itemID); data.add(itemType.getItemDamage()); } - + return data; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + isActive = dataStream.readBoolean(); clientAmount = dataStream.readInt(); - + if(clientAmount > 0) { itemType = new ItemStack(dataStream.readInt(), 1, dataStream.readInt()); @@ -292,12 +292,12 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento else { itemType = null; } - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override - public ItemStack getStackInSlot(int slotID) + public ItemStack getStackInSlot(int slotID) { if(slotID == 1) { @@ -307,10 +307,10 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento return bottomStack; } } - + @Override - public ItemStack decrStackSize(int slotID, int amount) - { + public ItemStack decrStackSize(int slotID, int amount) + { if(slotID == 1) { return null; @@ -318,35 +318,35 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento else if(slotID == 0) { int toRemove = Math.min(getItemCount(), amount); - + if(toRemove > 0) { ItemStack ret = itemType.copy(); ret.stackSize = toRemove; - + setItemCount(getItemCount()-toRemove); - + return ret; } } - + return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slotID) - { - return getStackInSlot(slotID); - } + } @Override - public int getSizeInventory() + public ItemStack getStackInSlotOnClosing(int slotID) + { + return getStackInSlot(slotID); + } + + @Override + public int getSizeInventory() { return 2; } @Override - public void setInventorySlotContents(int i, ItemStack itemstack) + public void setInventorySlotContents(int i, ItemStack itemstack) { if(i == 0) { @@ -354,7 +354,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { return; } - + if(itemstack == null) { setItemCount(getItemCount() - bottomStack.stackSize); @@ -371,12 +371,12 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } } } - + @Override public void onInventoryChanged() { super.onInventoryChanged(); - + if(!worldObj.isRemote) { MekanismUtils.saveChunk(this); @@ -385,7 +385,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento sortStacks(); } } - + public void setItemType(ItemStack stack) { if(stack == null) @@ -396,46 +396,46 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento bottomStack = null; return; } - + ItemStack ret = stack.copy(); ret.stackSize = 1; itemType = ret; } - + public void setItemCount(int count) { cacheCount = Math.max(0, count); topStack = null; bottomStack = null; - + if(count == 0) { setItemType(null); } - + onInventoryChanged(); } @Override - public String getInvName() + public String getInvName() { return MekanismUtils.localize("tile.BasicBlock.Bin.name"); } @Override - public boolean isInvNameLocalized() + public boolean isInvNameLocalized() { return true; } @Override - public int getInventoryStackLimit() + public int getInventoryStackLimit() { return 64; } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) + public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } @@ -447,13 +447,13 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento public void closeChest() {} @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) + public boolean isItemValidForSlot(int i, ItemStack itemstack) { return i == 1 ? isValid(itemstack) : false; } @Override - public int[] getAccessibleSlotsFromSide(int side) + public int[] getAccessibleSlotsFromSide(int side) { if(side == 1) { @@ -461,14 +461,14 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } else if(side == 0) { - return new int[] {0}; + return new int[] {0}; } - + return InventoryUtils.EMPTY; } @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) + public boolean canInsertItem(int i, ItemStack itemstack, int j) { return isItemValidForSlot(i, itemstack); } @@ -478,7 +478,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { return i == 0 ? isValid(itemstack) : false; } - + @Override public boolean canSetFacing(int facing) { @@ -486,32 +486,32 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + clientActive = active; + } + } @Override - public boolean renderUpdate() + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() { return true; } @Override - public boolean lightUpdate() + public boolean lightUpdate() { return true; } @@ -523,7 +523,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { return null; } - + return MekanismUtils.size(itemType, getItemCount()); } @@ -534,7 +534,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { setStoredItemType(null, 0); } - + setItemCount(amount); } @@ -543,10 +543,10 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { itemType = type; cacheCount = amount; - + topStack = null; bottomStack = null; - + onInventoryChanged(); } diff --git a/common/mekanism/common/tile/TileEntityBoundingBlock.java b/common/mekanism/common/tile/TileEntityBoundingBlock.java index c352ed697..e3b5b74e5 100644 --- a/common/mekanism/common/tile/TileEntityBoundingBlock.java +++ b/common/mekanism/common/tile/TileEntityBoundingBlock.java @@ -18,7 +18,7 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork public int mainX; public int mainY; public int mainZ; - + public boolean prevPower; public void setMainLocation(int x, int y, int z) @@ -28,38 +28,38 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork mainX = x; mainY = y; mainZ = z; - + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + @Override public void validate() { super.validate(); - + if(worldObj.isRemote) { PacketHandler.sendPacket(Transmission.SERVER, new PacketDataRequest().setParams(Coord4D.get(this))); } } - + @Override public boolean canUpdate() { return false; } - + public void onNeighborChange(int id) { TileEntity tile = worldObj.getBlockTileEntity(mainX, mainY, mainZ); - + if(tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)tile; - + boolean power = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); - + if(prevPower != power) { if(power) @@ -69,15 +69,15 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork else { onNoPower(); } - + prevPower = power; PacketHandler.sendPacket(Transmission.CLIENTS_DIM, new PacketTileEntity().setParams(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), tileEntity.worldObj.provider.dimensionId); } } } - + public void onPower() {} - + public void onNoPower() {} @Override @@ -88,29 +88,29 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork mainZ = dataStream.readInt(); prevPower = dataStream.readBoolean(); } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - mainX = nbtTags.getInteger("mainX"); - mainY = nbtTags.getInteger("mainY"); - mainZ = nbtTags.getInteger("mainZ"); - prevPower = nbtTags.getBoolean("prevPower"); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("mainX", mainX); - nbtTags.setInteger("mainY", mainY); - nbtTags.setInteger("mainZ", mainZ); - nbtTags.setBoolean("prevPower", prevPower); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + mainX = nbtTags.getInteger("mainX"); + mainY = nbtTags.getInteger("mainY"); + mainZ = nbtTags.getInteger("mainZ"); + prevPower = nbtTags.getBoolean("prevPower"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("mainX", mainX); + nbtTags.setInteger("mainY", mainY); + nbtTags.setInteger("mainZ", mainZ); + nbtTags.setBoolean("prevPower", prevPower); + } + @Override public ArrayList getNetworkedData(ArrayList data) { @@ -118,7 +118,7 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork data.add(mainY); data.add(mainZ); data.add(prevPower); - + return data; } } diff --git a/common/mekanism/common/tile/TileEntityCardboardBox.java b/common/mekanism/common/tile/TileEntityCardboardBox.java index 2e0af6ffc..d0492d54a 100644 --- a/common/mekanism/common/tile/TileEntityCardboardBox.java +++ b/common/mekanism/common/tile/TileEntityCardboardBox.java @@ -7,29 +7,29 @@ import net.minecraft.tileentity.TileEntity; public class TileEntityCardboardBox extends TileEntity { public BlockData storedData; - + @Override public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); - + if(nbtTags.hasKey("storedData")) { storedData = BlockData.read(nbtTags.getCompoundTag("storedData")); } } - + @Override public void writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - + if(storedData != null) { nbtTags.setCompoundTag("storedData", storedData.write(new NBTTagCompound())); } } - + @Override public boolean canUpdate() { diff --git a/common/mekanism/common/tile/TileEntityChanceMachine.java b/common/mekanism/common/tile/TileEntityChanceMachine.java index 07b23ce6c..d46d7e35b 100644 --- a/common/mekanism/common/tile/TileEntityChanceMachine.java +++ b/common/mekanism/common/tile/TileEntityChanceMachine.java @@ -22,34 +22,34 @@ public class TileEntityChanceMachine extends TileEntityBasicMachine public TileEntityChanceMachine(String soundPath, String name, ResourceLocation location, double perTick, int ticksRequired, double maxEnergy) { super(soundPath, name, location, perTick, ticksRequired, maxEnergy); - + sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0})); sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1})); sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {2, 4})); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {3})); - + sideConfig = new byte[] {2, 1, 0, 0, 4, 3}; - + inventory = new ItemStack[5]; - + upgradeComponent = new TileComponentUpgrade(this, 3); ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3)); } - + @Override public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { ChargeUtils.discharge(1, this); - + if(canOperate() && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK)) { setActive(true); - + if((operatingTicks+1) < MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) { operatingTicks++; @@ -58,7 +58,7 @@ public class TileEntityChanceMachine extends TileEntityBasicMachine else if((operatingTicks+1) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) { operate(); - + operatingTicks = 0; electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK); } @@ -69,16 +69,16 @@ public class TileEntityChanceMachine extends TileEntityBasicMachine setActive(false); } } - + if(!canOperate()) { operatingTicks = 0; } - + prevEnergy = getEnergy(); } } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -94,98 +94,98 @@ public class TileEntityChanceMachine extends TileEntityBasicMachine { return ChargeUtils.canBeDischarged(itemstack); } - + return false; } @Override - public void operate() - { - ChanceOutput output = RecipeHandler.getChanceOutput(inventory[0], true, getRecipes()); + public void operate() + { + ChanceOutput output = RecipeHandler.getChanceOutput(inventory[0], true, getRecipes()); - if(inventory[0].stackSize <= 0) - { - inventory[0] = null; - } + if(inventory[0].stackSize <= 0) + { + inventory[0] = null; + } - if(output.hasPrimary()) - { - if(inventory[2] == null) - { - inventory[2] = output.primaryOutput; - } - else { - inventory[2].stackSize += output.primaryOutput.stackSize; - } - } - - if(output.hasSecondary() && output.checkSecondary()) - { - if(inventory[4] == null) - { - inventory[4] = output.secondaryOutput; - } - else { - inventory[4].stackSize += output.secondaryOutput.stackSize; - } - } + if(output.hasPrimary()) + { + if(inventory[2] == null) + { + inventory[2] = output.primaryOutput; + } + else { + inventory[2].stackSize += output.primaryOutput.stackSize; + } + } - onInventoryChanged(); - ejectorComponent.onOutput(); - } + if(output.hasSecondary() && output.checkSecondary()) + { + if(inventory[4] == null) + { + inventory[4] = output.secondaryOutput; + } + else { + inventory[4].stackSize += output.secondaryOutput.stackSize; + } + } + + onInventoryChanged(); + ejectorComponent.onOutput(); + } @Override - public boolean canOperate() - { + public boolean canOperate() + { if(inventory[0] == null) - { - return false; - } + { + return false; + } - ChanceOutput output = RecipeHandler.getChanceOutput(inventory[0], false, getRecipes()); + ChanceOutput output = RecipeHandler.getChanceOutput(inventory[0], false, getRecipes()); - if(output == null) - { - return false; - } + if(output == null) + { + return false; + } + + if(output.hasPrimary()) + { + if(inventory[2] != null) + { + if(!inventory[2].isItemEqual(output.primaryOutput)) + { + return false; + } + else { + if(inventory[2].stackSize + output.primaryOutput.stackSize > inventory[2].getMaxStackSize()) + { + return false; + } + } + } + } + + if(output.hasSecondary()) + { + if(inventory[4] != null) + { + if(!inventory[4].isItemEqual(output.secondaryOutput)) + { + return false; + } + else { + if(inventory[4].stackSize + output.secondaryOutput.stackSize > inventory[4].getMaxStackSize()) + { + return false; + } + } + } + } + + return true; + } - if(output.hasPrimary()) - { - if(inventory[2] != null) - { - if(!inventory[2].isItemEqual(output.primaryOutput)) - { - return false; - } - else { - if(inventory[2].stackSize + output.primaryOutput.stackSize > inventory[2].getMaxStackSize()) - { - return false; - } - } - } - } - - if(output.hasSecondary()) - { - if(inventory[4] != null) - { - if(!inventory[4].isItemEqual(output.secondaryOutput)) - { - return false; - } - else { - if(inventory[4].stackSize + output.secondaryOutput.stackSize > inventory[4].getMaxStackSize()) - { - return false; - } - } - } - } - - return true; - } - @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -197,7 +197,7 @@ public class TileEntityChanceMachine extends TileEntityBasicMachine { return true; } - + return false; } diff --git a/common/mekanism/common/tile/TileEntityChargepad.java b/common/mekanism/common/tile/TileEntityChargepad.java index dc1fe9292..c0dbb1b47 100644 --- a/common/mekanism/common/tile/TileEntityChargepad.java +++ b/common/mekanism/common/tile/TileEntityChargepad.java @@ -34,67 +34,67 @@ import com.google.common.io.ByteArrayDataInput; public class TileEntityChargepad extends TileEntityElectricBlock implements IActiveState, IHasSound { public boolean isActive; - + public boolean prevActive; - + public Random random = new Random(); - + public TileEntityChargepad() { super("Chargepad", MachineType.CHARGEPAD.baseEnergy); inventory = new ItemStack[0]; } - + @Override public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { isActive = false; - + List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+0.2, zCoord+1)); - + for(EntityLivingBase entity : entities) { if(entity instanceof EntityPlayer || entity instanceof EntityRobit) { isActive = true; } - + if(getEnergy() > 0) { if(entity instanceof EntityRobit) { EntityRobit robit = (EntityRobit)entity; - + double canGive = Math.min(getEnergy(), 1000); double toGive = Math.min(robit.MAX_ELECTRICITY-robit.getEnergy(), canGive); - + robit.setEnergy(robit.getEnergy() + toGive); setEnergy(getEnergy() - toGive); } else if(entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; - + double prevEnergy = getEnergy(); - + for(ItemStack itemstack : player.inventory.armorInventory) { chargeItemStack(itemstack); - + if(prevEnergy != getEnergy()) { break; } } - + for(ItemStack itemstack : player.inventory.mainInventory) { chargeItemStack(itemstack); - + if(prevEnergy != getEnergy()) { break; @@ -103,7 +103,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct } } } - + if(prevActive != isActive) { worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.1, zCoord + 0.5, "random.click", 0.3F, isActive ? 0.6F : 0.5F); @@ -112,14 +112,14 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct } else { Mekanism.proxy.registerSound(this); - + if(isActive) { worldObj.spawnParticle("reddust", xCoord+random.nextDouble(), yCoord+0.15, zCoord+random.nextDouble(), 0, 0, 0); } } } - + public void chargeItemStack(ItemStack itemstack) { if(itemstack != null) @@ -136,67 +136,67 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct else if(itemstack.getItem() instanceof IEnergyContainerItem) { IEnergyContainerItem item = (IEnergyContainerItem)itemstack.getItem(); - + int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemstack)), item.getMaxEnergyStored(itemstack) - item.getEnergyStored(itemstack))); int toTransfer = (int)Math.round(Math.min(itemEnergy, (getEnergy()*Mekanism.TO_TE))); - + setEnergy(getEnergy() - (item.receiveEnergy(itemstack, toTransfer, false)*Mekanism.FROM_TE)); } } } - + @Override public void invalidate() { super.invalidate(); - + if(worldObj.isRemote) { Mekanism.proxy.unregisterSound(this); } } - + @Override protected EnumSet getConsumingSides() { return EnumSet.of(ForgeDirection.DOWN, ForgeDirection.getOrientation(facing).getOpposite()); } - + @Override public boolean getActive() { return isActive; } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(prevActive != active) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - } - - prevActive = active; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - } - + public void setActive(boolean active) + { + isActive = active; + + if(prevActive != active) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + } + + prevActive = active; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + } + @Override public void handlePacketData(ByteArrayDataInput dataStream) { @@ -204,7 +204,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct isActive = dataStream.readBoolean(); MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { @@ -212,7 +212,7 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct data.add(isActive); return data; } - + @Override public boolean canSetFacing(int side) { @@ -220,19 +220,19 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct } @Override - public String getSoundPath() + public String getSoundPath() { return "Chargepad.ogg"; } @Override - public float getVolumeMultiplier() + public float getVolumeMultiplier() { return 0.4F; } - + @Override - public boolean renderUpdate() + public boolean renderUpdate() { return false; } diff --git a/common/mekanism/common/tile/TileEntityChemicalCrystalizer.java b/common/mekanism/common/tile/TileEntityChemicalCrystalizer.java index 3ff1208b9..b7d39d193 100644 --- a/common/mekanism/common/tile/TileEntityChemicalCrystalizer.java +++ b/common/mekanism/common/tile/TileEntityChemicalCrystalizer.java @@ -38,67 +38,67 @@ import net.minecraftforge.fluids.FluidRegistry; import com.google.common.io.ByteArrayDataInput; public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IInvConfiguration -{ +{ public static final int MAX_GAS = 10000; public static final int MAX_FLUID = 10000; - + public byte[] sideConfig = new byte[] {0, 3, 0, 0, 1, 2}; - + public ArrayList sideOutputs = new ArrayList(); - + public GasTank inputTank = new GasTank(MAX_GAS); - + public static int WATER_USAGE = 5; - + public int updateDelay; - + public int gasOutput = 16; - + public int operatingTicks; - + public int TICKS_REQUIRED = 200; - + public boolean isActive; - + public boolean clientActive; - + public double prevEnergy; - + public float spinSpeed; - + public float spin; - + public final double ENERGY_USAGE = Mekanism.chemicalCrystalizerUsage; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileComponentEjector ejectorComponent; - + public TileEntityChemicalCrystalizer() { super("ChemicalCrystalizer", MachineType.CHEMICAL_CRYSTALIZER.baseEnergy); - + sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {0})); sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {1})); sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {2})); - + inventory = new ItemStack[3]; ejectorComponent = new TileComponentEjector(this, sideOutputs.get(1)); } - + @Override public void onUpdate() { if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -106,30 +106,30 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + ChargeUtils.discharge(2, this); - + if(inventory[0] != null && (inputTank.getGas() == null || inputTank.getStored() < inputTank.getMaxGas())) { inputTank.receive(GasTransmission.removeGas(inventory[0], null, inputTank.getNeeded()), true); } - + if(canOperate() && MekanismUtils.canFunction(this) && getEnergy() >= ENERGY_USAGE) { setActive(true); - + if((operatingTicks+1) < TICKS_REQUIRED) { operatingTicks++; @@ -138,7 +138,7 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple else if((operatingTicks+1) >= TICKS_REQUIRED) { operate(); - + operatingTicks = 0; setEnergy(getEnergy() - ENERGY_USAGE); } @@ -149,35 +149,35 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple setActive(false); } } - + if(!canOperate()) { operatingTicks = 0; } - + prevEnergy = getEnergy(); } } - + public boolean canOperate() { if(inputTank.getGas() == null) { return false; } - + ItemStack itemstack = RecipeHandler.getChemicalCrystalizerOutput(inputTank, false); - + if(itemstack == null) { return false; } - + if(inventory[1] == null) { return true; } - + if(!inventory[1].isItemEqual(itemstack)) { return false; @@ -186,55 +186,55 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple return inventory[1].stackSize + itemstack.stackSize <= inventory[1].getMaxStackSize(); } } - - public void operate() - { - ItemStack itemstack = RecipeHandler.getChemicalCrystalizerOutput(inputTank, true); - if(inventory[1] == null) - { - inventory[1] = itemstack; - } - else { - inventory[1].stackSize += itemstack.stackSize; - } + public void operate() + { + ItemStack itemstack = RecipeHandler.getChemicalCrystalizerOutput(inputTank, true); + + if(inventory[1] == null) + { + inventory[1] = itemstack; + } + else { + inventory[1].stackSize += itemstack.stackSize; + } + + onInventoryChanged(); + ejectorComponent.onOutput(); + } - onInventoryChanged(); - ejectorComponent.onOutput(); - } - @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { inputTank.setGas(null); } - + for(EntityPlayer player : playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), player); } - + return; } - + super.handlePacketData(dataStream); - + isActive = dataStream.readBoolean(); operatingTicks = dataStream.readInt(); - + for(int i = 0; i < 6; i++) { sideConfig[i] = dataStream.readByte(); } - + controlType = RedstoneControl.values()[dataStream.readInt()]; - + if(dataStream.readBoolean()) { inputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -242,21 +242,21 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple else { inputTank.setGas(null); } - - + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(operatingTicks); data.add(sideConfig); data.add(controlType.ordinal()); - + if(inputTank.getGas() != null) { data.add(true); @@ -266,96 +266,96 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple else { data.add(false); } - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - operatingTicks = nbtTags.getInteger("operatingTicks"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - inputTank.read(nbtTags.getCompoundTag("rightTank")); - - if(nbtTags.hasKey("sideDataStored")) - { - for(int i = 0; i < 6; i++) - { - sideConfig[i] = nbtTags.getByte("config"+i); - } - } - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setInteger("controlType", controlType.ordinal()); - - nbtTags.setCompoundTag("rightTank", inputTank.write(new NBTTagCompound())); - - nbtTags.setBoolean("sideDataStored", true); - - for(int i = 0; i < 6; i++) - { - nbtTags.setByte("config"+i, sideConfig[i]); - } - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + operatingTicks = nbtTags.getInteger("operatingTicks"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + inputTank.read(nbtTags.getCompoundTag("rightTank")); + + if(nbtTags.hasKey("sideDataStored")) + { + for(int i = 0; i < 6; i++) + { + sideConfig[i] = nbtTags.getByte("config"+i); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setInteger("controlType", controlType.ordinal()); + + nbtTags.setCompoundTag("rightTank", inputTank.write(new NBTTagCompound())); + + nbtTags.setBoolean("sideDataStored", true); + + for(int i = 0; i < 6; i++) + { + nbtTags.setByte("config"+i, sideConfig[i]); + } + } + @Override public boolean canSetFacing(int i) { return i != 0 && i != 1; } - + public int getScaledInputGasLevel(int i) { return inputTank != null ? inputTank.getStored()*i / MAX_GAS : 0; } - + public int getScaledProgress(int i) - { + { return operatingTicks*i / TICKS_REQUIRED; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return false; + } + + @Override + public boolean lightUpdate() + { + return true; + } @Override public boolean canTubeConnect(ForgeDirection side) @@ -368,15 +368,15 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple { return side == MekanismUtils.getLeft(facing) && inputTank.canReceive(type); } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); @@ -389,7 +389,7 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple { return inputTank.receive(stack, true); } - + return 0; } @@ -404,7 +404,7 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple { return false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -416,10 +416,10 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple { return ChargeUtils.canBeDischarged(itemstack); } - + return false; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -435,10 +435,10 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple { return ChargeUtils.canBeOutputted(itemstack, false); } - + return false; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -454,7 +454,7 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple { return new int[2]; } - + return InventoryUtils.EMPTY; } @@ -475,13 +475,13 @@ public class TileEntityChemicalCrystalizer extends TileEntityElectricBlock imple { return sideOutputs; } - + @Override public byte[] getConfiguration() { return sideConfig; } - + @Override public int getOrientation() { diff --git a/common/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java b/common/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index 25d39801d..eddf721c3 100644 --- a/common/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/common/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -35,46 +35,46 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc { public GasTank injectTank = new GasTank(MAX_GAS); public GasTank outputTank = new GasTank(MAX_GAS); - + public static final int MAX_GAS = 10000; - + public static final int INJECT_USAGE = 1; - + public int updateDelay; - + public int gasOutput = 16; - + public boolean isActive; - + public boolean clientActive; - + public double prevEnergy; - + public int operatingTicks = 0; - + public int TICKS_REQUIRED = 100; - + public final double ENERGY_USAGE = Mekanism.chemicalDissolutionChamberUsage; - + public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileEntityChemicalDissolutionChamber() { super("ChemicalDissolutionChamber", MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy); inventory = new ItemStack[4]; } - + @Override public void onUpdate() { if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -82,38 +82,38 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + ChargeUtils.discharge(3, this); - + if(inventory[0] != null && (injectTank.getGas() == null || injectTank.getStored() < injectTank.getMaxGas())) { injectTank.receive(GasTransmission.removeGas(inventory[0], GasRegistry.getGas("sulfuricAcid"), injectTank.getNeeded()), true); } - + if(inventory[2] != null && outputTank.getGas() != null) { outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true); } - + boolean changed = false; - + if(canOperate() && getEnergy() >= ENERGY_USAGE && injectTank.getStored() >= INJECT_USAGE && MekanismUtils.canFunction(this)) { setActive(true); setEnergy(getEnergy() - ENERGY_USAGE); - + if(operatingTicks < TICKS_REQUIRED) { operatingTicks++; @@ -121,17 +121,17 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc } else { GasStack stack = RecipeHandler.getItemToGasOutput(inventory[1], true, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()); - + outputTank.receive(stack, true); injectTank.draw(INJECT_USAGE, true); - + operatingTicks = 0; - + if(inventory[1].stackSize <= 0) { inventory[1] = null; } - + onInventoryChanged(); } } @@ -142,21 +142,21 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc setActive(false); } } - + if(changed && !canOperate()) { operatingTicks = 0; } - + prevEnergy = getEnergy(); - + if(outputTank.getGas() != null) { GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput)); outputTank.draw(GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getRight(facing)), true); - + TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); - + if(tileEntity instanceof IGasHandler) { if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getRight(facing).getOpposite(), outputTank.getGas().getGas())) @@ -167,7 +167,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc } } } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -179,10 +179,10 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc { return ChargeUtils.canBeDischarged(itemstack); } - + return false; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -190,10 +190,10 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc { return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, null); } - + return false; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -209,41 +209,41 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc { return new int[] {2}; } - + return InventoryUtils.EMPTY; } - + public int getScaledProgress(int i) - { + { return operatingTicks*i / TICKS_REQUIRED; } - + public boolean canOperate() { if(inventory[1] == null) { return false; } - + GasStack stack = RecipeHandler.getItemToGasOutput(inventory[1], false, Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get()); - + if(stack == null || (outputTank.getGas() != null && (outputTank.getGas().getGas() != stack.getGas() || outputTank.getNeeded() < stack.amount))) { return false; } - + return true; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; operatingTicks = dataStream.readInt(); - + if(dataStream.readBoolean()) { injectTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -251,7 +251,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc else { injectTank.setGas(null); } - + if(dataStream.readBoolean()) { outputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -259,19 +259,19 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc else { outputTank.setGas(null); } - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(controlType.ordinal()); data.add(operatingTicks); - + if(injectTank.getGas() != null) { data.add(true); @@ -281,7 +281,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc else { data.add(false); } - + if(outputTank.getGas() != null) { data.add(true); @@ -291,101 +291,101 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc else { data.add(false); } - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - operatingTicks = nbtTags.getInteger("operatingTicks"); - injectTank.read(nbtTags.getCompoundTag("injectTank")); - outputTank.read(nbtTags.getCompoundTag("gasTank")); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setCompoundTag("injectTank", injectTank.write(new NBTTagCompound())); - nbtTags.setCompoundTag("gasTank", outputTank.write(new NBTTagCompound())); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + operatingTicks = nbtTags.getInteger("operatingTicks"); + injectTank.read(nbtTags.getCompoundTag("injectTank")); + outputTank.read(nbtTags.getCompoundTag("gasTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setCompoundTag("injectTank", injectTank.write(new NBTTagCompound())); + nbtTags.setCompoundTag("gasTank", outputTank.write(new NBTTagCompound())); + } + @Override public boolean canSetFacing(int i) { return i != 0 && i != 1; } - + public int getScaledInjectGasLevel(int i) { return injectTank.getGas() != null ? injectTank.getStored()*i / MAX_GAS : 0; } - + public int getScaledOutputGasLevel(int i) { return outputTank.getGas() != null ? outputTank.getStored()*i / MAX_GAS : 0; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return false; + } + + @Override + public boolean lightUpdate() + { + return true; + } @Override public boolean canTubeConnect(ForgeDirection side) { return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing); } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); } - + @Override public String getSoundPath() { @@ -405,7 +405,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc { return injectTank.receive(stack, true); } - + return 0; } diff --git a/common/mekanism/common/tile/TileEntityChemicalInfuser.java b/common/mekanism/common/tile/TileEntityChemicalInfuser.java index 503da3962..c5512cdf7 100644 --- a/common/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/common/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -36,41 +36,41 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement public GasTank leftTank = new GasTank(MAX_GAS); public GasTank rightTank = new GasTank(MAX_GAS); public GasTank centerTank = new GasTank(MAX_GAS); - + public static final int MAX_GAS = 10000; - + public int updateDelay; - + public int gasOutput = 16; - + public boolean isActive; - + public boolean clientActive; - + public double prevEnergy; - + public final double ENERGY_USAGE = Mekanism.chemicalInfuserUsage; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileEntityChemicalInfuser() { super("ChemicalInfuser", MachineType.CHEMICAL_INFUSER.baseEnergy); inventory = new ItemStack[4]; } - + @Override public void onUpdate() { if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -78,43 +78,43 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + ChargeUtils.discharge(3, this); - + if(inventory[0] != null && (leftTank.getGas() == null || leftTank.getStored() < leftTank.getMaxGas())) { leftTank.receive(GasTransmission.removeGas(inventory[0], null, leftTank.getNeeded()), true); } - + if(inventory[1] != null && (rightTank.getGas() == null || rightTank.getStored() < rightTank.getMaxGas())) { rightTank.receive(GasTransmission.removeGas(inventory[1], null, rightTank.getNeeded()), true); } - + if(inventory[2] != null && centerTank.getGas() != null) { centerTank.draw(GasTransmission.addGas(inventory[2], centerTank.getGas()), true); } - + if(canOperate() && getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this)) { setActive(true); GasStack stack = RecipeHandler.getChemicalInfuserOutput(leftTank, rightTank, true); - + centerTank.receive(stack, true); - + setEnergy(getEnergy() - ENERGY_USAGE); } else { @@ -123,14 +123,14 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement setActive(false); } } - + if(centerTank.getGas() != null) { GasStack toSend = new GasStack(centerTank.getGas().getGas(), Math.min(centerTank.getStored(), gasOutput)); centerTank.draw(GasTransmission.emitGasToNetwork(toSend, this, ForgeDirection.getOrientation(facing)), true); - + TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj); - + if(tileEntity instanceof IGasHandler) { if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), centerTank.getGas().getGas())) @@ -139,40 +139,40 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement } } } - + prevEnergy = getEnergy(); } } - + public boolean canOperate() { if(leftTank.getGas() == null || rightTank.getGas() == null || centerTank.getNeeded() == 0) { return false; } - + GasStack out = RecipeHandler.getChemicalInfuserOutput(leftTank, rightTank, false); - + if(out == null || centerTank.getGas() != null && centerTank.getGas().getGas() != out.getGas()) { return false; } - + if(centerTank.getNeeded() < out.amount) { return false; } - + return true; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { leftTank.setGas(null); @@ -181,20 +181,20 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { rightTank.setGas(null); } - + for(EntityPlayer player : playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), player); } - + return; } - + super.handlePacketData(dataStream); - + isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - + if(dataStream.readBoolean()) { leftTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -202,7 +202,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement else { leftTank.setGas(null); } - + if(dataStream.readBoolean()) { rightTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -210,7 +210,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement else { rightTank.setGas(null); } - + if(dataStream.readBoolean()) { centerTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -218,19 +218,19 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement else { centerTank.setGas(null); } - - + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(controlType.ordinal()); - + if(leftTank.getGas() != null) { data.add(true); @@ -240,7 +240,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement else { data.add(false); } - + if(rightTank.getGas() != null) { data.add(true); @@ -250,7 +250,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement else { data.add(false); } - + if(centerTank.getGas() != null) { data.add(true); @@ -260,42 +260,42 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement else { data.add(false); } - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - leftTank.read(nbtTags.getCompoundTag("leftTank")); - rightTank.read(nbtTags.getCompoundTag("rightTank")); - centerTank.read(nbtTags.getCompoundTag("centerTank")); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - - nbtTags.setCompoundTag("leftTank", leftTank.write(new NBTTagCompound())); - nbtTags.setCompoundTag("rightTank", rightTank.write(new NBTTagCompound())); - nbtTags.setCompoundTag("centerTank", centerTank.write(new NBTTagCompound())); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + leftTank.read(nbtTags.getCompoundTag("leftTank")); + rightTank.read(nbtTags.getCompoundTag("rightTank")); + centerTank.read(nbtTags.getCompoundTag("centerTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + + nbtTags.setCompoundTag("leftTank", leftTank.write(new NBTTagCompound())); + nbtTags.setCompoundTag("rightTank", rightTank.write(new NBTTagCompound())); + nbtTags.setCompoundTag("centerTank", centerTank.write(new NBTTagCompound())); + } + @Override public boolean canSetFacing(int i) { return i != 0 && i != 1; } - + public GasTank getTank(ForgeDirection side) { if(side == MekanismUtils.getLeft(facing)) @@ -310,56 +310,56 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return centerTank; } - + return null; } - + public int getScaledLeftGasLevel(int i) { return leftTank != null ? leftTank.getStored()*i / MAX_GAS : 0; } - + public int getScaledRightGasLevel(int i) { return rightTank != null ? rightTank.getStored()*i / MAX_GAS : 0; } - + public int getScaledCenterGasLevel(int i) { return centerTank != null ? centerTank.getStored()*i / MAX_GAS : 0; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return false; + } + + @Override + public boolean lightUpdate() + { + return true; + } @Override public boolean canTubeConnect(ForgeDirection side) @@ -372,15 +372,15 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return getTank(side) != null && getTank(side) != centerTank ? getTank(side).canReceive(type) : false; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); @@ -393,7 +393,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return getTank(side).receive(stack, true); } - + return 0; } @@ -404,7 +404,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return getTank(side).draw(amount, true); } - + return null; } @@ -413,7 +413,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return getTank(side) != null && getTank(side) == centerTank ? getTank(side).canDraw(type) : false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -421,10 +421,10 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return ChargeUtils.canBeDischarged(itemstack); } - + return false; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -440,10 +440,10 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return ChargeUtils.canBeOutputted(itemstack, false); } - + return false; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -463,7 +463,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { return new int[3]; } - + return InventoryUtils.EMPTY; } diff --git a/common/mekanism/common/tile/TileEntityChemicalInjectionChamber.java b/common/mekanism/common/tile/TileEntityChemicalInjectionChamber.java index 8c36de8b3..6da679821 100644 --- a/common/mekanism/common/tile/TileEntityChemicalInjectionChamber.java +++ b/common/mekanism/common/tile/TileEntityChemicalInjectionChamber.java @@ -23,31 +23,31 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr { super("ChemicalInjectionChamber.ogg", "ChemicalInjectionChamber", new ResourceLocation("mekanism", "gui/GuiChemicalInjectionChamber.png"), Mekanism.chemicalInjectionChamberUsage, 1, 200, MachineType.CHEMICAL_INJECTION_CHAMBER.baseEnergy); } - + @Override public Map getRecipes() { return Recipe.CHEMICAL_INJECTION_CHAMBER.get(); } - + @Override public GasStack getItemGas(ItemStack itemstack) { if(MekanismUtils.getOreDictName(itemstack).contains("dustSulfur")) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 2); if(itemstack.itemID == Mekanism.GasTank.blockID && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && isValidGas(((IGasItem)itemstack.getItem()).getGas(itemstack).getGas())) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); - + return null; } @Override - public int receiveGas(ForgeDirection side, GasStack stack) + public int receiveGas(ForgeDirection side, GasStack stack) { if(isValidGas(stack.getGas())) { return gasTank.receive(stack, true); } - + return 0; } @@ -56,23 +56,23 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr { return isValidGas(type); } - + @Override public void handleSecondaryFuel() { if(inventory[1] != null && gasTank.getNeeded() > 0 && inventory[1].getItem() instanceof IGasItem) { GasStack gas = ((IGasItem)inventory[1].getItem()).getGas(inventory[1]); - + if(gas != null && isValidGas(gas.getGas())) { GasStack removed = GasTransmission.removeGas(inventory[1], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, gasTank.getNeeded()); gasTank.receive(removed, true); } - + return; } - + super.handleSecondaryFuel(); } @@ -81,7 +81,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr { return true; } - + @Override public boolean isValidGas(Gas gas) { diff --git a/common/mekanism/common/tile/TileEntityChemicalOxidizer.java b/common/mekanism/common/tile/TileEntityChemicalOxidizer.java index 84a1fb066..7d15f71d5 100644 --- a/common/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/common/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -33,44 +33,44 @@ import com.google.common.io.ByteArrayDataInput; public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound { public GasTank gasTank = new GasTank(MAX_GAS); - + public static final int MAX_GAS = 10000; - + public int updateDelay; - + public int gasOutput = 16; - + public boolean isActive; - + public boolean clientActive; - + public double prevEnergy; - + public int operatingTicks = 0; - + public int TICKS_REQUIRED = 100; - + public final double ENERGY_USAGE = Mekanism.rotaryCondensentratorUsage; - + public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileEntityChemicalOxidizer() { super("ChemicalOxidizer", MachineType.CHEMICAL_OXIDIZER.baseEnergy); inventory = new ItemStack[3]; } - + @Override public void onUpdate() { if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -78,46 +78,46 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + ChargeUtils.discharge(1, this); - + if(inventory[2] != null && gasTank.getGas() != null) { gasTank.draw(GasTransmission.addGas(inventory[2], gasTank.getGas()), true); } - + if(canOperate() && getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this)) { setActive(true); setEnergy(getEnergy() - ENERGY_USAGE); - + if(operatingTicks < TICKS_REQUIRED) { operatingTicks++; } else { GasStack stack = RecipeHandler.getItemToGasOutput(inventory[0], true, Recipe.CHEMICAL_OXIDIZER.get()); - + gasTank.receive(stack, true); operatingTicks = 0; - + if(inventory[0].stackSize <= 0) { inventory[0] = null; } - + onInventoryChanged(); } } @@ -127,16 +127,16 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen setActive(false); } } - + prevEnergy = getEnergy(); - + if(gasTank.getGas() != null) { GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), gasOutput)); gasTank.draw(GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getRight(facing)), true); - + TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); - + if(tileEntity instanceof IGasHandler) { if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getRight(facing).getOpposite(), gasTank.getGas().getGas())) @@ -147,7 +147,7 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen } } } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -159,10 +159,10 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen { return ChargeUtils.canBeDischarged(itemstack); } - + return false; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -170,10 +170,10 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen { return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, null); } - + return false; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -189,41 +189,41 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen { return new int[] {2}; } - + return InventoryUtils.EMPTY; } - + public int getScaledProgress(int i) - { + { return operatingTicks*i / TICKS_REQUIRED; } - + public boolean canOperate() { if(inventory[0] == null) { return false; } - + GasStack stack = RecipeHandler.getItemToGasOutput(inventory[0], false, Recipe.CHEMICAL_OXIDIZER.get()); - + if(stack == null || (gasTank.getGas() != null && (gasTank.getGas().getGas() != stack.getGas() || gasTank.getNeeded() < stack.amount))) { return false; } - + return true; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; operatingTicks = dataStream.readInt(); - + if(dataStream.readBoolean()) { gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -231,19 +231,19 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen else { gasTank.setGas(null); } - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(controlType.ordinal()); data.add(operatingTicks); - + if(gasTank.getGas() != null) { data.add(true); @@ -253,94 +253,94 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen else { data.add(false); } - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - operatingTicks = nbtTags.getInteger("operatingTicks"); - gasTank.read(nbtTags.getCompoundTag("gasTank")); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + operatingTicks = nbtTags.getInteger("operatingTicks"); + gasTank.read(nbtTags.getCompoundTag("gasTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); + } + @Override public boolean canSetFacing(int i) { return i != 0 && i != 1; } - + public int getScaledGasLevel(int i) { return gasTank.getGas() != null ? gasTank.getStored()*i / MAX_GAS : 0; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return false; + } + + @Override + public boolean lightUpdate() + { + return true; + } @Override public boolean canTubeConnect(ForgeDirection side) { return side == MekanismUtils.getRight(facing); } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); } - + @Override public String getSoundPath() { diff --git a/common/mekanism/common/tile/TileEntityChemicalWasher.java b/common/mekanism/common/tile/TileEntityChemicalWasher.java index 477c456cf..98d7c4049 100644 --- a/common/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/common/mekanism/common/tile/TileEntityChemicalWasher.java @@ -44,44 +44,44 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements public FluidTank fluidTank = new FluidTank(MAX_FLUID); public GasTank inputTank = new GasTank(MAX_GAS); public GasTank outputTank = new GasTank(MAX_GAS); - + public static final int MAX_GAS = 10000; public static final int MAX_FLUID = 10000; - + public static int WATER_USAGE = 5; - + public int updateDelay; - + public int gasOutput = 16; - + public boolean isActive; - + public boolean clientActive; - + public double prevEnergy; - + public final double ENERGY_USAGE = Mekanism.chemicalWasherUsage; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileEntityChemicalWasher() { super("ChemicalWasher", MachineType.CHEMICAL_WASHER.baseEnergy); inventory = new ItemStack[4]; } - + @Override public void onUpdate() { if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -89,35 +89,35 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + ChargeUtils.discharge(3, this); manageBuckets(); - + if(inventory[2] != null && outputTank.getGas() != null) { outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true); } - + if(canOperate() && getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this)) { setActive(true); GasStack stack = RecipeHandler.getChemicalWasherOutput(inputTank, true); - + outputTank.receive(stack, true); fluidTank.drain(WATER_USAGE, true); - + setEnergy(getEnergy() - ENERGY_USAGE); } else { @@ -126,14 +126,14 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements setActive(false); } } - + if(outputTank.getGas() != null) { GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput)); outputTank.draw(GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getRight(facing)), true); - + TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); - + if(tileEntity instanceof IGasHandler) { if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getRight(facing).getOpposite(), outputTank.getGas().getGas())) @@ -142,56 +142,56 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements } } } - + prevEnergy = getEnergy(); } } - + public boolean canOperate() { if(fluidTank.getFluidAmount() < WATER_USAGE || inputTank.getGas() == null || outputTank.getNeeded() == 0) { return false; } - + GasStack out = RecipeHandler.getChemicalWasherOutput(inputTank, false); - + if(out == null || (outputTank.getGas() != null && outputTank.getGas().getGas() != out.getGas())) { return false; } - + if(outputTank.getNeeded() < out.amount) { return false; } - + return true; } - + private void manageBuckets() { if(FluidContainerRegistry.isFilledContainer(inventory[0])) { FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - + if((fluidTank.getFluid() == null && itemFluid.amount <= MAX_FLUID) || fluidTank.getFluid().amount+itemFluid.amount <= MAX_FLUID) { if(itemFluid.getFluid() != FluidRegistry.WATER || (fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid))) { return; } - + ItemStack containerItem = inventory[0].getItem().getContainerItemStack(inventory[0]); - + boolean filled = false; - + if(containerItem != null) { if(inventory[1] == null || (inventory[1].isItemEqual(containerItem) && inventory[1].stackSize+1 <= containerItem.getMaxStackSize())) { inventory[0] = null; - + if(inventory[1] == null) { inventory[1] = containerItem; @@ -199,21 +199,21 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements else { inventory[1].stackSize++; } - + filled = true; } } - else { + else { inventory[0].stackSize--; - + if(inventory[0].stackSize == 0) { inventory[0] = null; } - + filled = true; } - + if(filled) { fluidTank.fill(itemFluid, true); @@ -221,32 +221,32 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements } } } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { inputTank.setGas(null); } - + for(EntityPlayer player : playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), player); } - + return; } - + super.handlePacketData(dataStream); - + isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - + if(dataStream.readBoolean()) { fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt())); @@ -254,7 +254,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements else { fluidTank.setFluid(null); } - + if(dataStream.readBoolean()) { inputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -262,7 +262,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements else { inputTank.setGas(null); } - + if(dataStream.readBoolean()) { outputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -270,19 +270,19 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements else { outputTank.setGas(null); } - - + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(controlType.ordinal()); - + if(fluidTank.getFluid() != null) { data.add(true); @@ -292,7 +292,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements else { data.add(false); } - + if(inputTank.getGas() != null) { data.add(true); @@ -302,7 +302,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements else { data.add(false); } - + if(outputTank.getGas() != null) { data.add(true); @@ -312,42 +312,42 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements else { data.add(false); } - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - fluidTank.readFromNBT(nbtTags.getCompoundTag("leftTank")); - inputTank.read(nbtTags.getCompoundTag("rightTank")); - outputTank.read(nbtTags.getCompoundTag("centerTank")); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - - nbtTags.setCompoundTag("leftTank", fluidTank.writeToNBT(new NBTTagCompound())); - nbtTags.setCompoundTag("rightTank", inputTank.write(new NBTTagCompound())); - nbtTags.setCompoundTag("centerTank", outputTank.write(new NBTTagCompound())); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + fluidTank.readFromNBT(nbtTags.getCompoundTag("leftTank")); + inputTank.read(nbtTags.getCompoundTag("rightTank")); + outputTank.read(nbtTags.getCompoundTag("centerTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + + nbtTags.setCompoundTag("leftTank", fluidTank.writeToNBT(new NBTTagCompound())); + nbtTags.setCompoundTag("rightTank", inputTank.write(new NBTTagCompound())); + nbtTags.setCompoundTag("centerTank", outputTank.write(new NBTTagCompound())); + } + @Override public boolean canSetFacing(int i) { return i != 0 && i != 1; } - + public GasTank getTank(ForgeDirection side) { if(side == MekanismUtils.getLeft(facing)) @@ -358,56 +358,56 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return outputTank; } - + return null; } - + public int getScaledFluidLevel(int i) { return fluidTank != null ? fluidTank.getFluidAmount()*i / MAX_FLUID : 0; } - + public int getScaledInputGasLevel(int i) { return inputTank != null ? inputTank.getStored()*i / MAX_GAS : 0; } - + public int getScaledOutputGasLevel(int i) { return outputTank != null ? outputTank.getStored()*i / MAX_GAS : 0; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return false; + } + + @Override + public boolean lightUpdate() + { + return true; + } @Override public boolean canTubeConnect(ForgeDirection side) @@ -420,15 +420,15 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return getTank(side) != null && getTank(side) != outputTank ? getTank(side).canReceive(type) : false; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); @@ -441,7 +441,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return getTank(side).receive(stack, true); } - + return 0; } @@ -452,7 +452,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return getTank(side).draw(amount, true); } - + return null; } @@ -461,7 +461,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return getTank(side) == outputTank ? getTank(side).canDraw(type) : false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -473,10 +473,10 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return ChargeUtils.canBeDischarged(itemstack); } - + return false; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -488,10 +488,10 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return ChargeUtils.canBeOutputted(itemstack, false); } - + return false; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -507,7 +507,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return new int[2]; } - + return InventoryUtils.EMPTY; } @@ -530,7 +530,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return fluidTank.fill(resource, doFill); } - + return 0; } @@ -565,7 +565,7 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements { return new FluidTankInfo[] {fluidTank.getInfo()}; } - + return PipeUtils.EMPTY; } } diff --git a/common/mekanism/common/tile/TileEntityCombiner.java b/common/mekanism/common/tile/TileEntityCombiner.java index fbcd8372b..4f4b623a9 100644 --- a/common/mekanism/common/tile/TileEntityCombiner.java +++ b/common/mekanism/common/tile/TileEntityCombiner.java @@ -19,13 +19,13 @@ public class TileEntityCombiner extends TileEntityAdvancedElectricMachine { super("Combiner.ogg", "Combiner", new ResourceLocation("mekanism", "gui/GuiCombiner.png"), Mekanism.combinerUsage, 1, 200, MachineType.COMBINER.baseEnergy); } - + @Override public Map getRecipes() { return Recipe.COMBINER.get(); } - + @Override public GasStack getItemGas(ItemStack itemstack) { @@ -33,10 +33,10 @@ public class TileEntityCombiner extends TileEntityAdvancedElectricMachine { return new GasStack(GasRegistry.getGas("liquidStone"), 200); } - + return null; } - + @Override public boolean isValidGas(Gas gas) { diff --git a/common/mekanism/common/tile/TileEntityContainerBlock.java b/common/mekanism/common/tile/TileEntityContainerBlock.java index f4b43385d..c66ee7be9 100644 --- a/common/mekanism/common/tile/TileEntityContainerBlock.java +++ b/common/mekanism/common/tile/TileEntityContainerBlock.java @@ -13,10 +13,10 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl { /** The inventory slot itemstacks used by this block. */ public ItemStack[] inventory; - + /** The full name of this machine. */ public String fullName; - + /** * A simple tile entity with a container and facing state. * @param name - full name of this tile entity @@ -25,144 +25,144 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl { fullName = name; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - if(handleInventory()) - { - NBTTagList tagList = nbtTags.getTagList("Items"); - inventory = new ItemStack[getSizeInventory()]; - - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); - - if(slotID >= 0 && slotID < getSizeInventory()) - { - setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); - } - } - } - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - if(handleInventory()) - { - NBTTagList tagList = new NBTTagList(); - - for(int slotCount = 0; slotCount < getSizeInventory(); slotCount++) - { - if(getStackInSlot(slotCount) != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - getStackInSlot(slotCount).writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } - - nbtTags.setTag("Items", tagList); - } - } + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + if(handleInventory()) + { + NBTTagList tagList = nbtTags.getTagList("Items"); + inventory = new ItemStack[getSizeInventory()]; + + for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) + { + NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); + + if(slotID >= 0 && slotID < getSizeInventory()) + { + setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); + } + } + } + } @Override - public int getSizeInventory() + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + if(handleInventory()) + { + NBTTagList tagList = new NBTTagList(); + + for(int slotCount = 0; slotCount < getSizeInventory(); slotCount++) + { + if(getStackInSlot(slotCount) != null) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte)slotCount); + getStackInSlot(slotCount).writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + nbtTags.setTag("Items", tagList); + } + } + + @Override + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotID) + public ItemStack getStackInSlot(int slotID) { return inventory[slotID]; } @Override - public ItemStack decrStackSize(int slotID, int amount) - { - if(getStackInSlot(slotID) != null) - { - ItemStack tempStack; + public ItemStack decrStackSize(int slotID, int amount) + { + if(getStackInSlot(slotID) != null) + { + ItemStack tempStack; - if(getStackInSlot(slotID).stackSize <= amount) - { - tempStack = getStackInSlot(slotID); - setInventorySlotContents(slotID, null); - return tempStack; - } - else { - tempStack = getStackInSlot(slotID).splitStack(amount); + if(getStackInSlot(slotID).stackSize <= amount) + { + tempStack = getStackInSlot(slotID); + setInventorySlotContents(slotID, null); + return tempStack; + } + else { + tempStack = getStackInSlot(slotID).splitStack(amount); - if(getStackInSlot(slotID).stackSize == 0) - { - setInventorySlotContents(slotID, null); - } + if(getStackInSlot(slotID).stackSize == 0) + { + setInventorySlotContents(slotID, null); + } - return tempStack; - } - } - else { - return null; - } - } + return tempStack; + } + } + else { + return null; + } + } @Override - public ItemStack getStackInSlotOnClosing(int slotID) - { - if(getStackInSlot(slotID) != null) - { - ItemStack tempStack = getStackInSlot(slotID); - setInventorySlotContents(slotID, null); - return tempStack; - } - else { - return null; - } - } + public ItemStack getStackInSlotOnClosing(int slotID) + { + if(getStackInSlot(slotID) != null) + { + ItemStack tempStack = getStackInSlot(slotID); + setInventorySlotContents(slotID, null); + return tempStack; + } + else { + return null; + } + } @Override - public void setInventorySlotContents(int slotID, ItemStack itemstack) - { - inventory[slotID] = itemstack; + public void setInventorySlotContents(int slotID, ItemStack itemstack) + { + inventory[slotID] = itemstack; + + if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + } - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } - @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return !isInvalid(); } - + @Override public String getInvName() { return MekanismUtils.localize(getBlockType().getUnlocalizedName() + "." + fullName + ".name"); } - + @Override - public int getInventoryStackLimit() + public int getInventoryStackLimit() { return 64; } - + @Override public void openChest() {} @Override public void closeChest() {} - + @Override public boolean isInvNameLocalized() { @@ -174,15 +174,15 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl { return true; } - + @Override public boolean canInsertItem(int slotID, ItemStack itemstack, int side) { return isItemValidForSlot(slotID, itemstack); } - + @Override - public int[] getAccessibleSlotsFromSide(int side) + public int[] getAccessibleSlotsFromSide(int side) { return InventoryUtils.EMPTY; } @@ -194,49 +194,49 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl } @Override - public void setInventory(NBTTagList nbtTags, Object... data) + public void setInventory(NBTTagList nbtTags, Object... data) { if(nbtTags == null || nbtTags.tagCount() == 0 || !handleInventory()) { return; } - - inventory = new ItemStack[getSizeInventory()]; - for(int slots = 0; slots < nbtTags.tagCount(); slots++) - { - NBTTagCompound tagCompound = (NBTTagCompound)nbtTags.tagAt(slots); - byte slotID = tagCompound.getByte("Slot"); + inventory = new ItemStack[getSizeInventory()]; - if(slotID >= 0 && slotID < inventory.length) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } + for(int slots = 0; slots < nbtTags.tagCount(); slots++) + { + NBTTagCompound tagCompound = (NBTTagCompound)nbtTags.tagAt(slots); + byte slotID = tagCompound.getByte("Slot"); + + if(slotID >= 0 && slotID < inventory.length) + { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } } @Override public NBTTagList getInventory(Object... data) { - NBTTagList tagList = new NBTTagList(); + NBTTagList tagList = new NBTTagList(); - if(handleInventory()) - { - for(int slots = 0; slots < inventory.length; slots++) - { - if(inventory[slots] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slots); - inventory[slots].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } - } + if(handleInventory()) + { + for(int slots = 0; slots < inventory.length; slots++) + { + if(inventory[slots] != null) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte)slots); + inventory[slots].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + } - return tagList; + return tagList; } - + public boolean handleInventory() { return true; diff --git a/common/mekanism/common/tile/TileEntityCrusher.java b/common/mekanism/common/tile/TileEntityCrusher.java index 6d11af8f3..1877af373 100644 --- a/common/mekanism/common/tile/TileEntityCrusher.java +++ b/common/mekanism/common/tile/TileEntityCrusher.java @@ -12,17 +12,17 @@ import net.minecraftforge.common.ForgeDirection; public class TileEntityCrusher extends TileEntityElectricMachine { public float crushMatrix = 0; - + public TileEntityCrusher() { super("Crusher.ogg", "Crusher", new ResourceLocation("mekanism", "gui/GuiCrusher.png"), Mekanism.crusherUsage, 200, MachineType.CRUSHER.baseEnergy); } - + @Override public void onUpdate() { super.onUpdate(); - + if(worldObj.isRemote) { if(crushMatrix < 6) @@ -34,7 +34,7 @@ public class TileEntityCrusher extends TileEntityElectricMachine } } } - + public float getMatrix() { float matrix = 0; @@ -47,13 +47,13 @@ public class TileEntityCrusher extends TileEntityElectricMachine return 3 - (crushMatrix-3); } } - + @Override public Map getRecipes() { return Recipe.CRUSHER.get(); } - + @Override public float getVolumeMultiplier() { diff --git a/common/mekanism/common/tile/TileEntityDigitalMiner.java b/common/mekanism/common/tile/TileEntityDigitalMiner.java index 52609367b..184acedb2 100644 --- a/common/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/common/mekanism/common/tile/TileEntityDigitalMiner.java @@ -55,63 +55,63 @@ import dan200.computer.api.IPeripheral; public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IPeripheral, IUpgradeTile, IRedstoneControl, IActiveState, IAdvancedBoundingBlock { public static int[] EJECT_INV; - + public BitSet oresToMine = new BitSet(); - + public HashList filters = new HashList(); - + public ThreadMinerSearch searcher = new ThreadMinerSearch(this); - + public final double ENERGY_USAGE = Mekanism.digitalMinerUsage; - + public int radius; - + public boolean inverse; - + public int minY = 0; public int maxY = 60; - + public boolean doEject = false; public boolean doPull = false; - + public int delay; - + public int clientToMine; - + public ItemStack replaceStack; - + public boolean isActive; public boolean clientActive; - + public boolean silkTouch; - + public boolean running; - + public double prevEnergy; - + public int delayTicks; - + public boolean initCalc = false; - + public int numPowering; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 28); - + public TileEntityDigitalMiner() { super("DigitalMiner", MachineType.DIGITAL_MINER.baseEnergy); inventory = new ItemStack[29]; radius = 10; } - + @Override public void onUpdate() { super.onUpdate(); - + if(getActive()) { for(EntityPlayer player : playersUsing) @@ -122,7 +122,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } } } - + if(!worldObj.isRemote) { if(!initCalc) @@ -132,58 +132,58 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I reset(); start(); } - + initCalc = true; } - + ChargeUtils.discharge(27, this); - + if(MekanismUtils.canFunction(this) && running && getEnergy() >= getPerTick() && searcher.state == State.FINISHED && oresToMine.cardinality() > 0) { setActive(true); - + if(delay > 0) { delay--; } - + setEnergy(getEnergy()-getPerTick()); - + if(delay == 0) { Set toRemove = new HashSet(); - + int next = 0; - + while(true) { int index = oresToMine.nextSetBit(next); Coord4D coord = getCoordFromIndex(index); - + if(index == -1) { break; } - + if(!coord.exists(worldObj)) { toRemove.add(index); next = index + 1; continue; } - + int id = coord.getBlockId(worldObj); int meta = coord.getMetadata(worldObj); - + if(id == 0) { toRemove.add(index); next = index + 1; continue; } - + boolean hasFilter = false; - + for(MinerFilter filter : filters) { if(filter.canFilter(new ItemStack(id, 1, meta))) @@ -192,31 +192,31 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I break; } } - + if(inverse ? hasFilter : !hasFilter) { toRemove.add(index); next = index + 1; continue; } - + List drops = MinerUtils.getDrops(worldObj, coord, silkTouch); - + if(canInsert(drops)) { add(drops); - + setReplace(coord); toRemove.add(index); - + worldObj.playAuxSFXAtEntity(null, 2001, coord.xCoord, coord.yCoord, coord.zCoord, id + (meta << 12)); - + delay = getDelay(); } - + break; } - + for(Integer i : toRemove) { oresToMine.clear(i); @@ -229,32 +229,32 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I setActive(false); } } - + if(doEject && delayTicks == 0 && getTopEject(false, null) != null && getEjectInv() != null) { if(getEjectInv() instanceof IInventory) { ItemStack remains = InventoryUtils.putStackInInventory((IInventory)getEjectInv(), getTopEject(false, null), ForgeDirection.getOrientation(facing).getOpposite().ordinal(), false); - + getTopEject(true, remains); } else if(getEjectInv() instanceof ILogisticalTransporter) { ItemStack rejected = TransporterUtils.insert(getEjectTile(), (ILogisticalTransporter)getEjectInv(), getTopEject(false, null), null, true, 0); - + if(TransporterManager.didEmit(getTopEject(false, null), rejected)) { getTopEject(true, rejected); } } - + delayTicks = 10; } else if(delayTicks > 0) { delayTicks--; } - + if(playersUsing.size() > 0) { for(EntityPlayer player : playersUsing) @@ -262,42 +262,42 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getSmallPacket(new ArrayList())), player); } } - + prevEnergy = getEnergy(); } } - + public double getPerTick() { double ret = MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_USAGE); - + if(silkTouch) { ret *= 6F; } - + int baseRad = Math.max(radius-10, 0); ret *= (1 + ((float)baseRad/22F)); - + int baseHeight = Math.max((maxY-minY)-60, 0); ret *= (1 + ((float)baseHeight/195F)); - + return ret; } - + public int getDelay() { return MekanismUtils.getTicks(getSpeedMultiplier(), 80); } - + public void setReplace(Coord4D obj) { ItemStack stack = getReplace(); - + if(stack != null) { worldObj.setBlock(obj.xCoord, obj.yCoord, obj.zCoord, replaceStack.itemID, replaceStack.getItemDamage(), 3); - + if(Block.blocksList[obj.getBlockId(worldObj)] != null && !Block.blocksList[obj.getBlockId(worldObj)].canBlockStay(worldObj, obj.xCoord, obj.yCoord, obj.zCoord)) { Block.blocksList[obj.getBlockId(worldObj)].dropBlockAsItem(worldObj, obj.xCoord, obj.yCoord, obj.zCoord, obj.getMetadata(worldObj), 1); @@ -308,91 +308,91 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I worldObj.setBlockToAir(obj.xCoord, obj.yCoord, obj.zCoord); } } - + public ItemStack getReplace() { if(replaceStack == null) { return null; } - + for(int i = 0; i < 27; i++) { if(inventory[i] != null && inventory[i].isItemEqual(replaceStack)) { inventory[i].stackSize--; - + if(inventory[i].stackSize == 0) { inventory[i] = null; } - + return MekanismUtils.size(replaceStack, 1); } } - + if(doPull && getPullInv() instanceof IInventory) { InvStack stack = InventoryUtils.takeDefinedItem((IInventory)getPullInv(), 1, replaceStack.copy(), 1, 1); - + if(stack != null) { stack.use(); return MekanismUtils.size(replaceStack, 1); } } - + return null; } - + public ItemStack[] copy(ItemStack[] stacks) { ItemStack[] toReturn = new ItemStack[stacks.length]; - + for(int i = 0; i < stacks.length; i++) { toReturn[i] = stacks[i] != null ? stacks[i].copy() : null; } - + return toReturn; } - + public ItemStack getTopEject(boolean remove, ItemStack reject) { for(int i = 27-1; i >= 0; i--) { ItemStack stack = inventory[i]; - + if(stack != null) { if(replaceStack != null && replaceStack.isItemEqual(stack)) { continue; } - + if(remove) { inventory[i] = reject; } - + return stack; } } - + return null; } - + public boolean canInsert(List stacks) { if(stacks.isEmpty()) { return true; } - + ItemStack[] testInv = copy(inventory); - + int added = 0; - + stacks: for(ItemStack stack : stacks) { @@ -402,46 +402,46 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { testInv[i] = stack; added++; - + continue stacks; } else if(testInv[i].isItemEqual(stack) && testInv[i].stackSize+stack.stackSize <= stack.getMaxStackSize()) { testInv[i].stackSize += stack.stackSize; added++; - + continue stacks; } } } - + if(added == stacks.size()) { return true; } - + return false; } - + public TileEntity getPullInv() { return Coord4D.get(this).translate(0, 2, 0).getTileEntity(worldObj); } - + public TileEntity getEjectInv() { ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); - + return new Coord4D(xCoord+(side.offsetX*2), yCoord+1, zCoord+(side.offsetZ*2), worldObj.provider.dimensionId).getTileEntity(worldObj); } - + public void add(List stacks) { if(stacks.isEmpty()) { return; } - + stacks: for(ItemStack stack : stacks) { @@ -450,62 +450,62 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(inventory[i] == null) { inventory[i] = stack; - + continue stacks; } else if(inventory[i].isItemEqual(stack) && inventory[i].stackSize+stack.stackSize <= stack.getMaxStackSize()) { inventory[i].stackSize += stack.stackSize; - + continue stacks; } } } } - + public void start() { if(searcher.state == State.IDLE) { searcher.start(); } - + running = true; - + MekanismUtils.saveChunk(this); } - + public void stop() { if(searcher.state == State.SEARCHING) { searcher.interrupt(); reset(); - + return; } else if(searcher.state == State.FINISHED) { running = false; } - + MekanismUtils.saveChunk(this); } - + public void reset() { searcher = new ThreadMinerSearch(this); running = false; oresToMine.clear(); - + MekanismUtils.saveChunk(this); } - + @Override public void openChest() { super.openChest(); - + if(!worldObj.isRemote) { for(EntityPlayer player : playersUsing) @@ -514,91 +514,91 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } } } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - radius = nbtTags.getInteger("radius"); - minY = nbtTags.getInteger("minY"); - maxY = nbtTags.getInteger("maxY"); - doEject = nbtTags.getBoolean("doEject"); - doPull = nbtTags.getBoolean("doPull"); - isActive = nbtTags.getBoolean("isActive"); - running = nbtTags.getBoolean("running"); - delay = nbtTags.getInteger("delay"); - silkTouch = nbtTags.getBoolean("silkTouch"); - numPowering = nbtTags.getInteger("numPowering"); - searcher.state = State.values()[nbtTags.getInteger("state")]; - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - inverse = nbtTags.getBoolean("inverse"); - - if(nbtTags.hasKey("replaceStack")) - { - replaceStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("replaceStack")); - } - - if(nbtTags.hasKey("filters")) - { - NBTTagList tagList = nbtTags.getTagList("filters"); - - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i))); - } - } - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - if(searcher.state == State.SEARCHING) - { - reset(); - } - - nbtTags.setInteger("radius", radius); - nbtTags.setInteger("minY", minY); - nbtTags.setInteger("maxY", maxY); - nbtTags.setBoolean("doEject", doEject); - nbtTags.setBoolean("doPull", doPull); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setBoolean("running", running); - nbtTags.setInteger("delay", delay); - nbtTags.setBoolean("silkTouch", silkTouch); - nbtTags.setInteger("numPowering", numPowering); - nbtTags.setInteger("state", searcher.state.ordinal()); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setBoolean("inverse", inverse); - - if(replaceStack != null) - { - nbtTags.setCompoundTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound())); - } - - NBTTagList filterTags = new NBTTagList(); - - for(MinerFilter filter : filters) - { - filterTags.appendTag(filter.write(new NBTTagCompound())); - } - - if(filterTags.tagCount() != 0) - { - nbtTags.setTag("filters", filterTags); - } - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + radius = nbtTags.getInteger("radius"); + minY = nbtTags.getInteger("minY"); + maxY = nbtTags.getInteger("maxY"); + doEject = nbtTags.getBoolean("doEject"); + doPull = nbtTags.getBoolean("doPull"); + isActive = nbtTags.getBoolean("isActive"); + running = nbtTags.getBoolean("running"); + delay = nbtTags.getInteger("delay"); + silkTouch = nbtTags.getBoolean("silkTouch"); + numPowering = nbtTags.getInteger("numPowering"); + searcher.state = State.values()[nbtTags.getInteger("state")]; + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + inverse = nbtTags.getBoolean("inverse"); + + if(nbtTags.hasKey("replaceStack")) + { + replaceStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("replaceStack")); + } + + if(nbtTags.hasKey("filters")) + { + NBTTagList tagList = nbtTags.getTagList("filters"); + + for(int i = 0; i < tagList.tagCount(); i++) + { + filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i))); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + if(searcher.state == State.SEARCHING) + { + reset(); + } + + nbtTags.setInteger("radius", radius); + nbtTags.setInteger("minY", minY); + nbtTags.setInteger("maxY", maxY); + nbtTags.setBoolean("doEject", doEject); + nbtTags.setBoolean("doPull", doPull); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setBoolean("running", running); + nbtTags.setInteger("delay", delay); + nbtTags.setBoolean("silkTouch", silkTouch); + nbtTags.setInteger("numPowering", numPowering); + nbtTags.setInteger("state", searcher.state.ordinal()); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setBoolean("inverse", inverse); + + if(replaceStack != null) + { + nbtTags.setCompoundTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound())); + } + + NBTTagList filterTags = new NBTTagList(); + + for(MinerFilter filter : filters) + { + filterTags.appendTag(filter.write(new NBTTagCompound())); + } + + if(filterTags.tagCount() != 0) + { + nbtTags.setTag("filters", filterTags); + } + } + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { doEject = !doEject; @@ -610,7 +610,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else if(type == 2) { boolean doNull = dataStream.readBoolean(); - + if(!doNull) { replaceStack = new ItemStack(dataStream.readInt(), 1, dataStream.readInt()); @@ -651,19 +651,19 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { inverse = !inverse; } - + for(EntityPlayer player : playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getGenericPacket(new ArrayList())), player); } - + return; } - + super.handlePacketData(dataStream); - + int type = dataStream.readInt(); - + if(type == 0) { radius = dataStream.readInt(); @@ -676,7 +676,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I silkTouch = dataStream.readBoolean(); numPowering = dataStream.readInt(); searcher.state = State.values()[dataStream.readInt()]; - + if(dataStream.readBoolean()) { replaceStack = new ItemStack(dataStream.readInt(), 1, dataStream.readInt()); @@ -684,15 +684,15 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else { replaceStack = null; } - + clientToMine = dataStream.readInt(); controlType = RedstoneControl.values()[dataStream.readInt()]; inverse = dataStream.readBoolean(); - + filters.clear(); - + int amount = dataStream.readInt(); - + for(int i = 0; i < amount; i++) { filters.add(MinerFilter.readFromPacket(dataStream)); @@ -710,7 +710,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I silkTouch = dataStream.readBoolean(); numPowering = dataStream.readInt(); searcher.state = State.values()[dataStream.readInt()]; - + if(dataStream.readBoolean()) { replaceStack = new ItemStack(dataStream.readInt(), 1, dataStream.readInt()); @@ -718,7 +718,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else { replaceStack = null; } - + clientToMine = dataStream.readInt(); controlType = RedstoneControl.values()[dataStream.readInt()]; inverse = dataStream.readBoolean(); @@ -726,9 +726,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else if(type == 2) { filters.clear(); - + int amount = dataStream.readInt(); - + for(int i = 0; i < amount; i++) { filters.add(MinerFilter.readFromPacket(dataStream)); @@ -741,14 +741,14 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I clientToMine = dataStream.readInt(); } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(0); - + data.add(radius); data.add(minY); data.add(maxY); @@ -759,7 +759,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I data.add(silkTouch); data.add(numPowering); data.add(searcher.state.ordinal()); - + if(replaceStack != null) { data.add(true); @@ -769,7 +769,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else { data.add(false); } - + if(searcher.state == State.SEARCHING) { data.add(searcher.found); @@ -777,26 +777,26 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else { data.add(oresToMine.cardinality()); } - + data.add(controlType.ordinal()); data.add(inverse); - + data.add(filters.size()); - + for(MinerFilter filter : filters) { filter.write(data); } - + return data; } - + public ArrayList getSmallPacket(ArrayList data) { super.getNetworkedData(data); - + data.add(3); - + data.add(isActive); data.add(running); @@ -807,16 +807,16 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else { data.add(oresToMine.cardinality()); } - + return data; } - + public ArrayList getGenericPacket(ArrayList data) { super.getNetworkedData(data); - + data.add(1); - + data.add(radius); data.add(minY); data.add(maxY); @@ -827,7 +827,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I data.add(silkTouch); data.add(numPowering); data.add(searcher.state.ordinal()); - + if(replaceStack != null) { data.add(true); @@ -837,7 +837,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else { data.add(false); } - + if(searcher.state == State.SEARCHING) { data.add(searcher.found); @@ -845,150 +845,150 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else { data.add(oresToMine.cardinality()); } - + data.add(controlType.ordinal()); data.add(inverse); - + return data; } - + public ArrayList getFilterPacket(ArrayList data) { super.getNetworkedData(data); - + data.add(2); - + data.add(filters.size()); - + for(MinerFilter filter : filters) { filter.write(data); } - + return data; } - + public int getTotalSize() { return getDiameter()*getDiameter()*(maxY-minY+1); } - + public int getDiameter() { return (radius*2)+1; } - + public Coord4D getStartingCoord() { return new Coord4D(xCoord-radius, minY, zCoord-radius, worldObj.provider.dimensionId); } - + public Coord4D getCoordFromIndex(int index) { int diameter = getDiameter(); Coord4D start = getStartingCoord(); - + int x = start.xCoord+index%diameter; int z = start.zCoord+(index/diameter)%diameter; int y = start.yCoord+(index/diameter/diameter); - + return new Coord4D(x, y, z, worldObj.provider.dimensionId); } - + @Override - public double getMaxEnergy() + public double getMaxEnergy() { return MekanismUtils.getMaxEnergy(getEnergyMultiplier(), MAX_ELECTRICITY); } - + @Override public boolean isPowered() { return redstone || numPowering > 0; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); } - + @Override public TileComponentUpgrade getComponent() { return upgradeComponent; } - + @Override - public int getEnergyMultiplier(Object... data) + public int getEnergyMultiplier(Object... data) { return upgradeComponent.energyMultiplier; } @Override - public void setEnergyMultiplier(int multiplier, Object... data) + public void setEnergyMultiplier(int multiplier, Object... data) { upgradeComponent.energyMultiplier = multiplier; MekanismUtils.saveChunk(this); } @Override - public int getSpeedMultiplier(Object... data) + public int getSpeedMultiplier(Object... data) { return upgradeComponent.speedMultiplier; } @Override - public void setSpeedMultiplier(int multiplier, Object... data) + public void setSpeedMultiplier(int multiplier, Object... data) { upgradeComponent.speedMultiplier = multiplier; MekanismUtils.saveChunk(this); } - + @Override public boolean supportsUpgrades(Object... data) { return true; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } - + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return false; + } + + @Override + public boolean lightUpdate() + { + return true; + } + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() @@ -1009,14 +1009,14 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { continue; } - + MekanismUtils.makeAdvancedBoundingBlock(worldObj, x, y, z, Coord4D.get(this)); worldObj.notifyBlocksOfNeighborChange(x, y, z, Mekanism.BoundingBlock.blockID); } } } } - + @Override public boolean canSetFacing(int side) { @@ -1037,13 +1037,13 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } } } - + @Override public int[] getAccessibleSlotsFromSide(int side) { return InventoryUtils.EMPTY; } - + public TileEntity getEjectTile() { ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); @@ -1054,36 +1054,36 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public int[] getBoundSlots(Coord4D location, int side) { ForgeDirection dir = ForgeDirection.getOrientation(facing).getOpposite(); - + Coord4D eject = Coord4D.get(this).translate(dir.offsetX, 1, dir.offsetZ); Coord4D pull = Coord4D.get(this).translate(0, 1, 0); - + if((location.equals(eject) && side == dir.ordinal()) || (location.equals(pull) && side == 1)) { if(EJECT_INV == null) { EJECT_INV = new int[27]; - + for(int i = 0; i < EJECT_INV.length; i++) { EJECT_INV[i] = i; } } - + return EJECT_INV; } - + return InventoryUtils.EMPTY; } @Override - public boolean canBoundInsert(Coord4D location, int i, ItemStack itemstack) + public boolean canBoundInsert(Coord4D location, int i, ItemStack itemstack) { ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); - + Coord4D eject = Coord4D.get(this).translate(side.offsetX, 1, side.offsetZ); Coord4D pull = Coord4D.get(this).translate(0, 1, 0); - + if(location.equals(eject)) { return false; @@ -1095,7 +1095,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I return true; } } - + return false; } @@ -1103,33 +1103,33 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public boolean canBoundExtract(Coord4D location, int i, ItemStack itemstack, int j) { ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); - + Coord4D eject = new Coord4D(xCoord+side.offsetX, yCoord+1, zCoord+side.offsetZ, worldObj.provider.dimensionId); Coord4D pull = new Coord4D(xCoord, yCoord+1, zCoord, worldObj.provider.dimensionId); - + if(location.equals(eject)) { if(itemstack != null && replaceStack != null && itemstack.isItemEqual(replaceStack)) { return false; } - + return true; } else if(location.equals(pull)) { return false; } - + return false; } - + @Override public void onPower() { numPowering++; } - + @Override public void onNoPower() { @@ -1141,22 +1141,22 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { return getInvName(); } - + public String[] names = {"setRadius", "setMin", "setMax", "setReplace", "addFilter", "removeFilter", "addOreFilter", "removeOreFilter", "reset", "start", "stop"}; - + @Override public String[] getMethodNames() { return names; } - + @Override public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { if(arguments.length > 0) { int num = 0; - + if(arguments[0] instanceof Double) { num = ((Double)arguments[0]).intValue(); @@ -1165,7 +1165,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { num = Integer.parseInt((String)arguments[0]); } - + if(num != 0) { if(method == 0) @@ -1183,7 +1183,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I else if(method == 3) { int meta = 0; - + if(arguments.length > 1) { if(arguments[1] instanceof Double) @@ -1195,13 +1195,13 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I meta = Integer.parseInt((String)arguments[1]); } } - + replaceStack = new ItemStack(num, 1, meta); } else if(method == 4) { int meta = 0; - + if(arguments.length > 1) { if(arguments[1] instanceof Double) @@ -1213,17 +1213,17 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I meta = Integer.parseInt((String)arguments[1]); } } - + filters.add(new MItemStackFilter(new ItemStack(num, 1, meta))); } else if(method == 5) { Iterator iter = filters.iterator(); - + while(iter.hasNext()) { MinerFilter filter = iter.next(); - + if(filter instanceof MItemStackFilter) { if(((MItemStackFilter)filter).itemType.itemID == num) @@ -1237,7 +1237,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { String ore = (String)arguments[0]; MOreDictFilter filter = new MOreDictFilter(); - + filter.oreDictName = ore; filters.add(filter); } @@ -1245,11 +1245,11 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { String ore = (String)arguments[0]; Iterator iter = filters.iterator(); - + while(iter.hasNext()) { MinerFilter filter = iter.next(); - + if(filter instanceof MOreDictFilter) { if(((MOreDictFilter)filter).oreDictName == ore) @@ -1273,24 +1273,24 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } } } - + for(EntityPlayer player : playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getGenericPacket(new ArrayList())), player); } - + return null; } - + @Override public boolean canAttachToSide(int side) { return true; } - + @Override public void attach(IComputerAccess computer) {} - + @Override public void detach(IComputerAccess computer) {} } diff --git a/common/mekanism/common/tile/TileEntityDynamicTank.java b/common/mekanism/common/tile/TileEntityDynamicTank.java index 06f2f953c..7b631bc76 100644 --- a/common/mekanism/common/tile/TileEntityDynamicTank.java +++ b/common/mekanism/common/tile/TileEntityDynamicTank.java @@ -31,57 +31,57 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock { /** Unique inventory ID for the dynamic tank, serves as a way to retrieve cached inventories. */ public int inventoryID = -1; - + /** The tank data for this structure. */ public SynchronizedTankData structure; - + /** Whether or not to send this tank's structure in the next update packet. */ public boolean sendStructure; - + /** This tank's previous "has structure" state. */ public boolean prevStructure; - + /** Whether or not this tank has it's structure, for the client side mechanics. */ public boolean clientHasStructure; - + /** The cached fluid this tank segment contains. */ public FluidStack cachedFluid; - + /** A client-sided and server-sided map of valves on this tank's structure, used on the client for rendering fluids. */ public Map valveViewing = new HashMap(); - + /** The capacity this tank has on the client-side. */ public int clientCapacity; - + /** Whether or not this tank segment is rendering the structure. */ public boolean isRendering; - + public float prevScale; - + public TileEntityDynamicTank() { this("DynamicTank"); } - + public TileEntityDynamicTank(String name) { super(name); inventory = new ItemStack[2]; } - + public void update() { if(!worldObj.isRemote && (structure == null || !structure.didTick)) { new TankUpdateProtocol(this).updateTanks(); - + if(structure != null) { structure.didTick = true; } } } - + @Override public void onUpdate() { @@ -91,7 +91,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock { structure = new SynchronizedTankData(); } - + if(structure != null && clientHasStructure && isRendering) { for(ValveData data : valveViewing.keySet()) @@ -101,38 +101,38 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock valveViewing.put(data, valveViewing.get(data)-1); } } - + if(!prevStructure) { Mekanism.proxy.doTankAnimation(this); } - - float targetScale = (float)(structure.fluidStored != null ? structure.fluidStored.amount : 0)/clientCapacity; - - if(Math.abs(prevScale - targetScale) > 0.01) - { - prevScale = (9*prevScale + targetScale)/10; - } + + float targetScale = (float)(structure.fluidStored != null ? structure.fluidStored.amount : 0)/clientCapacity; + + if(Math.abs(prevScale - targetScale) > 0.01) + { + prevScale = (9*prevScale + targetScale)/10; + } } - + prevStructure = clientHasStructure; - + if(!clientHasStructure || !isRendering) { for(ValveData data : valveViewing.keySet()) { TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)data.location.getTileEntity(worldObj); - + if(tileEntity != null) { tileEntity.clientHasStructure = false; } } - + valveViewing.clear(); } } - + if(playersUsing.size() > 0 && ((worldObj.isRemote && !clientHasStructure) || (!worldObj.isRemote && structure == null))) { for(EntityPlayer player : playersUsing) @@ -140,24 +140,24 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock player.closeScreen(); } } - + if(!worldObj.isRemote) { if(structure == null) { isRendering = false; } - + if(inventoryID != -1 && structure == null) { MekanismUtils.updateCache(inventoryID, cachedFluid, inventory, this); } - + if(structure == null && ticker == 5) { update(); } - + if(prevStructure != (structure != null)) { if(structure != null && !structure.hasRenderer) @@ -166,43 +166,43 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock isRendering = true; sendStructure = true; } - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { Coord4D obj = Coord4D.get(this).getFromSide(side); - + if(!(obj.getTileEntity(worldObj) instanceof TileEntityDynamicTank)) { worldObj.notifyBlockOfNeighborChange(obj.xCoord, obj.yCoord, obj.zCoord, getBlockType().blockID); } } - + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } - + prevStructure = structure != null; - + if(structure != null) { structure.didTick = false; - + if(inventoryID != -1) { MekanismUtils.updateCache(inventoryID, structure.fluidStored, structure.inventory, this); - + cachedFluid = structure.fluidStored; inventory = structure.inventory; } - + manageInventory(); } } } - + public void manageInventory() { int max = structure.volume*TankUpdateProtocol.FLUID_PER_TANK; - + if(structure.inventory[0] != null) { if(FluidContainerRegistry.isEmptyContainer(structure.inventory[0])) @@ -210,18 +210,18 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock if(structure.fluidStored != null && structure.fluidStored.amount >= FluidContainerRegistry.BUCKET_VOLUME) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(structure.fluidStored, structure.inventory[0]); - + if(filled != null) { if(structure.inventory[1] == null || (structure.inventory[1].isItemEqual(filled) && structure.inventory[1].stackSize+1 <= filled.getMaxStackSize())) { structure.inventory[0].stackSize--; - + if(structure.inventory[0].stackSize <= 0) { structure.inventory[0] = null; } - + if(structure.inventory[1] == null) { structure.inventory[1] = filled; @@ -229,16 +229,16 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock else { structure.inventory[1].stackSize++; } - + onInventoryChanged(); - + structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - + if(structure.fluidStored.amount == 0) { structure.fluidStored = null; } - + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } @@ -247,24 +247,24 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock else if(FluidContainerRegistry.isFilledContainer(structure.inventory[0])) { FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(structure.inventory[0]); - + if((structure.fluidStored == null && itemFluid.amount <= max) || structure.fluidStored.amount+itemFluid.amount <= max) { if(structure.fluidStored != null && !structure.fluidStored.isFluidEqual(itemFluid)) { return; } - + ItemStack containerItem = structure.inventory[0].getItem().getContainerItemStack(structure.inventory[0]); - + boolean filled = false; - + if(containerItem != null) { if(structure.inventory[1] == null || (structure.inventory[1].isItemEqual(containerItem) && structure.inventory[1].stackSize+1 <= containerItem.getMaxStackSize())) { structure.inventory[0] = null; - + if(structure.inventory[1] == null) { structure.inventory[1] = containerItem; @@ -272,22 +272,22 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock else { structure.inventory[1].stackSize++; } - + onInventoryChanged(); filled = true; } } - else { + else { structure.inventory[0].stackSize--; - + if(structure.inventory[0].stackSize == 0) { structure.inventory[0] = null; } - + filled = true; } - + if(filled) { if(structure.fluidStored == null) @@ -298,22 +298,22 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock structure.fluidStored.amount += itemFluid.amount; } } - + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isRendering); data.add(structure != null); data.add(structure != null ? structure.volume*TankUpdateProtocol.FLUID_PER_TANK : 0); - + if(structure != null && structure.fluidStored != null) { data.add(1); @@ -323,54 +323,54 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock else { data.add(0); } - + if(structure != null && isRendering) { if(sendStructure) { sendStructure = false; - + data.add(true); - + data.add(structure.volHeight); data.add(structure.volWidth); data.add(structure.volLength); - + structure.renderLocation.write(data); } else { data.add(false); } - + data.add(structure.valves.size()); - + for(ValveData valveData : structure.valves) { valveData.location.write(data); - + data.add(valveData.side.ordinal()); data.add(valveData.serverFluid); } } - + return data; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + if(structure == null) { structure = new SynchronizedTankData(); } - + isRendering = dataStream.readBoolean(); clientHasStructure = dataStream.readBoolean(); - + clientCapacity = dataStream.readInt(); - + if(dataStream.readInt() == 1) { structure.fluidStored = new FluidStack(dataStream.readInt(), dataStream.readInt()); @@ -378,7 +378,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock else { structure.fluidStored = null; } - + if(clientHasStructure && isRendering) { if(dataStream.readBoolean()) @@ -386,24 +386,24 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock structure.volHeight = dataStream.readInt(); structure.volWidth = dataStream.readInt(); structure.volLength = dataStream.readInt(); - + structure.renderLocation = Coord4D.read(dataStream); } - + int size = dataStream.readInt(); - + for(int i = 0; i < size; i++) { ValveData data = new ValveData(); data.location = Coord4D.read(dataStream); data.side = ForgeDirection.getOrientation(dataStream.readInt()); int viewingTicks = 0; - + if(dataStream.readBoolean()) { viewingTicks = 30; } - + if(viewingTicks == 0) { if(valveViewing.containsKey(data) && valveViewing.get(data) > 0) @@ -411,11 +411,11 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock continue; } } - + valveViewing.put(data, viewingTicks); - + TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)data.location.getTileEntity(worldObj); - + if(tileEntity != null) { tileEntity.clientHasStructure = true; @@ -423,7 +423,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock } } } - + public void sendPacketToRenderer() { if(structure != null) @@ -431,7 +431,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock for(Coord4D obj : structure.locations) { TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(worldObj); - + if(tileEntity != null && tileEntity.isRendering) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList()))); @@ -439,69 +439,69 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock } } } - + public int getScaledFluidLevel(int i) { if(clientCapacity == 0 || structure.fluidStored == null) { return 0; } - + return structure.fluidStored.amount*i / clientCapacity; } - + @Override - public ItemStack getStackInSlot(int slotID) + public ItemStack getStackInSlot(int slotID) { return structure != null ? structure.inventory[slotID] : null; } - - @Override - public void setInventorySlotContents(int slotID, ItemStack itemstack) - { - if(structure != null) - { - structure.inventory[slotID] = itemstack; - - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - if(structure == null) - { - inventoryID = nbtTags.getInteger("inventoryID"); - - if(inventoryID != -1) - { - if(nbtTags.hasKey("cachedFluid")) - { - cachedFluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid")); - } - } - } - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("inventoryID", inventoryID); - - if(cachedFluid != null) - { - nbtTags.setTag("cachedFluid", cachedFluid.writeToNBT(new NBTTagCompound())); - } - } - + public void setInventorySlotContents(int slotID, ItemStack itemstack) + { + if(structure != null) + { + structure.inventory[slotID] = itemstack; + + if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + { + itemstack.stackSize = getInventoryStackLimit(); + } + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + if(structure == null) + { + inventoryID = nbtTags.getInteger("inventoryID"); + + if(inventoryID != -1) + { + if(nbtTags.hasKey("cachedFluid")) + { + cachedFluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid")); + } + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("inventoryID", inventoryID); + + if(cachedFluid != null) + { + nbtTags.setTag("cachedFluid", cachedFluid.writeToNBT(new NBTTagCompound())); + } + } + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() diff --git a/common/mekanism/common/tile/TileEntityDynamicValve.java b/common/mekanism/common/tile/TileEntityDynamicValve.java index f73ac69f1..e23bbea21 100644 --- a/common/mekanism/common/tile/TileEntityDynamicValve.java +++ b/common/mekanism/common/tile/TileEntityDynamicValve.java @@ -11,13 +11,13 @@ import net.minecraftforge.fluids.IFluidHandler; public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFluidHandler { public DynamicFluidTank fluidTank; - + public TileEntityDynamicValve() { super("Dynamic Valve"); fluidTank = new DynamicFluidTank(this); } - + @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { @@ -25,7 +25,7 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl } @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { return fluidTank.fill(resource, doFill); } @@ -40,23 +40,23 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl return fluidTank.drain(resource.amount, doDrain); } } - + return null; } @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { if(fluidTank.dynamicTank.structure != null) { return fluidTank.drain(maxDrain, doDrain); } - + return null; } @Override - public boolean canFill(ForgeDirection from, Fluid fluid) + public boolean canFill(ForgeDirection from, Fluid fluid) { return true; } diff --git a/common/mekanism/common/tile/TileEntityElectricBlock.java b/common/mekanism/common/tile/TileEntityElectricBlock.java index 5e02c7ff4..7abece1a2 100644 --- a/common/mekanism/common/tile/TileEntityElectricBlock.java +++ b/common/mekanism/common/tile/TileEntityElectricBlock.java @@ -34,13 +34,13 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { /** How much energy is stored in this block. */ public double electricityStored; - + /** Maximum amount of energy this machine can hold. */ public double MAX_ELECTRICITY; - + /** BuildCraft power handler. */ public PowerHandler powerHandler; - + /** * The base of all blocks that deal with electricity. It has a facing state, initialized state, * and a current amount of stored energy. @@ -51,12 +51,12 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { super(name); MAX_ELECTRICITY = maxEnergy; - + powerHandler = new PowerHandler(this, PowerHandler.Type.STORAGE); powerHandler.configurePowerPerdition(0, 0); powerHandler.configure(0, 0, 0, 0); } - + public void register() { if(!worldObj.isRemote) @@ -68,13 +68,13 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } } } - + @Override public void onUpdate() { reconfigure(); } - + public EnumSet getOutputtingSides() { return EnumSet.noneOf(ForgeDirection.class); @@ -86,38 +86,38 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i set.remove(ForgeDirection.UNKNOWN); return set; } - + public double getMaxOutput() { return 0; } - + @Override public double getEnergy() { return electricityStored; } - + @Override public void setEnergy(double energy) { electricityStored = Math.max(Math.min(energy, getMaxEnergy()), 0); MekanismUtils.saveChunk(this); } - + @Override public double getMaxEnergy() { return MAX_ELECTRICITY; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); setEnergy(dataStream.readDouble()); } - + @Override public ArrayList getNetworkedData(ArrayList data) { @@ -125,7 +125,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i data.add(getEnergy()); return data; } - + @Override public void onChunkUnload() { @@ -134,50 +134,50 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i Mekanism.ic2Registered.remove(Coord4D.get(this)); MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); } - + super.onChunkUnload(); } - + @Override public void invalidate() { super.invalidate(); - + if(!worldObj.isRemote) { Mekanism.ic2Registered.remove(Coord4D.get(this)); MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); } } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - electricityStored = nbtTags.getDouble("electricityStored"); - reconfigure(); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setDouble("electricityStored", getEnergy()); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + electricityStored = nbtTags.getDouble("electricityStored"); + reconfigure(); + } + @Override - public PowerReceiver getPowerReceiver(ForgeDirection side) + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setDouble("electricityStored", getEnergy()); + } + + @Override + public PowerReceiver getPowerReceiver(ForgeDirection side) { if(getConsumingSides().contains(side)) { return powerHandler.getPowerReceiver(); } - + return null; } - + protected void reconfigure() { if(MekanismUtils.useBuildCraft()) @@ -185,9 +185,9 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i powerHandler.configure(1, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), 0, (float)(getMaxEnergy()*Mekanism.TO_BC)); } } - + @Override - public void doWork(PowerHandler workProvider) + public void doWork(PowerHandler workProvider) { if(powerHandler.getEnergyStored() > 0) { @@ -195,19 +195,19 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { setEnergy(getEnergy() + powerHandler.useEnergy(0, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), true)*Mekanism.FROM_BC); } - + powerHandler.setEnergy(0); } - + reconfigure(); } - + @Override public World getWorld() { return worldObj; } - + /** * Gets the scaled energy level for the GUI. * @param i - multiplier @@ -217,22 +217,22 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { return (int)(getEnergy()*i / getMaxEnergy()); } - + @Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { if(getConsumingSides().contains(from)) { double toAdd = (int)Math.min(getMaxEnergy()-getEnergy(), maxReceive*Mekanism.FROM_TE); - + if(!simulate) { setEnergy(getEnergy() + toAdd); } - + return (int)Math.round(toAdd*Mekanism.TO_TE); } - + return 0; } @@ -242,20 +242,20 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i if(getOutputtingSides().contains(from)) { double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), maxExtract*Mekanism.FROM_TE)); - + if(!simulate) { setEnergy(getEnergy() - toSend); } - + return (int)Math.round(toSend*Mekanism.TO_TE); } - + return 0; } @Override - public boolean canInterface(ForgeDirection from) + public boolean canInterface(ForgeDirection from) { return getConsumingSides().contains(from) || getOutputtingSides().contains(from); } @@ -267,11 +267,11 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override - public int getMaxEnergyStored(ForgeDirection from) + public int getMaxEnergyStored(ForgeDirection from) { return (int)Math.round(getMaxEnergy()*Mekanism.TO_TE); } - + @Override public int getMaxSafeInput() { @@ -292,17 +292,17 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override - public boolean isTeleporterCompatible(ForgeDirection side) + public boolean isTeleporterCompatible(ForgeDirection side) { return getOutputtingSides().contains(side); } - + @Override public boolean canOutputTo(ForgeDirection side) { return getOutputtingSides().contains(side); } - + @Override public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { @@ -310,29 +310,29 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override - public int getStored() + public int getStored() { return (int)Math.round(getEnergy()*Mekanism.TO_IC2); } @Override - public int getCapacity() + public int getCapacity() { return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2); } @Override - public int getOutput() + public int getOutput() { return (int)Math.round(getMaxOutput()*Mekanism.TO_IC2); } @Override - public double demandedEnergyUnits() + public double demandedEnergyUnits() { return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2; } - + @Override public boolean canReceiveEnergy(ForgeDirection side) { @@ -346,16 +346,16 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } @Override - public double injectEnergyUnits(ForgeDirection direction, double i) - { + public double injectEnergyUnits(ForgeDirection direction, double i) + { if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof IGridTransmitter) { return i; } - - return i-transferEnergyToAcceptor(direction, i*Mekanism.FROM_IC2)*Mekanism.TO_IC2; - } - + + return i-transferEnergyToAcceptor(direction, i*Mekanism.FROM_IC2)*Mekanism.TO_IC2; + } + @Override public double transferEnergyToAcceptor(ForgeDirection side, double amount) { @@ -363,15 +363,15 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i { return 0; } - - double toUse = Math.min(getMaxEnergy()-getEnergy(), amount); - setEnergy(getEnergy() + toUse); - - return toUse; + + double toUse = Math.min(getMaxEnergy()-getEnergy(), amount); + setEnergy(getEnergy() + toUse); + + return toUse; } - + @Override - public boolean canEmitPowerFrom(ForgeDirection side) + public boolean canEmitPowerFrom(ForgeDirection side) { return getOutputtingSides().contains(side); } diff --git a/common/mekanism/common/tile/TileEntityElectricChest.java b/common/mekanism/common/tile/TileEntityElectricChest.java index 1976e1b0a..4ccd52f30 100644 --- a/common/mekanism/common/tile/TileEntityElectricChest.java +++ b/common/mekanism/common/tile/TileEntityElectricChest.java @@ -13,89 +13,89 @@ import com.google.common.io.ByteArrayDataInput; public class TileEntityElectricChest extends TileEntityElectricBlock { public static int[] INV; - + public String password = ""; - + public boolean authenticated = false; - + public boolean locked = false; - + public float lidAngle; - + public float prevLidAngle; - + public TileEntityElectricChest() { super("ElectricChest", 12000); inventory = new ItemStack[55]; } - + @Override public void onUpdate() { super.onUpdate(); - + prevLidAngle = lidAngle; - float increment = 0.1F; + float increment = 0.1F; - if((playersUsing.size() > 0) && (lidAngle == 0.0F)) - { - worldObj.playSoundEffect(xCoord + 0.5F, yCoord + 0.5D, zCoord + 0.5F, "random.chestopen", 0.5F, (worldObj.rand.nextFloat()*0.1F) + 0.9F); - } + if((playersUsing.size() > 0) && (lidAngle == 0.0F)) + { + worldObj.playSoundEffect(xCoord + 0.5F, yCoord + 0.5D, zCoord + 0.5F, "random.chestopen", 0.5F, (worldObj.rand.nextFloat()*0.1F) + 0.9F); + } - if((playersUsing.size() == 0 && lidAngle > 0.0F) || (playersUsing.size() > 0 && lidAngle < 1.0F)) - { - float angle = lidAngle; + if((playersUsing.size() == 0 && lidAngle > 0.0F) || (playersUsing.size() > 0 && lidAngle < 1.0F)) + { + float angle = lidAngle; - if(playersUsing.size() > 0) - { - lidAngle += increment; - } - else { - lidAngle -= increment; - } + if(playersUsing.size() > 0) + { + lidAngle += increment; + } + else { + lidAngle -= increment; + } - if(lidAngle > 1.0F) - { - lidAngle = 1.0F; - } + if(lidAngle > 1.0F) + { + lidAngle = 1.0F; + } - float split = 0.5F; + float split = 0.5F; - if(lidAngle < split && angle >= split) - { - worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.chestclosed", 0.5F, (worldObj.rand.nextFloat()*0.1F) + 0.9F); - } + if(lidAngle < split && angle >= split) + { + worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.chestclosed", 0.5F, (worldObj.rand.nextFloat()*0.1F) + 0.9F); + } - if(lidAngle < 0.0F) - { - lidAngle = 0.0F; - } - } - - ChargeUtils.discharge(54, this); + if(lidAngle < 0.0F) + { + lidAngle = 0.0F; + } + } + + ChargeUtils.discharge(54, this); } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - authenticated = nbtTags.getBoolean("authenticated"); - locked = nbtTags.getBoolean("locked"); - password = nbtTags.getString("password"); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("authenticated", authenticated); - nbtTags.setBoolean("locked", locked); - nbtTags.setString("password", password); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + authenticated = nbtTags.getBoolean("authenticated"); + locked = nbtTags.getBoolean("locked"); + password = nbtTags.getString("password"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("authenticated", authenticated); + nbtTags.setBoolean("locked", locked); + nbtTags.setString("password", password); + } + @Override public void handlePacketData(ByteArrayDataInput dataStream) { @@ -104,7 +104,7 @@ public class TileEntityElectricChest extends TileEntityElectricBlock locked = dataStream.readBoolean(); password = dataStream.readUTF(); } - + @Override public ArrayList getNetworkedData(ArrayList data) { @@ -114,12 +114,12 @@ public class TileEntityElectricChest extends TileEntityElectricBlock data.add(password); return data; } - + public boolean canAccess() { return authenticated && (getEnergy() == 0 || !locked); } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -131,9 +131,9 @@ public class TileEntityElectricChest extends TileEntityElectricBlock return true; } } - + @Override - public int[] getAccessibleSlotsFromSide(int side) + public int[] getAccessibleSlotsFromSide(int side) { if(side == 0 || !canAccess()) { @@ -143,13 +143,13 @@ public class TileEntityElectricChest extends TileEntityElectricBlock if(INV == null) { INV = new int[55]; - + for(int i = 0; i < INV.length; i++) { INV[i] = i; } } - + return INV; } } @@ -165,13 +165,13 @@ public class TileEntityElectricChest extends TileEntityElectricBlock return true; } } - + @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { return false; } - + @Override public boolean canSetFacing(int side) { diff --git a/common/mekanism/common/tile/TileEntityElectricMachine.java b/common/mekanism/common/tile/TileEntityElectricMachine.java index f3a7aac43..c0dfd9b13 100644 --- a/common/mekanism/common/tile/TileEntityElectricMachine.java +++ b/common/mekanism/common/tile/TileEntityElectricMachine.java @@ -17,9 +17,9 @@ import dan200.computer.api.ILuaContext; public abstract class TileEntityElectricMachine extends TileEntityBasicMachine { /** - * A simple electrical machine. This has 3 slots - the input slot (0), the energy slot (1), + * A simple electrical machine. This has 3 slots - the input slot (0), the energy slot (1), * output slot (2), and the upgrade slot (3). It will not run if it does not have enough energy. - * + * * @param soundPath - location of the sound effect * @param name - full name of this machine * @param location - GUI texture path of this machine @@ -30,34 +30,34 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine public TileEntityElectricMachine(String soundPath, String name, ResourceLocation location, double perTick, int ticksRequired, double maxEnergy) { super(soundPath, name, location, perTick, ticksRequired, maxEnergy); - + sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {0})); sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1})); sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {2})); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {3})); - + sideConfig = new byte[] {2, 1, 0, 0, 4, 3}; - + inventory = new ItemStack[4]; - + upgradeComponent = new TileComponentUpgrade(this, 3); ejectorComponent = new TileComponentEjector(this, sideOutputs.get(3)); } - + @Override public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { ChargeUtils.discharge(1, this); - + if(canOperate() && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK)) { setActive(true); - + if((operatingTicks+1) < MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) { operatingTicks++; @@ -66,7 +66,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine else if((operatingTicks+1) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) { operate(); - + operatingTicks = 0; electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK); } @@ -77,16 +77,16 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine setActive(false); } } - + if(!canOperate()) { operatingTicks = 0; } - + prevEnergy = getEnergy(); } } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -106,61 +106,61 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine { return ChargeUtils.canBeDischarged(itemstack); } - + return false; } @Override - public void operate() - { - ItemStack itemstack = RecipeHandler.getOutput(inventory[0], true, getRecipes()); + public void operate() + { + ItemStack itemstack = RecipeHandler.getOutput(inventory[0], true, getRecipes()); - if(inventory[0].stackSize <= 0) - { - inventory[0] = null; - } + if(inventory[0].stackSize <= 0) + { + inventory[0] = null; + } - if(inventory[2] == null) - { - inventory[2] = itemstack; - } - else { - inventory[2].stackSize += itemstack.stackSize; - } + if(inventory[2] == null) + { + inventory[2] = itemstack; + } + else { + inventory[2].stackSize += itemstack.stackSize; + } - onInventoryChanged(); - ejectorComponent.onOutput(); - } + onInventoryChanged(); + ejectorComponent.onOutput(); + } @Override - public boolean canOperate() - { - if(inventory[0] == null) - { - return false; - } + public boolean canOperate() + { + if(inventory[0] == null) + { + return false; + } - ItemStack itemstack = RecipeHandler.getOutput(inventory[0], false, getRecipes()); + ItemStack itemstack = RecipeHandler.getOutput(inventory[0], false, getRecipes()); - if(itemstack == null) - { - return false; - } + if(itemstack == null) + { + return false; + } - if(inventory[2] == null) - { - return true; - } + if(inventory[2] == null) + { + return true; + } + + if(!inventory[2].isItemEqual(itemstack)) + { + return false; + } + else { + return inventory[2].stackSize + itemstack.stackSize <= inventory[2].getMaxStackSize(); + } + } - if(!inventory[2].isItemEqual(itemstack)) - { - return false; - } - else { - return inventory[2].stackSize + itemstack.stackSize <= inventory[2].getMaxStackSize(); - } - } - @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -172,18 +172,18 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine { return true; } - + return false; } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { diff --git a/common/mekanism/common/tile/TileEntityElectricPump.java b/common/mekanism/common/tile/TileEntityElectricPump.java index 6f635cc8f..fe33d58f4 100644 --- a/common/mekanism/common/tile/TileEntityElectricPump.java +++ b/common/mekanism/common/tile/TileEntityElectricPump.java @@ -38,25 +38,25 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I { /** This pump's tank */ public FluidTank fluidTank; - + /** The nodes that have full sources near them or in them */ public Set recurringNodes = new HashSet(); - + /** The nodes that have already been sucked up, but are held on to in order to remove dead blocks */ public Set cleaningNodes = new HashSet(); - + public TileEntityElectricPump() { super("ElectricPump", 10000); fluidTank = new FluidTank(10000); inventory = new ItemStack[3]; } - + @Override public void onUpdate() { ChargeUtils.discharge(2, this); - + if(inventory[0] != null) { if(fluidTank.getFluid() != null && fluidTank.getFluid().amount >= FluidContainerRegistry.BUCKET_VOLUME) @@ -64,42 +64,42 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I if(FluidContainerRegistry.isEmptyContainer(inventory[0])) { ItemStack tempStack = FluidContainerRegistry.fillFluidContainer(fluidTank.getFluid(), inventory[0]); - + if(tempStack != null) { if(inventory[1] == null) { fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); - + inventory[1] = tempStack; inventory[0].stackSize--; - + if(inventory[0].stackSize <= 0) { inventory[0] = null; } - + onInventoryChanged(); } else if(tempStack.isItemEqual(inventory[1]) && tempStack.getMaxStackSize() > inventory[1].stackSize) { fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); - + inventory[1].stackSize++; inventory[0].stackSize--; - + if(inventory[0].stackSize <= 0) { inventory[0] = null; } - + onInventoryChanged(); } } } } } - + if(!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) { if(getEnergy() >= 100 && (fluidTank.getFluid() == null || fluidTank.getFluid().amount+FluidContainerRegistry.BUCKET_VOLUME <= 10000)) @@ -108,25 +108,25 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I { PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this), 50D); } - + clean(true); } } - + super.onUpdate(); - - if(fluidTank.getFluid() != null) + + if(fluidTank.getFluid() != null) { - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { TileEntity tileEntity = Coord4D.get(this).getFromSide(orientation).getTileEntity(worldObj); - if(tileEntity instanceof IFluidHandler) + if(tileEntity instanceof IFluidHandler) { FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(100, fluidTank.getFluidAmount())); fluidTank.drain(((IFluidHandler)tileEntity).fill(orientation.getOpposite(), toDrain, true), true); - - if(fluidTank.getFluid() == null || fluidTank.getFluid().amount <= 0) + + if(fluidTank.getFluid() == null || fluidTank.getFluid().amount <= 0) { break; } @@ -134,16 +134,16 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I } } } - + public boolean suck(boolean take) { List tempPumpList = Arrays.asList(recurringNodes.toArray(new Coord4D[recurringNodes.size()])); Collections.shuffle(tempPumpList); - + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { Coord4D wrapper = Coord4D.get(this).getFromSide(orientation); - + if(MekanismUtils.isFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord)) { if(fluidTank.getFluid() == null || MekanismUtils.getFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord).isFluidEqual(fluidTank.getFluid())) @@ -155,12 +155,12 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I fluidTank.fill(MekanismUtils.getFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord), true); worldObj.setBlockToAir(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord); } - + return true; } } } - + for(Coord4D wrapper : cleaningNodes) { if(MekanismUtils.isFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord)) @@ -173,12 +173,12 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I fluidTank.fill(MekanismUtils.getFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord), true); worldObj.setBlockToAir(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord); } - + return true; } } } - + for(Coord4D wrapper : tempPumpList) { if(MekanismUtils.isFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord)) @@ -191,15 +191,15 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I fluidTank.fill(MekanismUtils.getFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord), true); worldObj.setBlockToAir(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord); } - + return true; } } - + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { Coord4D side = wrapper.getFromSide(orientation); - + if(Coord4D.get(this).distanceTo(side) <= 80) { if(MekanismUtils.isFluid(worldObj, side.xCoord, side.yCoord, side.zCoord)) @@ -213,24 +213,24 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I fluidTank.fill(MekanismUtils.getFluid(worldObj, side.xCoord, side.yCoord, side.zCoord), true); worldObj.setBlockToAir(side.xCoord, side.yCoord, side.zCoord); } - + return true; } } } } - + cleaningNodes.add(wrapper); recurringNodes.remove(wrapper); } - + return false; } - + public boolean clean(boolean take) { boolean took = false; - + if(!worldObj.isRemote) { for(Coord4D wrapper : cleaningNodes) @@ -240,7 +240,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I if(fluidTank.getFluid() != null && MekanismUtils.getFluidId(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord) == fluidTank.getFluid().fluidID) { took = true; - + if(take) { worldObj.setBlockToAir(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord); @@ -248,7 +248,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I } } } - + for(Coord4D wrapper : recurringNodes) { if(MekanismUtils.isDeadFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord)) @@ -256,7 +256,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I if(fluidTank.getFluid() != null && MekanismUtils.getFluidId(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord) == fluidTank.getFluid().fluidID) { took = true; - + if(take) { worldObj.setBlockToAir(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord); @@ -264,17 +264,17 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I } } } - + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { Coord4D wrapper = Coord4D.get(this).getFromSide(orientation); - + if(MekanismUtils.isDeadFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord)) { if(fluidTank.getFluid() != null && MekanismUtils.getFluidId(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord) == fluidTank.getFluid().fluidID) { took = true; - + if(take) { worldObj.setBlockToAir(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord); @@ -283,15 +283,15 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I } } } - + return took; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + if(dataStream.readInt() == 1) { fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); @@ -299,15 +299,15 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I else { fluidTank.setFluid(null); } - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + if(fluidTank.getFluid() != null) { data.add(1); @@ -317,83 +317,83 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I else { data.add(0); } - + return data; } - + public int getScaledFluidLevel(int i) { return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / 10000 : 0; } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - if(fluidTank.getFluid() != null) - { - nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); - } - - NBTTagList recurringList = new NBTTagList(); - - for(Coord4D wrapper : recurringNodes) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - wrapper.write(tagCompound); - recurringList.appendTag(tagCompound); - } - - if(recurringList.tagCount() != 0) - { - nbtTags.setTag("recurringNodes", recurringList); - } - - NBTTagList cleaningList = new NBTTagList(); - - for(Coord4D obj : cleaningNodes) - { - cleaningList.appendTag(obj.write(new NBTTagCompound())); - } - - if(cleaningList.tagCount() != 0) - { - nbtTags.setTag("cleaningNodes", cleaningList); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - if(nbtTags.hasKey("fluidTank")) - { - fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); - } - - if(nbtTags.hasKey("recurringNodes")) - { - NBTTagList tagList = nbtTags.getTagList("recurringNodes"); - - for(int i = 0; i < tagList.tagCount(); i++) - { - recurringNodes.add(Coord4D.read((NBTTagCompound)tagList.tagAt(i))); - } - } - - if(nbtTags.hasKey("cleaningNodes")) - { - NBTTagList tagList = nbtTags.getTagList("cleaningNodes"); - - for(int i = 0; i < tagList.tagCount(); i++) - { - cleaningNodes.add(Coord4D.read((NBTTagCompound)tagList.tagAt(i))); - } - } - } - + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + if(fluidTank.getFluid() != null) + { + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); + } + + NBTTagList recurringList = new NBTTagList(); + + for(Coord4D wrapper : recurringNodes) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + wrapper.write(tagCompound); + recurringList.appendTag(tagCompound); + } + + if(recurringList.tagCount() != 0) + { + nbtTags.setTag("recurringNodes", recurringList); + } + + NBTTagList cleaningList = new NBTTagList(); + + for(Coord4D obj : cleaningNodes) + { + cleaningList.appendTag(obj.write(new NBTTagCompound())); + } + + if(cleaningList.tagCount() != 0) + { + nbtTags.setTag("cleaningNodes", cleaningList); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + if(nbtTags.hasKey("fluidTank")) + { + fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); + } + + if(nbtTags.hasKey("recurringNodes")) + { + NBTTagList tagList = nbtTags.getTagList("recurringNodes"); + + for(int i = 0; i < tagList.tagCount(); i++) + { + recurringNodes.add(Coord4D.read((NBTTagCompound)tagList.tagAt(i))); + } + } + + if(nbtTags.hasKey("cleaningNodes")) + { + NBTTagList tagList = nbtTags.getTagList("cleaningNodes"); + + for(int i = 0; i < tagList.tagCount(); i++) + { + cleaningNodes.add(Coord4D.read((NBTTagCompound)tagList.tagAt(i))); + } + } + } + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -409,10 +409,10 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I { return ChargeUtils.canBeDischarged(itemstack); } - + return true; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -424,22 +424,22 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I { return true; } - + return false; } - + @Override protected EnumSet getConsumingSides() { return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); } - + @Override public boolean canSetFacing(int side) { return side != 0 && side != 1; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -457,70 +457,70 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection direction) + public FluidTankInfo[] getTankInfo(ForgeDirection direction) { if(direction == ForgeDirection.getOrientation(1)) { return new FluidTankInfo[] {fluidTank.getInfo()}; } - + return PipeUtils.EMPTY; } @Override - public void setFluidStack(FluidStack fluidStack, Object... data) + public void setFluidStack(FluidStack fluidStack, Object... data) { fluidTank.setFluid(fluidStack); } @Override - public FluidStack getFluidStack(Object... data) + public FluidStack getFluidStack(Object... data) { return fluidTank.getFluid(); } @Override - public boolean hasTank(Object... data) + public boolean hasTank(Object... data) { return true; } @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid() && from == ForgeDirection.getOrientation(1)) { return drain(from, resource.amount, doDrain); } - + return null; } - + @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { return 0; } @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { if(from == ForgeDirection.getOrientation(1)) { return fluidTank.drain(maxDrain, doDrain); } - + return null; } @Override - public boolean canFill(ForgeDirection from, Fluid fluid) + public boolean canFill(ForgeDirection from, Fluid fluid) { return false; } @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) + public boolean canDrain(ForgeDirection from, Fluid fluid) { return from == ForgeDirection.getOrientation(1); } @@ -530,9 +530,9 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I { recurringNodes.clear(); cleaningNodes.clear(); - + player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.pumpReset"))); - + return true; } diff --git a/common/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/common/mekanism/common/tile/TileEntityElectrolyticSeparator.java index 822a0088d..5322a9f76 100644 --- a/common/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/common/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -44,22 +44,22 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { /** This separator's water slot. */ public FluidTank fluidTank = new FluidTank(24000); - + /** The maximum amount of gas this block can store. */ public int MAX_GAS = 2400; - + /** The amount of oxygen this block is storing. */ public GasTank leftTank = new GasTank(MAX_GAS); - + /** The amount of hydrogen this block is storing. */ public GasTank rightTank = new GasTank(MAX_GAS); - + /** How fast this block can output gas. */ public int output = 16; - + /** The type of gas this block is outputting. */ public boolean dumpLeft = false; - + /** Type type of gas this block is dumping. */ public boolean dumpRight = false; @@ -68,26 +68,26 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp super("ElectrolyticSeparator", MachineType.ELECTROLYTIC_SEPARATOR.baseEnergy); inventory = new ItemStack[4]; } - + @Override public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { ChargeUtils.discharge(3, this); - + if(inventory[0] != null) { if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory[0])) { FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - + if(fluidTank.getFluid() == null || fluid.isFluidEqual(fluidTank.getFluid()) && fluidTank.getFluid().amount+fluid.amount <= fluidTank.getCapacity()) { fluidTank.fill(fluid, true); - + if(inventory[0].getItem().hasContainerItem()) { inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]); @@ -95,7 +95,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp else { inventory[0].stackSize--; } - + if(inventory[0].stackSize == 0) { inventory[0] = null; @@ -103,7 +103,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } } } - + if(!worldObj.isRemote) { if(inventory[1] != null && leftTank.getStored() > 0) @@ -111,14 +111,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp leftTank.draw(GasTransmission.addGas(inventory[1], leftTank.getGas()), true); MekanismUtils.saveChunk(this); } - + if(inventory[2] != null && rightTank.getStored() > 0) { rightTank.draw(GasTransmission.addGas(inventory[2], rightTank.getGas()), true); MekanismUtils.saveChunk(this); } } - + if(canOperate()) { fillTanks(RecipeHandler.getElectrolyticSeparatorOutput(fluidTank, true)); @@ -193,16 +193,16 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return false; } - + return canFill(gases) || canFill(gases.swap()); } - + public boolean canFill(ChemicalPair gases) - { + { return (leftTank.canReceive(gases.leftGas.getGas()) && leftTank.getNeeded() >= gases.leftGas.amount && rightTank.canReceive(gases.rightGas.getGas()) && rightTank.getNeeded() >= gases.rightGas.amount); } - + public void fillTanks(ChemicalPair gases) { if(gases == null) return; @@ -218,18 +218,18 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp rightTank.receive(gases.leftGas, true); } } - + public void spawnParticle(int type) { if(type == 0) { ForgeDirection side = ForgeDirection.getOrientation(facing); - + double x = xCoord + (side.offsetX == 0 ? 0.5 : Math.max(side.offsetX, 0)); double z = zCoord + (side.offsetZ == 0 ? 0.5 : Math.max(side.offsetZ, 0)); - + worldObj.spawnParticle("smoke", x, yCoord + 0.5, z, 0.0D, 0.0D, 0.0D); - + } else if(type == 1) { @@ -250,7 +250,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } } } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -264,13 +264,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } else if(slotID == 1 || slotID == 2) { - return itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && + return itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && ((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack); } - + return false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -290,10 +290,10 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return ChargeUtils.canBeDischarged(itemstack); } - + return true; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -305,10 +305,10 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return new int[] {1, 2}; } - + return new int[] {0}; } - + /** * Gets the scaled hydrogen level for the GUI. * @param i - multiplier @@ -318,7 +318,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return leftTank.getStored()*i / MAX_GAS; } - + /** * Gets the scaled oxygen level for the GUI. * @param i - multiplier @@ -328,7 +328,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return rightTank.getStored()*i / MAX_GAS; } - + /** * Gets the scaled water level for the GUI. * @param i - multiplier @@ -338,7 +338,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / fluidTank.getCapacity() : 0; } - + /** * Gets the scaled energy level for the GUI. * @param i - multiplier @@ -348,14 +348,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return (int)(electricityStored*i / MAX_ELECTRICITY); } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { byte type = dataStream.readByte(); - + if(type == 0) { dumpLeft ^= true; @@ -364,14 +364,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { dumpRight ^= true; } - + return; } - + super.handlePacketData(dataStream); - + int type = dataStream.readInt(); - + if(type == 0) { if(dataStream.readBoolean()) @@ -406,7 +406,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp spawnParticle(dataStream.readInt()); } } - + @Override public ArrayList getNetworkedData(ArrayList data) { @@ -449,7 +449,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp return data; } - + public ArrayList getParticlePacket(int type, ArrayList data) { super.getNetworkedData(data); @@ -457,11 +457,11 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp data.add(type); return data; } - + @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); if(nbtTags.hasKey("fluidTank")) { @@ -471,41 +471,41 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp leftTank.read(nbtTags.getCompoundTag("leftTank")); rightTank.read(nbtTags.getCompoundTag("rightTank")); - dumpLeft = nbtTags.getBoolean("dumpLeft"); + dumpLeft = nbtTags.getBoolean("dumpLeft"); dumpRight = nbtTags.getBoolean("dumpRight"); - } + } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); - if(fluidTank.getFluid() != null) - { - nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); - } + if(fluidTank.getFluid() != null) + { + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); + } nbtTags.setCompoundTag("leftTank", leftTank.write(new NBTTagCompound())); nbtTags.setCompoundTag("rightTank", rightTank.write(new NBTTagCompound())); - nbtTags.setBoolean("dumpLeft", dumpLeft); + nbtTags.setBoolean("dumpLeft", dumpLeft); nbtTags.setBoolean("dumpRight", dumpRight); - } + } @Override - public String getType() + public String getType() { return getInvName(); } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getWater", "getWaterNeeded", "getHydrogen", "getHydrogenNeeded", "getOxygen", "getOxygenNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -536,7 +536,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public boolean canAttachToSide(int side) + public boolean canAttachToSide(int side) { return true; } @@ -552,51 +552,51 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing); } - + @Override - public void setFluidStack(FluidStack fluidStack, Object... data) + public void setFluidStack(FluidStack fluidStack, Object... data) { fluidTank.setFluid(fluidStack); } @Override - public FluidStack getFluidStack(Object... data) + public FluidStack getFluidStack(Object... data) { return fluidTank.getFluid(); } @Override - public boolean hasTank(Object... data) + public boolean hasTank(Object... data) { return true; } @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return null; } @Override - public boolean canFill(ForgeDirection from, Fluid fluid) + public boolean canFill(ForgeDirection from, Fluid fluid) { return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(fluid); } @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) + public boolean canDrain(ForgeDirection from, Fluid fluid) { return false; } - + @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(resource.getFluid())) { return fluidTank.fill(resource, doFill); } - + return 0; } @@ -607,19 +607,19 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) + public FluidTankInfo[] getTankInfo(ForgeDirection from) { return new FluidTankInfo[] {fluidTank.getInfo()}; } @Override - public int receiveGas(ForgeDirection side, GasStack stack) + public int receiveGas(ForgeDirection side, GasStack stack) { return 0; } @Override - public GasStack drawGas(ForgeDirection side, int amount) + public GasStack drawGas(ForgeDirection side, int amount) { if(side == MekanismUtils.getLeft(facing)) { @@ -629,7 +629,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { return rightTank.draw(amount, true); } - + return null; } diff --git a/common/mekanism/common/tile/TileEntityEliteFactory.java b/common/mekanism/common/tile/TileEntityEliteFactory.java index 46d739692..0c74a16b0 100644 --- a/common/mekanism/common/tile/TileEntityEliteFactory.java +++ b/common/mekanism/common/tile/TileEntityEliteFactory.java @@ -12,7 +12,7 @@ public class TileEntityEliteFactory extends TileEntityFactory public TileEntityEliteFactory() { super(FactoryTier.ELITE, MachineType.ELITE_FACTORY); - + sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0})); sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1})); diff --git a/common/mekanism/common/tile/TileEntityEnergizedSmelter.java b/common/mekanism/common/tile/TileEntityEnergizedSmelter.java index 992176290..daa38e083 100644 --- a/common/mekanism/common/tile/TileEntityEnergizedSmelter.java +++ b/common/mekanism/common/tile/TileEntityEnergizedSmelter.java @@ -13,12 +13,12 @@ import net.minecraft.util.ResourceLocation; public class TileEntityEnergizedSmelter extends TileEntityElectricMachine { public static Map furnaceRecipes = new HashMap(); - + public TileEntityEnergizedSmelter() { super("Smelter.ogg", "EnergizedSmelter", new ResourceLocation("mekanism", "gui/GuiEnergizedSmelter.png"), Mekanism.energizedSmelterUsage, 200, MachineType.ENERGIZED_SMELTER.baseEnergy); } - + @Override public Map getRecipes() { diff --git a/common/mekanism/common/tile/TileEntityEnergyCube.java b/common/mekanism/common/tile/TileEntityEnergyCube.java index 566eaef5a..48eade9d0 100644 --- a/common/mekanism/common/tile/TileEntityEnergyCube.java +++ b/common/mekanism/common/tile/TileEntityEnergyCube.java @@ -27,15 +27,15 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe { /** This Energy Cube's tier. */ public EnergyCubeTier tier = EnergyCubeTier.BASIC; - + /** The redstone level this Energy Cube is outputting at. */ public int currentRedstoneLevel; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType; - + public int prevScale; - + /** * A block used to store and transfer electricity. * @param energy - maximum energy this block can hold. @@ -44,37 +44,37 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe public TileEntityEnergyCube() { super("EnergyCube", 0); - + inventory = new ItemStack[2]; controlType = RedstoneControl.DISABLED; } - + @Override public void onUpdate() { super.onUpdate(); - + ChargeUtils.charge(0, this); ChargeUtils.discharge(1, this); - + if(MekanismUtils.canFunction(this)) { CableUtils.emit(this); } } - + @Override public String getInvName() { return MekanismUtils.localize(getBlockType().getUnlocalizedName() + "." + tier.name + ".name"); } - + @Override public double getMaxOutput() { return tier.OUTPUT; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -86,26 +86,26 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe { return ChargeUtils.canBeDischarged(itemstack); } - + return true; } - + @Override protected EnumSet getConsumingSides() { EnumSet set = EnumSet.allOf(ForgeDirection.class); set.removeAll(getOutputtingSides()); set.remove(ForgeDirection.UNKNOWN); - + return set; } - + @Override public EnumSet getOutputtingSides() { return EnumSet.of(ForgeDirection.getOrientation(facing)); } - + @Override public boolean canSetFacing(int side) { @@ -113,17 +113,17 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe } @Override - public double getMaxEnergy() + public double getMaxEnergy() { return tier.MAX_ELECTRICITY; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { return side == 1 ? new int[] {0} : new int[] {1}; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -135,24 +135,24 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe { return ChargeUtils.canBeOutputted(itemstack, true); } - + return false; } @Override - public String getType() + public String getType() { return getInvName(); } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -171,7 +171,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe } @Override - public boolean canAttachToSide(int side) + public boolean canAttachToSide(int side) { return true; } @@ -181,89 +181,89 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPe @Override public void detach(IComputerAccess computer) {} - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { tier = EnergyCubeTier.getFromName(dataStream.readUTF()); - + super.handlePacketData(dataStream); - + controlType = RedstoneControl.values()[dataStream.readInt()]; - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { data.add(tier.name); - + super.getNetworkedData(data); - + data.add(controlType.ordinal()); - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - tier = EnergyCubeTier.getFromName(nbtTags.getString("tier")); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setString("tier", tier.name); - nbtTags.setInteger("controlType", controlType.ordinal()); - } - - @Override - public void setEnergy(double energy) + public void readFromNBT(NBTTagCompound nbtTags) { - super.setEnergy(energy); - - int newRedstoneLevel = getRedstoneLevel(); - - if(newRedstoneLevel != currentRedstoneLevel) - { - onInventoryChanged(); - currentRedstoneLevel = newRedstoneLevel; - } - - if(!worldObj.isRemote) - { - int newScale = getScaledEnergyLevel(100); - - if(newScale != prevScale) - { - PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this), 50D); - } - - prevScale = newScale; - } + super.readFromNBT(nbtTags); + + tier = EnergyCubeTier.getFromName(nbtTags.getString("tier")); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setString("tier", tier.name); + nbtTags.setInteger("controlType", controlType.ordinal()); + } + + @Override + public void setEnergy(double energy) + { + super.setEnergy(energy); + + int newRedstoneLevel = getRedstoneLevel(); + + if(newRedstoneLevel != currentRedstoneLevel) + { + onInventoryChanged(); + currentRedstoneLevel = newRedstoneLevel; + } + + if(!worldObj.isRemote) + { + int newScale = getScaledEnergyLevel(100); + + if(newScale != prevScale) + { + PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this), 50D); + } + + prevScale = newScale; + } } public int getRedstoneLevel() { - double fractionFull = getEnergy()/getMaxEnergy(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); + double fractionFull = getEnergy()/getMaxEnergy(); + return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; } diff --git a/common/mekanism/common/tile/TileEntityEnrichmentChamber.java b/common/mekanism/common/tile/TileEntityEnrichmentChamber.java index 0b817e774..dc8ca4397 100644 --- a/common/mekanism/common/tile/TileEntityEnrichmentChamber.java +++ b/common/mekanism/common/tile/TileEntityEnrichmentChamber.java @@ -13,13 +13,13 @@ public class TileEntityEnrichmentChamber extends TileEntityElectricMachine { super("Chamber.ogg", "EnrichmentChamber", new ResourceLocation("mekanism", "gui/GuiChamber.png"), Mekanism.enrichmentChamberUsage, 200, MachineType.ENRICHMENT_CHAMBER.baseEnergy); } - + @Override public Map getRecipes() { return Recipe.ENRICHMENT_CHAMBER.get(); } - + @Override public float getVolumeMultiplier() { diff --git a/common/mekanism/common/tile/TileEntityFactory.java b/common/mekanism/common/tile/TileEntityFactory.java index 9d647ae70..b89433dd4 100644 --- a/common/mekanism/common/tile/TileEntityFactory.java +++ b/common/mekanism/common/tile/TileEntityFactory.java @@ -44,95 +44,95 @@ import dan200.computer.api.ILuaContext; import dan200.computer.api.IPeripheral; public class TileEntityFactory extends TileEntityElectricBlock implements IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl, IGasHandler, ITubeConnection -{ +{ /** This Factory's tier. */ public FactoryTier tier; - + /** This machine's side configuration. */ public byte[] sideConfig = new byte[] {5, 4, 0, 3, 2, 1}; - + /** An arraylist of SideData for this machine. */ public ArrayList sideOutputs = new ArrayList(); - + /** An int[] used to track all current operations' progress. */ public int[] progress; - + /** How many ticks it takes, by default, to run an operation. */ public int TICKS_REQUIRED = 200; - + /** How much energy each operation consumes per tick. */ public double ENERGY_PER_TICK = Mekanism.factoryUsage; - + /** How long it takes this factory to switch recipe types. */ public int RECIPE_TICKS_REQUIRED = 40; - + /** How many recipe ticks have progressed. */ public int recipeTicks; - + /** The client's current active state. */ public boolean clientActive; - + /** This machine's active state. */ public boolean isActive; - + /** How many ticks must pass until this block's active state can sync with the client. */ public int updateDelay; - + /** This machine's recipe type. */ public int recipeType; - + /** This machine's previous amount of energy. */ public double prevEnergy; - + public GasTank gasTank; - + public boolean sorting; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 0); public TileComponentEjector ejectorComponent; - + public TileEntityFactory() { this(FactoryTier.BASIC, MachineType.BASIC_FACTORY); - + sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0})); sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1})); sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {4})); sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7})); sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {8, 9, 10})); - + ejectorComponent = new TileComponentEjector(this, sideOutputs.get(5)); } - + public TileEntityFactory(FactoryTier type, MachineType machine) { super(type.name + "Factory", machine.baseEnergy); - + tier = type; inventory = new ItemStack[5+type.processes*2]; progress = new int[type.processes]; isActive = false; - + gasTank = new GasTank(TileEntityAdvancedElectricMachine.MAX_GAS*tier.processes); } - + @Override public void onUpdate() { super.onUpdate(); - + if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -140,33 +140,33 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip } } } - + if(!worldObj.isRemote) { if(ticker == 1) { worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID); } - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + ChargeUtils.discharge(1, this); - + handleSecondaryFuel(); sortInventory(); - + if(inventory[2] != null && inventory[3] == null) { RecipeType toSet = null; - + for(RecipeType type : RecipeType.values()) { if(inventory[2].isItemEqual(type.getStack())) @@ -175,7 +175,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip break; } } - + if(toSet != null && recipeType != toSet.ordinal()) { if(recipeTicks < RECIPE_TICKS_REQUIRED) @@ -185,15 +185,15 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip else if(recipeTicks == RECIPE_TICKS_REQUIRED) { recipeTicks = 0; - + inventory[2] = null; inventory[3] = getMachineStack(); - + recipeType = toSet.ordinal(); gasTank.setGas(null); - + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID); - + MekanismUtils.saveChunk(this); } } @@ -204,7 +204,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip else { recipeTicks = 0; } - + for(int process = 0; process < tier.processes; process++) { if(MekanismUtils.canFunction(this) && canOperate(getInputSlot(process), getOutputSlot(process)) && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK) && gasTank.getStored() >= getSecondaryEnergyPerTick()) @@ -218,13 +218,13 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip else if((progress[process]+1) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) { operate(getInputSlot(process), getOutputSlot(process)); - + progress[process] = 0; gasTank.draw(getSecondaryEnergyPerTick(), true); electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK); } } - + if(!canOperate(getInputSlot(process), getOutputSlot(process))) { if(!RecipeType.values()[recipeType].usesFuel() || !RecipeType.values()[recipeType].hasRecipe(inventory[getInputSlot(process)])) @@ -233,9 +233,9 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip } } } - + boolean hasOperation = false; - + for(int i = 0; i < tier.processes; i++) { if(canOperate(getInputSlot(i), getOutputSlot(i))) @@ -244,7 +244,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip break; } } - + if(MekanismUtils.canFunction(this) && hasOperation && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK) && gasTank.getStored() >= getSecondaryEnergyPerTick()) { setActive(true); @@ -255,21 +255,21 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip setActive(false); } } - + prevEnergy = getEnergy(); } } - + public void sortInventory() { if(sorting) { boolean didOp = false; - + int[] inputSlots = null; - + List invStacks = new ArrayList(); - + if(tier == FactoryTier.BASIC) { inputSlots = new int[] {5, 6, 7}; @@ -282,26 +282,26 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip { inputSlots = new int[] {5, 6, 7, 8, 9, 10, 11}; } - + for(int id : inputSlots) { invStacks.add(InvID.get(id, inventory)); } - + for(InvID invID1 : invStacks) { for(InvID invID2 : invStacks) { if(invID1.ID == invID2.ID || StackUtils.diffIgnoreNull(invID1.stack, invID2.stack) || Math.abs(invID1.size()-invID2.size()) < 2) continue; - + List evened = StackUtils.even(inventory[invID1.ID], inventory[invID2.ID]); inventory[invID1.ID] = evened.get(0); inventory[invID2.ID] = evened.get(1); - + didOp = true; break; } - + if(didOp) { onInventoryChanged(); @@ -310,78 +310,78 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip } } } - + public static class InvID { public ItemStack stack; public int ID; - + public InvID(ItemStack s, int i) { stack = s; ID = i; } - + public int size() { return stack != null ? stack.stackSize : 0; } - + public int id() { return stack != null ? stack.itemID : 0; } - + public static InvID get(int id, ItemStack[] inv) { return new InvID(inv[id], id); } } - + public int getSecondaryEnergyPerTick() { return RecipeType.values()[recipeType].getSecondaryEnergyPerTick(); } - + public void handleSecondaryFuel() - { + { if(inventory[4] != null && RecipeType.values()[recipeType].usesFuel() && gasTank.getNeeded() > 0) { if(inventory[4].getItem() instanceof IGasItem) { GasStack gas = ((IGasItem)inventory[4].getItem()).getGas(inventory[4]); - + if(gas != null && RecipeType.values()[recipeType].isValidGas(gas.getGas())) { GasStack removed = GasTransmission.removeGas(inventory[4], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, gasTank.getNeeded()); gasTank.receive(removed, true); } - + return; } - + GasStack stack = RecipeType.values()[recipeType].getItemGas(inventory[4]); int gasNeeded = gasTank.getNeeded(); - + if(stack != null && stack.amount <= gasNeeded) { gasTank.receive(stack, true); - + inventory[4].stackSize--; - + if(inventory[4].stackSize == 0) { inventory[4] = null; } } } - } - + } + public ItemStack getMachineStack() { return RecipeType.values()[recipeType].getStack(); } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -401,10 +401,10 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip { return true; } - + return false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -441,7 +441,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip return RecipeType.values()[recipeType].getCopiedOutput(itemstack, gasTank.getGas() != null ? gasTank.getGas().getGas() : null, false) != null; } } - + if(slotID == 0) { return itemstack.itemID == Mekanism.SpeedUpgrade.itemID || itemstack.itemID == Mekanism.EnergyUpgrade.itemID; @@ -454,123 +454,123 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip { return RecipeType.values()[recipeType].getItemGas(itemstack) != null; } - + return false; } - + @Override public void invalidate() { super.invalidate(); - + if(worldObj.isRemote) { Mekanism.proxy.unregisterSound(this); } } - + public int getScaledProgress(int i, int process) { return progress[process]*i / MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED); } - + public int getScaledGasLevel(int i) { return gasTank.getStored()*i / gasTank.getMaxGas(); } - + public int getScaledRecipeProgress(int i) { return recipeTicks*i / RECIPE_TICKS_REQUIRED; } - + public boolean canOperate(int inputSlot, int outputSlot) { - if(inventory[inputSlot] == null) - { - return false; - } + if(inventory[inputSlot] == null) + { + return false; + } - ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, false); + ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, false); - if(itemstack == null) - { - return false; - } + if(itemstack == null) + { + return false; + } - if(inventory[outputSlot] == null) - { - return true; - } + if(inventory[outputSlot] == null) + { + return true; + } - if(!inventory[outputSlot].isItemEqual(itemstack)) - { - return false; - } - else { - return inventory[outputSlot].stackSize + itemstack.stackSize <= inventory[outputSlot].getMaxStackSize(); - } + if(!inventory[outputSlot].isItemEqual(itemstack)) + { + return false; + } + else { + return inventory[outputSlot].stackSize + itemstack.stackSize <= inventory[outputSlot].getMaxStackSize(); + } } - + public void operate(int inputSlot, int outputSlot) { - if(!canOperate(inputSlot, outputSlot)) - { - return; - } + if(!canOperate(inputSlot, outputSlot)) + { + return; + } - ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, true); + ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, true); - if(inventory[inputSlot].stackSize <= 0) - { - inventory[inputSlot] = null; - } + if(inventory[inputSlot].stackSize <= 0) + { + inventory[inputSlot] = null; + } - if(inventory[outputSlot] == null) - { - inventory[outputSlot] = itemstack; - } - else { - inventory[outputSlot].stackSize += itemstack.stackSize; - } - - onInventoryChanged(); - ejectorComponent.onOutput(); + if(inventory[outputSlot] == null) + { + inventory[outputSlot] = itemstack; + } + else { + inventory[outputSlot].stackSize += itemstack.stackSize; + } + + onInventoryChanged(); + ejectorComponent.onOutput(); } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { sorting = !sorting; } - + return; } - + super.handlePacketData(dataStream); - + clientActive = dataStream.readBoolean(); recipeType = dataStream.readInt(); recipeTicks = dataStream.readInt(); controlType = RedstoneControl.values()[dataStream.readInt()]; sorting = dataStream.readBoolean(); - + for(int i = 0; i < tier.processes; i++) { progress[i] = dataStream.readInt(); } - + for(int i = 0; i < 6; i++) { sideConfig[i] = dataStream.readByte(); } - + if(dataStream.readBoolean()) { gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); @@ -578,7 +578,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip else { gasTank.setGas(null); } - + if(updateDelay == 0 && clientActive != isActive) { updateDelay = Mekanism.UPDATE_DELAY; @@ -586,65 +586,65 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - clientActive = isActive = nbtTags.getBoolean("isActive"); - recipeType = nbtTags.getInteger("recipeType"); - recipeTicks = nbtTags.getInteger("recipeTicks"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - sorting = nbtTags.getBoolean("sorting"); - - for(int i = 0; i < tier.processes; i++) - { - progress[i] = nbtTags.getInteger("progress" + i); - } - - if(nbtTags.hasKey("sideDataStored")) - { - for(int i = 0; i < 6; i++) - { - sideConfig[i] = nbtTags.getByte("config"+i); - } - } - - gasTank.read(nbtTags.getCompoundTag("gasTank")); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("recipeType", recipeType); - nbtTags.setInteger("recipeTicks", recipeTicks); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setBoolean("sorting", sorting); - - for(int i = 0; i < tier.processes; i++) - { - nbtTags.setInteger("progress" + i, progress[i]); - } - - nbtTags.setBoolean("sideDataStored", true); - - for(int i = 0; i < 6; i++) - { - nbtTags.setByte("config"+i, sideConfig[i]); - } - - nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + clientActive = isActive = nbtTags.getBoolean("isActive"); + recipeType = nbtTags.getInteger("recipeType"); + recipeTicks = nbtTags.getInteger("recipeTicks"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + sorting = nbtTags.getBoolean("sorting"); + + for(int i = 0; i < tier.processes; i++) + { + progress[i] = nbtTags.getInteger("progress" + i); + } + + if(nbtTags.hasKey("sideDataStored")) + { + for(int i = 0; i < 6; i++) + { + sideConfig[i] = nbtTags.getByte("config"+i); + } + } + + gasTank.read(nbtTags.getCompoundTag("gasTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("recipeType", recipeType); + nbtTags.setInteger("recipeTicks", recipeTicks); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setBoolean("sorting", sorting); + + for(int i = 0; i < tier.processes; i++) + { + nbtTags.setInteger("progress" + i, progress[i]); + } + + nbtTags.setBoolean("sideDataStored", true); + + for(int i = 0; i < 6; i++) + { + nbtTags.setByte("config"+i, sideConfig[i]); + } + + nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); + } + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(recipeType); data.add(recipeTicks); @@ -652,7 +652,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip data.add(sorting); data.add(progress); data.add(sideConfig); - + if(gasTank.getGas() != null) { data.add(true); @@ -662,15 +662,15 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip else { data.add(false); } - + return data; } - + public int getInputSlot(int operation) { return operation+5; } - + public int getOutputSlot(int operation) { return tier.processes+5+operation; @@ -683,13 +683,13 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -700,17 +700,17 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip { return new Object[] {"Please provide a target operation."}; } - + if(!(arguments[0] instanceof Double) && !(arguments[0] instanceof Integer)) { return new Object[] {"Invalid characters."}; } - + if((Integer)arguments[0] < 0 || (Integer)arguments[0] > progress.length) { return new Object[] {"No such operation found."}; } - + return new Object[] {progress[(Integer)arguments[0]]}; case 2: return new Object[] {facing}; @@ -719,17 +719,17 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip { return new Object[] {"Please provide a target operation."}; } - + if(!(arguments[0] instanceof Double) && !(arguments[0] instanceof Integer)) { return new Object[] {"Invalid characters."}; } - + if((Integer)arguments[0] < 0 || (Integer)arguments[0] > progress.length) { return new Object[] {"No such operation found."}; } - + return new Object[] {canOperate(getInputSlot((Integer)arguments[0]), getOutputSlot((Integer)arguments[0]))}; case 4: return new Object[] {getMaxEnergy()}; @@ -754,87 +754,87 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip public void detach(IComputerAccess computer) {} @Override - public double getMaxEnergy() + public double getMaxEnergy() { return MekanismUtils.getMaxEnergy(getEnergyMultiplier(), MAX_ELECTRICITY); } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + @Override public int[] getAccessibleSlotsFromSide(int side) { return sideOutputs.get(sideConfig[MekanismUtils.getBaseOrientation(side, facing)]).availableSlots; } - + @Override public boolean canSetFacing(int side) { return side != 0 && side != 1; } - + @Override public ArrayList getSideData() { return sideOutputs; } - + @Override public byte[] getConfiguration() { return sideConfig; } - + @Override public int getOrientation() { return facing; } - + @Override - public int getEnergyMultiplier(Object... data) + public int getEnergyMultiplier(Object... data) { return upgradeComponent.energyMultiplier; } @Override - public void setEnergyMultiplier(int multiplier, Object... data) + public void setEnergyMultiplier(int multiplier, Object... data) { upgradeComponent.energyMultiplier = multiplier; MekanismUtils.saveChunk(this); } @Override - public int getSpeedMultiplier(Object... data) + public int getSpeedMultiplier(Object... data) { return upgradeComponent.speedMultiplier; } @Override - public void setSpeedMultiplier(int multiplier, Object... data) + public void setSpeedMultiplier(int multiplier, Object... data) { upgradeComponent.speedMultiplier = multiplier; MekanismUtils.saveChunk(this); } - + @Override public boolean supportsUpgrades(Object... data) { @@ -846,15 +846,15 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip { return RecipeType.values()[recipeType].getSound(); } - + @Override public float getVolumeMultiplier() { return 1; } - + @Override - public boolean renderUpdate() + public boolean renderUpdate() { return true; } @@ -864,26 +864,26 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip { return true; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); } - + @Override public TileComponentUpgrade getComponent() { return upgradeComponent; } - + @Override public IEjector getEjector() { @@ -891,13 +891,13 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip } @Override - public int receiveGas(ForgeDirection side, GasStack stack) + public int receiveGas(ForgeDirection side, GasStack stack) { if(canReceiveGas(side, stack.getGas())) { return gasTank.receive(stack, true); } - + return 0; } diff --git a/common/mekanism/common/tile/TileEntityGasTank.java b/common/mekanism/common/tile/TileEntityGasTank.java index ffa950ad2..e2e696573 100644 --- a/common/mekanism/common/tile/TileEntityGasTank.java +++ b/common/mekanism/common/tile/TileEntityGasTank.java @@ -28,44 +28,44 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH { /** The type of gas stored in this tank. */ public GasTank gasTank = new GasTank(MAX_GAS); - + public static final int MAX_GAS = 96000; - + /** How fast this tank can output gas. */ public int output = 16; - + public boolean dumping; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType; - + public TileEntityGasTank() { super("GasTank"); inventory = new ItemStack[2]; controlType = RedstoneControl.DISABLED; } - + @Override public void onUpdate() - { + { if(inventory[0] != null && gasTank.getGas() != null) { gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true); } - + if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas())) { gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, gasTank.getNeeded()), true); } - + if(!worldObj.isRemote && gasTank.getGas() != null && MekanismUtils.canFunction(this)) { GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), output)); gasTank.draw(GasTransmission.emitGasToNetwork(toSend, this, ForgeDirection.getOrientation(facing)), true); - + TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj); - + if(tileEntity instanceof IGasHandler) { if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), gasTank.getGas().getGas())) @@ -74,13 +74,13 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH } } } - + if(!worldObj.isRemote && dumping) { gasTank.draw(8, true); } } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -93,10 +93,10 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && ((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack)); } - + return false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -108,10 +108,10 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH { return itemstack.getItem() instanceof IGasItem && (gasTank.getGas() == null || ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, gasTank.getGas().getGas())); } - + return true; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -119,7 +119,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH } @Override - public int receiveGas(ForgeDirection side, GasStack stack) + public int receiveGas(ForgeDirection side, GasStack stack) { return gasTank.receive(stack, true); } @@ -137,38 +137,38 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH } @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) + public boolean canReceiveGas(ForgeDirection side, Gas type) { if(side != ForgeDirection.getOrientation(facing)) { return gasTank.canReceive(type); } - + return false; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { dumping = !dumping; } - + for(EntityPlayer player : playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), player); } - + return; } - + super.handlePacketData(dataStream); - + if(dataStream.readBoolean()) { gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -176,38 +176,38 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH else { gasTank.setGas(null); } - + dumping = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - gasTank.read(nbtTags.getCompoundTag("gasTank")); - dumping = nbtTags.getBoolean("dumping"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); - nbtTags.setBoolean("dumping", dumping); - nbtTags.setInteger("controlType", controlType.ordinal()); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + gasTank.read(nbtTags.getCompoundTag("gasTank")); + dumping = nbtTags.getBoolean("dumping"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); + nbtTags.setBoolean("dumping", dumping); + nbtTags.setInteger("controlType", controlType.ordinal()); + } + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + if(gasTank.getGas() != null) { data.add(true); @@ -217,13 +217,13 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH else { data.add(false); } - + data.add(dumping); data.add(controlType.ordinal()); - + return data; } - + @Override public boolean canSetFacing(int side) { @@ -231,19 +231,19 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH } @Override - public boolean canTubeConnect(ForgeDirection side) + public boolean canTubeConnect(ForgeDirection side) { return true; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; } diff --git a/common/mekanism/common/tile/TileEntityLogisticalSorter.java b/common/mekanism/common/tile/TileEntityLogisticalSorter.java index 467d02325..d0f21a889 100644 --- a/common/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/common/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -34,66 +34,66 @@ import com.google.common.io.ByteArrayDataInput; public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState { public HashList filters = new HashList(); - + public RedstoneControl controlType = RedstoneControl.DISABLED; - + public EnumColor color; - + public boolean autoEject; - + public boolean roundRobin; - + public int rrIndex = 0; - + public final int MAX_DELAY = 10; - + public int delayTicks; - + public boolean isActive; - + public boolean clientActive; - + public final double ENERGY_PER_ITEM = 5; - - public TileEntityLogisticalSorter() + + public TileEntityLogisticalSorter() { super("LogisticalSorter", MachineType.LOGISTICAL_SORTER.baseEnergy); inventory = new ItemStack[1]; doAutoSync = false; } - + @Override public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { delayTicks = Math.max(0, delayTicks-1); - + if(delayTicks == 6) { setActive(false); } - + if(MekanismUtils.canFunction(this) && delayTicks == 0) { TileEntity back = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj); TileEntity front = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj); - + if(back instanceof IInventory && (front instanceof ILogisticalTransporter || front instanceof IInventory)) { IInventory inventory = (IInventory)back; - + InvStack inInventory = null; boolean hasFilter = false; EnumColor filterColor = color; int min = 0; - + for(TransporterFilter filter : filters) { InvStack invStack = filter.getStackFromInventory(inventory, ForgeDirection.getOrientation(facing).getOpposite()); - + if(invStack != null && invStack.getStack() != null) { if(filter.canFilter(invStack.getStack())) @@ -101,39 +101,39 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen filterColor = filter.color; hasFilter = true; inInventory = invStack; - + if(filter instanceof TItemStackFilter) { TItemStackFilter itemFilter = (TItemStackFilter)filter; - + if(itemFilter.sizeMode) { min = itemFilter.min; } } - + break; } } } - + if(!hasFilter && autoEject) { inInventory = InventoryUtils.takeTopStack(inventory, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), new FirstFinder()); } - + if(inInventory != null && inInventory.getStack() != null) { ItemStack used = null; - + if(front instanceof ILogisticalTransporter) { ILogisticalTransporter transporter = (ILogisticalTransporter)front; - + if(!roundRobin) { ItemStack rejects = TransporterUtils.insert(this, transporter, inInventory.getStack(), filterColor, true, min); - + if(TransporterManager.didEmit(inInventory.getStack(), rejects)) { used = TransporterManager.getToUse(inInventory.getStack(), rejects); @@ -141,7 +141,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen } else { ItemStack rejects = TransporterUtils.insertRR(this, transporter, inInventory.getStack(), filterColor, true, min); - + if(TransporterManager.didEmit(inInventory.getStack(), rejects)) { used = TransporterManager.getToUse(inInventory.getStack(), rejects); @@ -151,13 +151,13 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen else if(front instanceof IInventory) { ItemStack rejects = InventoryUtils.putStackInInventory((IInventory)front, inInventory.getStack(), facing, false); - + if(TransporterManager.didEmit(inInventory.getStack(), rejects)) { used = TransporterManager.getToUse(inInventory.getStack(), rejects); } } - + if(used != null) { inInventory.use(used.stackSize); @@ -165,11 +165,11 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen setActive(true); } } - + delayTicks = 10; } } - + if(playersUsing.size() > 0) { for(EntityPlayer player : playersUsing) @@ -179,78 +179,78 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen } } } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("controlType", controlType.ordinal()); - - if(color != null) - { - nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); - } - - nbtTags.setBoolean("autoEject", autoEject); - nbtTags.setBoolean("roundRobin", roundRobin); - - nbtTags.setInteger("rrIndex", rrIndex); - - NBTTagList filterTags = new NBTTagList(); - - for(TransporterFilter filter : filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } - - if(filterTags.tagCount() != 0) - { - nbtTags.setTag("filters", filterTags); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - if(nbtTags.hasKey("color")) - { - color = TransporterUtils.colors.get(nbtTags.getInteger("color")); - } - - autoEject = nbtTags.getBoolean("autoEject"); - roundRobin = nbtTags.getBoolean("roundRobin"); - - rrIndex = nbtTags.getInteger("rrIndex"); - - if(nbtTags.hasKey("filters")) - { - NBTTagList tagList = nbtTags.getTagList("filters"); - - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i))); - } - } - } - + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("controlType", controlType.ordinal()); + + if(color != null) + { + nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); + } + + nbtTags.setBoolean("autoEject", autoEject); + nbtTags.setBoolean("roundRobin", roundRobin); + + nbtTags.setInteger("rrIndex", rrIndex); + + NBTTagList filterTags = new NBTTagList(); + + for(TransporterFilter filter : filters) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } + + if(filterTags.tagCount() != 0) + { + nbtTags.setTag("filters", filterTags); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + if(nbtTags.hasKey("color")) + { + color = TransporterUtils.colors.get(nbtTags.getInteger("color")); + } + + autoEject = nbtTags.getBoolean("autoEject"); + roundRobin = nbtTags.getBoolean("roundRobin"); + + rrIndex = nbtTags.getInteger("rrIndex"); + + if(nbtTags.hasKey("filters")) + { + NBTTagList tagList = nbtTags.getTagList("filters"); + + for(int i = 0; i < tagList.tagCount(); i++) + { + filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i))); + } + } + } + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { int clickType = dataStream.readInt(); - + if(clickType == 0) { color = TransporterUtils.increment(color); @@ -273,21 +273,21 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen roundRobin = !roundRobin; rrIndex = 0; } - + return; } - + super.handlePacketData(dataStream); - + int type = dataStream.readInt(); - + if(type == 0) { isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - + int c = dataStream.readInt(); - + if(c != -1) { color = TransporterUtils.colors.get(c); @@ -295,28 +295,28 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen else { color = null; } - + autoEject = dataStream.readBoolean(); roundRobin = dataStream.readBoolean(); - + filters.clear(); - + int amount = dataStream.readInt(); - + for(int i = 0; i < amount; i++) { filters.add(TransporterFilter.readFromPacket(dataStream)); } - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } else if(type == 1) { isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - + int c = dataStream.readInt(); - + if(c != -1) { color = TransporterUtils.colors.get(c); @@ -324,35 +324,35 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen else { color = null; } - + autoEject = dataStream.readBoolean(); roundRobin = dataStream.readBoolean(); - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } else if(type == 2) { filters.clear(); - + int amount = dataStream.readInt(); - + for(int i = 0; i < amount; i++) { filters.add(TransporterFilter.readFromPacket(dataStream)); } } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(0); - + data.add(isActive); data.add(controlType.ordinal()); - + if(color != null) { data.add(TransporterUtils.colors.indexOf(color)); @@ -360,29 +360,29 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen else { data.add(-1); } - + data.add(autoEject); data.add(roundRobin); - + data.add(filters.size()); - + for(TransporterFilter filter : filters) { filter.write(data); } - + return data; } - + public ArrayList getGenericPacket(ArrayList data) { super.getNetworkedData(data); - + data.add(1); - + data.add(isActive); data.add(controlType.ordinal()); - + if(color != null) { data.add(TransporterUtils.colors.indexOf(color)); @@ -390,85 +390,85 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen else { data.add(-1); } - + data.add(autoEject); data.add(roundRobin); - + return data; - + } - + public ArrayList getFilterPacket(ArrayList data) { super.getNetworkedData(data); - + data.add(2); - + data.add(filters.size()); - + for(TransporterFilter filter : filters) { filter.write(data); } - + return data; } - + public boolean canSendHome(ItemStack stack) { TileEntity back = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj); - + if(back instanceof IInventory) { return InventoryUtils.canInsert(back, null, stack, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), true); } - + return false; } - + public boolean hasInventory() { return Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj) instanceof IInventory; } - + public ItemStack sendHome(ItemStack stack) { TileEntity back = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj); - + if(back instanceof IInventory) { return InventoryUtils.putStackInInventory((IInventory)back, stack, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), true); } - + return stack; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { return false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { return false; } - + @Override public int getInventoryStackLimit() { return 1; } - + @Override - public int[] getAccessibleSlotsFromSide(int side) + public int[] getAccessibleSlotsFromSide(int side) { if(side == ForgeDirection.getOrientation(facing).ordinal() || side == ForgeDirection.getOrientation(facing).getOpposite().ordinal()) { return new int[] {0}; } - + return null; } @@ -480,61 +480,61 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getFilterPacket(new ArrayList())), Coord4D.get(this), 50D); } } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - if(active) - { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "mekanism:etc.Click", 0.3F, 1); - } - - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return true; - } - - @Override - public boolean lightUpdate() - { - return false; - } - + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + if(active) + { + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "mekanism:etc.Click", 0.3F, 1); + } + + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return true; + } + + @Override + public boolean lightUpdate() + { + return false; + } + @Override protected EnumSet getConsumingSides() { return EnumSet.noneOf(ForgeDirection.class); } - + @Override public boolean canSetFacing(int facing) { diff --git a/common/mekanism/common/tile/TileEntityMetallurgicInfuser.java b/common/mekanism/common/tile/TileEntityMetallurgicInfuser.java index 664de9b3d..2e8b9883a 100644 --- a/common/mekanism/common/tile/TileEntityMetallurgicInfuser.java +++ b/common/mekanism/common/tile/TileEntityMetallurgicInfuser.java @@ -41,74 +41,74 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem { /** This machine's side configuration. */ public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4}; - + /** An arraylist of SideData for this machine. */ public ArrayList sideOutputs = new ArrayList(); - + /** The type of infuse this machine stores. */ public InfuseType type = null; - + /** The maxiumum amount of infuse this machine can store. */ public int MAX_INFUSE = 1000; - + /** How much energy this machine consumes per-tick. */ public double ENERGY_PER_TICK = Mekanism.metallurgicInfuserUsage; - + /** How many ticks it takes to run an operation. */ public int TICKS_REQUIRED = 200; - + /** The amount of infuse this machine has stored. */ public int infuseStored; - + /** How many ticks this machine has been operating for. */ public int operatingTicks; - + /** Whether or not this machine is in it's active state. */ public boolean isActive; - + /** The client's current active state. */ public boolean clientActive; - + /** How many ticks must pass until this block's active state can sync with the client. */ public int updateDelay; - + /** This machine's previous amount of energy. */ public double prevEnergy; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 0); public TileComponentEjector ejectorComponent; - + public TileEntityMetallurgicInfuser() { super("MetallurgicInfuser", MachineType.METALLURGIC_INFUSER.baseEnergy); - + sideOutputs.add(new SideData(EnumColor.GREY, InventoryUtils.EMPTY)); sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0})); sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {1})); sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {2})); sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {3})); sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {4})); - + inventory = new ItemStack[5]; ejectorComponent = new TileComponentEjector(this, sideOutputs.get(4)); } - + @Override public void onUpdate() { super.onUpdate(); - + if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -116,27 +116,27 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + ChargeUtils.discharge(4, this); - + if(inventory[1] != null) { if(InfuseRegistry.getObject(inventory[1]) != null) { InfuseObject infuse = InfuseRegistry.getObject(inventory[1]); - + if(type == null || type == infuse.type) { if(infuseStored+infuse.stored <= MAX_INFUSE) @@ -144,20 +144,20 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem infuseStored+=infuse.stored; type = infuse.type; inventory[1].stackSize--; - - if(inventory[1].stackSize <= 0) - { - inventory[1] = null; - } + + if(inventory[1].stackSize <= 0) + { + inventory[1] = null; + } } } } } - + if(canOperate() && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK)) { setActive(true); - + if((operatingTicks+1) < MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) { operatingTicks++; @@ -166,7 +166,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem else if((operatingTicks+1) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) { operate(); - + operatingTicks = 0; electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK); } @@ -177,22 +177,22 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem setActive(false); } } - + if(!canOperate()) { operatingTicks = 0; } - + if(infuseStored <= 0) { infuseStored = 0; type = null; } - + prevEnergy = getEnergy(); } } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -204,10 +204,10 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem { return true; } - + return false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -225,159 +225,159 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem } else if(slotID == 2) { - if(type != null) - { - if(RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, itemstack), false) != null) - { - return true; - } - } - else { - for(Object obj : Recipe.METALLURGIC_INFUSER.get().keySet()) - { - InfusionInput input = (InfusionInput)obj; - if(input.inputStack.isItemEqual(itemstack)) - { - return true; - } - } - } + if(type != null) + { + if(RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, itemstack), false) != null) + { + return true; + } + } + else { + for(Object obj : Recipe.METALLURGIC_INFUSER.get().keySet()) + { + InfusionInput input = (InfusionInput)obj; + if(input.inputStack.isItemEqual(itemstack)) + { + return true; + } + } + } } else if(slotID == 4) { return ChargeUtils.canBeDischarged(itemstack); } - + return false; } - + public void operate() { - if(!canOperate()) - { - return; - } + if(!canOperate()) + { + return; + } - InfusionOutput output = RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, inventory[2]), true); - - infuseStored -= output.getInfuseRequired(); + InfusionOutput output = RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, inventory[2]), true); - if(inventory[2].stackSize <= 0) - { - inventory[2] = null; - } + infuseStored -= output.getInfuseRequired(); - if(inventory[3] == null) - { - inventory[3] = output.resource.copy(); - } - else { - inventory[3].stackSize += output.resource.stackSize; - } - - ejectorComponent.onOutput(); + if(inventory[2].stackSize <= 0) + { + inventory[2] = null; + } + + if(inventory[3] == null) + { + inventory[3] = output.resource.copy(); + } + else { + inventory[3].stackSize += output.resource.stackSize; + } + + ejectorComponent.onOutput(); } - + public boolean canOperate() { - if(inventory[2] == null) - { - return false; - } + if(inventory[2] == null) + { + return false; + } - InfusionOutput output = RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, inventory[2]), false); + InfusionOutput output = RecipeHandler.getMetallurgicInfuserOutput(InfusionInput.getInfusion(type, infuseStored, inventory[2]), false); - if(output == null) - { - return false; - } - - if(infuseStored-output.getInfuseRequired() < 0) - { - return false; - } + if(output == null) + { + return false; + } - if(inventory[3] == null) - { - return true; - } + if(infuseStored-output.getInfuseRequired() < 0) + { + return false; + } - if(!inventory[3].isItemEqual(output.resource)) - { - return false; - } - else { - return inventory[3].stackSize + output.resource.stackSize <= inventory[3].getMaxStackSize(); - } + if(inventory[3] == null) + { + return true; + } + + if(!inventory[3].isItemEqual(output.resource)) + { + return false; + } + else { + return inventory[3].stackSize + output.resource.stackSize <= inventory[3].getMaxStackSize(); + } } - + public int getScaledInfuseLevel(int i) { return infuseStored*i / MAX_INFUSE; } - + public int getScaledProgress(int i) { return operatingTicks*i / MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED); } - + @Override public void invalidate() { super.invalidate(); - + if(worldObj.isRemote) { Mekanism.proxy.unregisterSound(this); } } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - clientActive = isActive = nbtTags.getBoolean("isActive"); - operatingTicks = nbtTags.getInteger("operatingTicks"); - infuseStored = nbtTags.getInteger("infuseStored"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - type = InfuseRegistry.get(nbtTags.getString("type")); - - if(nbtTags.hasKey("sideDataStored")) - { - for(int i = 0; i < 6; i++) - { - sideConfig[i] = nbtTags.getByte("config"+i); - } - } - } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setInteger("infuseStored", infuseStored); - nbtTags.setInteger("controlType", controlType.ordinal()); - - if(type != null) - { - nbtTags.setString("type", type.name); - } - else { - nbtTags.setString("type", "null"); - } - - nbtTags.setBoolean("sideDataStored", true); - - for(int i = 0; i < 6; i++) - { - nbtTags.setByte("config"+i, sideConfig[i]); - } - } - + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + clientActive = isActive = nbtTags.getBoolean("isActive"); + operatingTicks = nbtTags.getInteger("operatingTicks"); + infuseStored = nbtTags.getInteger("infuseStored"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + type = InfuseRegistry.get(nbtTags.getString("type")); + + if(nbtTags.hasKey("sideDataStored")) + { + for(int i = 0; i < 6; i++) + { + sideConfig[i] = nbtTags.getByte("config"+i); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setInteger("infuseStored", infuseStored); + nbtTags.setInteger("controlType", controlType.ordinal()); + + if(type != null) + { + nbtTags.setString("type", type.name); + } + else { + nbtTags.setString("type", "null"); + } + + nbtTags.setBoolean("sideDataStored", true); + + for(int i = 0; i < 6; i++) + { + nbtTags.setByte("config"+i, sideConfig[i]); + } + } + @Override public void handlePacketData(ByteArrayDataInput dataStream) { @@ -386,20 +386,20 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem infuseStored = dataStream.readInt(); return; } - + super.handlePacketData(dataStream); - + clientActive = dataStream.readBoolean(); operatingTicks = dataStream.readInt(); infuseStored = dataStream.readInt(); controlType = RedstoneControl.values()[dataStream.readInt()]; type = InfuseRegistry.get(dataStream.readUTF()); - + for(int i = 0; i < 6; i++) { sideConfig[i] = dataStream.readByte(); } - + if(updateDelay == 0 && clientActive != isActive) { updateDelay = Mekanism.UPDATE_DELAY; @@ -407,17 +407,17 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(operatingTicks); data.add(infuseStored); data.add(controlType.ordinal()); - + if(type != null) { data.add(type.name); @@ -425,7 +425,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem else { data.add("null"); } - + data.add(sideConfig); return data; } @@ -437,13 +437,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getInfuse", "getInfuseNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -480,7 +480,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem @Override public void detach(IComputerAccess computer) {} - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -488,81 +488,81 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem } @Override - public double getMaxEnergy() + public double getMaxEnergy() { return MekanismUtils.getMaxEnergy(getEnergyMultiplier(), MAX_ELECTRICITY); } - + @Override public boolean canSetFacing(int side) { return side != 0 && side != 1; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + @Override public ArrayList getSideData() { return sideOutputs; } - + @Override public byte[] getConfiguration() { return sideConfig; } - + @Override public int getOrientation() { return facing; } - + @Override - public int getEnergyMultiplier(Object... data) + public int getEnergyMultiplier(Object... data) { return upgradeComponent.energyMultiplier; } @Override - public void setEnergyMultiplier(int multiplier, Object... data) + public void setEnergyMultiplier(int multiplier, Object... data) { upgradeComponent.energyMultiplier = multiplier; MekanismUtils.saveChunk(this); } @Override - public int getSpeedMultiplier(Object... data) + public int getSpeedMultiplier(Object... data) { return upgradeComponent.speedMultiplier; } @Override - public void setSpeedMultiplier(int multiplier, Object... data) + public void setSpeedMultiplier(int multiplier, Object... data) { upgradeComponent.speedMultiplier = multiplier; MekanismUtils.saveChunk(this); } - + @Override public boolean supportsUpgrades(Object... data) { @@ -574,15 +574,15 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem { return "MetallurgicInfuser.ogg"; } - + @Override public float getVolumeMultiplier() { return 1; } - + @Override - public boolean renderUpdate() + public boolean renderUpdate() { return true; } @@ -592,26 +592,26 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem { return true; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); } - + @Override public TileComponentUpgrade getComponent() { return upgradeComponent; } - + @Override public IEjector getEjector() { diff --git a/common/mekanism/common/tile/TileEntityObsidianTNT.java b/common/mekanism/common/tile/TileEntityObsidianTNT.java index 65fcbc473..c78e0a6ae 100644 --- a/common/mekanism/common/tile/TileEntityObsidianTNT.java +++ b/common/mekanism/common/tile/TileEntityObsidianTNT.java @@ -3,7 +3,7 @@ package mekanism.common.tile; import net.minecraft.tileentity.TileEntity; //For a TESR -public class TileEntityObsidianTNT extends TileEntity +public class TileEntityObsidianTNT extends TileEntity { @Override public boolean canUpdate() diff --git a/common/mekanism/common/tile/TileEntityOsmiumCompressor.java b/common/mekanism/common/tile/TileEntityOsmiumCompressor.java index 4884c6aa6..09721e0ff 100644 --- a/common/mekanism/common/tile/TileEntityOsmiumCompressor.java +++ b/common/mekanism/common/tile/TileEntityOsmiumCompressor.java @@ -18,7 +18,7 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin { super("Compressor.ogg", "OsmiumCompressor", new ResourceLocation("mekanism", "gui/GuiCompressor.png"), Mekanism.osmiumCompressorUsage, 1, 200, MachineType.OSMIUM_COMPRESSOR.baseEnergy); } - + @Override public Map getRecipes() { @@ -29,7 +29,7 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin public GasStack getItemGas(ItemStack itemstack) { int amount = 0; - + for(ItemStack ore : OreDictionary.getOres("ingotOsmium")) { if(ore.isItemEqual(itemstack)) @@ -37,7 +37,7 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin return new GasStack(GasRegistry.getGas("liquidOsmium"), 200); } } - + for(ItemStack ore : OreDictionary.getOres("blockOsmium")) { if(ore.isItemEqual(itemstack)) @@ -45,10 +45,10 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin return new GasStack(GasRegistry.getGas("liquidOsmium"), 1800); } } - + return null; } - + @Override public boolean isValidGas(Gas gas) { diff --git a/common/mekanism/common/tile/TileEntityPrecisionSawmill.java b/common/mekanism/common/tile/TileEntityPrecisionSawmill.java index ab244d9fa..f5b5557a0 100644 --- a/common/mekanism/common/tile/TileEntityPrecisionSawmill.java +++ b/common/mekanism/common/tile/TileEntityPrecisionSawmill.java @@ -13,13 +13,13 @@ public class TileEntityPrecisionSawmill extends TileEntityChanceMachine { super("PrecisionSawmill.ogg", "PrecisionSawmill", new ResourceLocation("mekanism", "gui/GuiPrecisionSawmill.png"), Mekanism.precisionSawmillUsage, 200, MachineType.PRECISION_SAWMILL.baseEnergy); } - + @Override public Map getRecipes() { return Recipe.PRECISION_SAWMILL.get(); } - + @Override public float getVolumeMultiplier() { diff --git a/common/mekanism/common/tile/TileEntityPurificationChamber.java b/common/mekanism/common/tile/TileEntityPurificationChamber.java index 129cb752f..7a13cac4f 100644 --- a/common/mekanism/common/tile/TileEntityPurificationChamber.java +++ b/common/mekanism/common/tile/TileEntityPurificationChamber.java @@ -23,31 +23,31 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac { super("PurificationChamber.ogg", "PurificationChamber", new ResourceLocation("mekanism", "gui/GuiPurificationChamber.png"), Mekanism.purificationChamberUsage, 1, 200, MachineType.PURIFICATION_CHAMBER.baseEnergy); } - + @Override public Map getRecipes() { return Recipe.PURIFICATION_CHAMBER.get(); } - + @Override public GasStack getItemGas(ItemStack itemstack) { if(itemstack.isItemEqual(new ItemStack(Item.flint))) return new GasStack(GasRegistry.getGas("oxygen"), 10); if(itemstack.itemID == Mekanism.GasTank.blockID && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("oxygen")) return new GasStack(GasRegistry.getGas("oxygen"), 1); - + return null; } @Override - public int receiveGas(ForgeDirection side, GasStack stack) + public int receiveGas(ForgeDirection side, GasStack stack) { if(stack.getGas() == GasRegistry.getGas("oxygen")) { - return gasTank.receive(stack, true); + return gasTank.receive(stack, true); } - + return 0; } @@ -56,7 +56,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac { return type == GasRegistry.getGas("oxygen"); } - + @Override public void handleSecondaryFuel() { @@ -66,7 +66,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac gasTank.receive(removed, true); return; } - + super.handleSecondaryFuel(); } @@ -75,7 +75,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac { return true; } - + @Override public boolean isValidGas(Gas gas) { diff --git a/common/mekanism/common/tile/TileEntityRotaryCondensentrator.java b/common/mekanism/common/tile/TileEntityRotaryCondensentrator.java index c0796c450..fdbcd3a7a 100644 --- a/common/mekanism/common/tile/TileEntityRotaryCondensentrator.java +++ b/common/mekanism/common/tile/TileEntityRotaryCondensentrator.java @@ -38,36 +38,36 @@ import com.google.common.io.ByteArrayDataInput; public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedTank, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl { public GasTank gasTank = new GasTank(MAX_GAS); - + public FluidTank fluidTank; - + public static final int MAX_GAS = 10000; - + public int updateDelay; - + /** 0: gas -> fluid; 1: fluid -> gas */ public int mode; - + public int gasOutput = 16; - + public boolean isActive; - + public boolean clientActive; - + public double prevEnergy; - + public final double ENERGY_USAGE = Mekanism.rotaryCondensentratorUsage; - + /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - + public TileEntityRotaryCondensentrator() { super("RotaryCondensentrator", MachineType.ROTARY_CONDENSENTRATOR.baseEnergy); fluidTank = new FluidTank(10000); inventory = new ItemStack[5]; } - + @Override public void onUpdate() { @@ -76,7 +76,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -84,28 +84,28 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + ChargeUtils.discharge(4, this); - + if(mode == 0) { if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getStored() < gasTank.getMaxGas())) { gasTank.receive(GasTransmission.removeGas(inventory[1], null, gasTank.getNeeded()), true); } - + if(inventory[2] != null) { if(FluidContainerRegistry.isEmptyContainer(inventory[2])) @@ -113,18 +113,18 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp if(fluidTank.getFluid() != null && fluidTank.getFluid().amount >= FluidContainerRegistry.BUCKET_VOLUME) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(fluidTank.getFluid(), inventory[2]); - + if(filled != null) { if(inventory[3] == null || (inventory[3].isItemEqual(filled) && inventory[3].stackSize+1 <= filled.getMaxStackSize())) { inventory[2].stackSize--; - + if(inventory[2].stackSize <= 0) { inventory[2] = null; } - + if(inventory[3] == null) { inventory[3] = filled; @@ -132,14 +132,14 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp else { inventory[3].stackSize++; } - + fluidTank.drain(FluidContainerRegistry.getFluidForFilledItem(filled).amount, true); } } } } } - + if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidGas(gasTank.getGas()) && (fluidTank.getFluid() == null || (fluidTank.getFluid().amount < 10000 && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { setActive(true); @@ -160,14 +160,14 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true); } - + if(gasTank.getGas() != null) { GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getGas().amount, gasOutput)); gasTank.draw(GasTransmission.emitGasToNetwork(toSend, this, MekanismUtils.getLeft(facing)), true); - + TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj); - + if(tileEntity instanceof IGasHandler) { if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), gasTank.getGas().getGas())) @@ -176,28 +176,28 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp } } } - + if(FluidContainerRegistry.isFilledContainer(inventory[2])) { FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[2]); - + if((fluidTank.getFluid() == null && itemFluid.amount <= 10000) || fluidTank.getFluid().amount+itemFluid.amount <= 10000) { if(fluidTank.getFluid() != null && !fluidTank.getFluid().isFluidEqual(itemFluid)) { return; } - + ItemStack containerItem = inventory[2].getItem().getContainerItemStack(inventory[2]); - + boolean filled = false; - + if(containerItem != null) { if(inventory[3] == null || (inventory[3].isItemEqual(containerItem) && inventory[3].stackSize+1 <= containerItem.getMaxStackSize())) { inventory[2] = null; - + if(inventory[3] == null) { inventory[3] = containerItem; @@ -205,28 +205,28 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp else { inventory[3].stackSize++; } - + filled = true; } } - else { + else { inventory[2].stackSize--; - + if(inventory[2].stackSize == 0) { inventory[2] = null; } - + filled = true; } - + if(filled) { fluidTank.fill(itemFluid, true); } } } - + if(getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_GAS && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { setActive(true); @@ -241,67 +241,67 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp } } } - + prevEnergy = getEnergy(); } } - + public boolean isValidGas(GasStack g) { if(g == null) { return false; } - + return g.getGas().hasFluid(); } - + public boolean gasEquals(GasStack gas, FluidStack fluid) { if(fluid == null || gas == null || !gas.getGas().hasFluid()) { return false; } - + return gas.getGas().getFluid() == fluid.getFluid(); } - + public boolean isValidFluid(FluidStack f) { if(f == null) { return false; } - + return GasRegistry.getGas(f.getFluid()) != null; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { mode = mode == 0 ? 1 : 0; } - + for(EntityPlayer player : playersUsing) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), player); } - + return; } - + super.handlePacketData(dataStream); - + mode = dataStream.readInt(); isActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - + if(dataStream.readBoolean()) { fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); @@ -309,7 +309,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp else { fluidTank.setFluid(null); } - + if(dataStream.readBoolean()) { gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); @@ -317,20 +317,20 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp else { gasTank.setGas(null); } - - + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(mode); data.add(isActive); data.add(controlType.ordinal()); - + if(fluidTank.getFluid() != null) { data.add(true); @@ -340,7 +340,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp else { data.add(false); } - + if(gasTank.getGas() != null) { data.add(true); @@ -350,90 +350,90 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp else { data.add(false); } - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - mode = nbtTags.getInteger("mode"); - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - gasTank.read(nbtTags.getCompoundTag("gasTank")); - - if(nbtTags.hasKey("fluidTank")) - { - fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); - } - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("mode", mode); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); - - if(fluidTank.getFluid() != null) - { - nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); - } - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + mode = nbtTags.getInteger("mode"); + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + gasTank.read(nbtTags.getCompoundTag("gasTank")); + + if(nbtTags.hasKey("fluidTank")) + { + fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("mode", mode); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound())); + + if(fluidTank.getFluid() != null) + { + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); + } + } + @Override public boolean canSetFacing(int i) { return i != 0 && i != 1; } - + public int getScaledFluidLevel(int i) { return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / 10000 : 0; } - + public int getScaledGasLevel(int i) { return gasTank.getGas() != null ? gasTank.getStored()*i / MAX_GAS : 0; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() + { + return isActive; + } + + @Override + public boolean renderUpdate() + { + return false; + } + + @Override + public boolean lightUpdate() + { + return true; + } @Override public boolean canTubeConnect(ForgeDirection side) @@ -446,7 +446,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { return gasTank.receive(stack, true); } - + @Override public GasStack drawGas(ForgeDirection side, int amount) { @@ -490,7 +490,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { return fluidTank.fill(resource, doFill); } - + return 0; } @@ -501,7 +501,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { return drain(from, resource.amount, doDrain); } - + return null; } @@ -524,7 +524,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { return new FluidTankInfo[] {fluidTank.getInfo()}; } - + return PipeUtils.EMPTY; } @@ -535,18 +535,18 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { return fluidTank.drain(maxDrain, doDrain); } - + return null; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); diff --git a/common/mekanism/common/tile/TileEntitySalinationController.java b/common/mekanism/common/tile/TileEntitySalinationController.java index ae6b20ad4..783a9dfb7 100644 --- a/common/mekanism/common/tile/TileEntitySalinationController.java +++ b/common/mekanism/common/tile/TileEntitySalinationController.java @@ -31,7 +31,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class TileEntitySalinationController extends TileEntitySalinationTank implements IConfigurable { public static final int MAX_BRINE = 10000; - + public static final int MAX_SOLARS = 4; public static final int WARMUP = 10000; @@ -42,31 +42,31 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp public TileEntityAdvancedSolarGenerator[] solars = new TileEntityAdvancedSolarGenerator[4]; public boolean temperatureSet = false; - + public double partialWater = 0; public double partialBrine = 0; - + public float biomeTemp = 0; public float temperature = 0; - + public int height = 0; - + public boolean structured = false; public boolean controllerConflict = false; public boolean isLeftOnFace; - + public boolean updatedThisTick = false; public int clientSolarAmount; - + public boolean cacheStructure = false; - + public float prevScale; - + public TileEntitySalinationController() { super("SalinationController"); - + inventory = new ItemStack[4]; } @@ -74,27 +74,27 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { updatedThisTick = false; - + if(ticker == 5 && cacheStructure) { refresh(true); cacheStructure = false; } - + updateTemperature(); manageBuckets(); - + if(canOperate()) { int brineNeeded = brineTank.getCapacity()-brineTank.getFluidAmount(); int waterStored = waterTank.getFluidAmount(); - + partialWater += Math.min(waterTank.getFluidAmount(), getTemperature()*100); - + if(partialWater >= 1) { int waterInt = (int)Math.floor(partialWater); @@ -102,7 +102,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp partialWater %= 1; partialBrine += ((double)waterInt)/100D; } - + if(partialBrine >= 1) { int brineInt = (int)Math.floor(partialBrine); @@ -110,7 +110,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp partialBrine %= 1; } } - + if(structured) { if(Math.abs((float)waterTank.getFluidAmount()/waterTank.getCapacity()-prevScale) > 0.01) @@ -121,23 +121,23 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp } } } - + @Override public void onChunkUnload() { super.onChunkUnload(); - + refresh(false); } - + @Override public void onNeighborChange(int id) { super.onNeighborChange(id); - + refresh(false); } - + protected void refresh(boolean canCreate) { if(!worldObj.isRemote) @@ -145,24 +145,24 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp if((structured || canCreate) && !updatedThisTick) { boolean prev = structured; - + clearStructure(); structured = buildStructure(); - + if(structured != prev) { PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this), 50D); } - + if(structured) { waterTank.setCapacity(getMaxWater()); - + if(waterTank.getFluid() != null) { waterTank.getFluid().amount = Math.min(waterTank.getFluid().amount, getMaxWater()); } - + temperature = Math.min(getMaxTemperature(), getTemperature()); } } @@ -175,15 +175,15 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp { return false; } - + if(!waterTank.getFluid().containsFluid(FluidRegistry.getFluidStack("water", 1)) || brineTank.getCapacity()-brineTank.getFluidAmount() == 0) { return false; } - + return true; } - + private void manageBuckets() { if(inventory[2] != null) @@ -193,65 +193,65 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp if(FluidContainerRegistry.isEmptyContainer(inventory[2])) { ItemStack tempStack = FluidContainerRegistry.fillFluidContainer(brineTank.getFluid(), inventory[2]); - + if(tempStack != null) { if(inventory[3] == null) { brineTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); - + inventory[3] = tempStack; inventory[2].stackSize--; - + if(inventory[2].stackSize <= 0) { inventory[2] = null; } - + onInventoryChanged(); } else if(tempStack.isItemEqual(inventory[3]) && tempStack.getMaxStackSize() > inventory[3].stackSize) { brineTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); - + inventory[3].stackSize++; inventory[2].stackSize--; - + if(inventory[2].stackSize <= 0) { inventory[2] = null; } - + onInventoryChanged(); } } } } } - + if(structured) { if(FluidContainerRegistry.isFilledContainer(inventory[0])) { FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - + if((waterTank.getFluid() == null && itemFluid.amount <= getMaxWater()) || waterTank.getFluid().amount+itemFluid.amount <= getMaxWater()) { if(itemFluid.getFluid() != FluidRegistry.WATER || (waterTank.getFluid() != null && !waterTank.getFluid().isFluidEqual(itemFluid))) { return; } - + ItemStack containerItem = inventory[0].getItem().getContainerItemStack(inventory[0]); - + boolean filled = false; - + if(containerItem != null) { if(inventory[1] == null || (inventory[1].isItemEqual(containerItem) && inventory[1].stackSize+1 <= containerItem.getMaxStackSize())) { inventory[0] = null; - + if(inventory[1] == null) { inventory[1] = containerItem; @@ -259,21 +259,21 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp else { inventory[1].stackSize++; } - + filled = true; } } - else { + else { inventory[0].stackSize--; - + if(inventory[0].stackSize == 0) { inventory[0] = null; } - + filled = true; } - + if(filled) { waterTank.fill(itemFluid, true); @@ -282,12 +282,12 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp } } } - + private void updateTemperature() { float max = getMaxTemperature(); float incr = (max/WARMUP)*getTempMultiplier(); - + if(getTempMultiplier() == 0) { temperature = Math.max(0, getTemperature()-(max/WARMUP)); @@ -296,22 +296,22 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp temperature = Math.min(max, getTemperature()+incr); } } - + public float getTemperature() { return temperature; } - + public float getMaxTemperature() { if(!structured) { return 0; } - + return 1 + (height-3)*0.5F; } - + public float getTempMultiplier() { if(!temperatureSet) @@ -319,19 +319,19 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp biomeTemp = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord).getFloatTemperature(); temperatureSet = true; } - + return biomeTemp*((float)getActiveSolars()/MAX_SOLARS); } - + public int getActiveSolars() { if(worldObj.isRemote) { return clientSolarAmount; } - + int ret = 0; - + for(TileEntityAdvancedSolarGenerator solar : solars) { if(solar != null && solar.seesSun) @@ -339,7 +339,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp ret++; } } - + return ret; } @@ -350,26 +350,26 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp height = 0; controllerConflict = false; updatedThisTick = true; - + if(!scanBottomLayer()) { height = 0; - return false; + return false; } - + Coord4D startPoint = Coord4D.get(this).getFromSide(right); startPoint = isLeftOnFace ? startPoint.getFromSide(right) : startPoint; int middle = 0; - + Coord4D middlePointer = startPoint.getFromSide(ForgeDirection.DOWN); - + while(scanMiddleLayer(middlePointer)) { middlePointer = middlePointer.getFromSide(ForgeDirection.DOWN); middle++; } - + if(height < 3 || height > 18 || middle != height-2) { height = 0; @@ -378,9 +378,9 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp structured = scanTopLayer(startPoint); height = structured ? height : 0; - + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID); - + for(TileEntitySalinationTank tank : tankParts) { if(tank != this && tank instanceof TileEntitySalinationValve) @@ -388,7 +388,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp worldObj.notifyBlocksOfNeighborChange(tank.xCoord, tank.yCoord, tank.zCoord, tank.getBlockType().blockID); } } - + return structured; } @@ -402,9 +402,9 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp for(int z = 0; z < 4; z++) { Coord4D pointer = current.getFromSide(left, x).getFromSide(back, z); - + int corner = getCorner(x, z); - + if(corner != -1) { if(addSolarPanel(pointer.getTileEntity(worldObj), corner)) @@ -426,7 +426,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp } else { TileEntity pointerTile = pointer.getTileEntity(worldObj); - + if(!addTankPart(pointerTile)) { return false; @@ -438,12 +438,12 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp return true; } - + public int getMaxWater() { return height*4*TankUpdateProtocol.FLUID_PER_TANK; } - + public int getCorner(int x, int z) { if(x == 0 && z == 0) @@ -462,7 +462,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp { return 3; } - + return -1; } @@ -476,7 +476,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp for(int z = 0; z < 4; z++) { Coord4D pointer = current.getFromSide(left, x).getFromSide(back, z); - + if((x == 1 || x == 2) && (z == 1 || z == 2)) { if(!pointer.isAirBlock(worldObj)) @@ -486,8 +486,8 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp } else { TileEntity pointerTile = pointer.getTileEntity(worldObj); - - if(!addTankPart(pointerTile)) + + if(!addTankPart(pointerTile)) { return false; } @@ -502,7 +502,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp { height = 1; Coord4D baseBlock = Coord4D.get(this); - + while(baseBlock.getFromSide(ForgeDirection.DOWN).getTileEntity(worldObj) instanceof TileEntitySalinationTank) { baseBlock.step(ForgeDirection.DOWN); @@ -512,17 +512,17 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp ForgeDirection left = MekanismUtils.getLeft(facing); ForgeDirection right = MekanismUtils.getRight(facing); - if(!scanBottomRow(baseBlock)) + if(!scanBottomRow(baseBlock)) { return false; }; - - if(!scanBottomRow(baseBlock.getFromSide(left))) + + if(!scanBottomRow(baseBlock.getFromSide(left))) { return false; }; - - if(!scanBottomRow(baseBlock.getFromSide(right))) + + if(!scanBottomRow(baseBlock.getFromSide(right))) { return false; }; @@ -530,13 +530,13 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp boolean twoLeft = scanBottomRow(baseBlock.getFromSide(left).getFromSide(left)); boolean twoRight = scanBottomRow(baseBlock.getFromSide(right).getFromSide(right)); - if(twoLeft == twoRight) + if(twoLeft == twoRight) { return false; } isLeftOnFace = twoRight; - + return true; } @@ -553,12 +553,12 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp for(int i = 1; i <= 4; i++) { TileEntity tile = current.getTileEntity(worldObj); - - if(!addTankPart(tile)) + + if(!addTankPart(tile)) { return false; } - + current = current.getFromSide(back); } @@ -574,7 +574,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp ((TileEntitySalinationTank)tile).addToStructure(this); tankParts.add((TileEntitySalinationTank)tile); } - + return true; } else { @@ -582,7 +582,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp { controllerConflict = true; } - + return false; } } @@ -598,36 +598,36 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp return false; } } - + public int getScaledWaterLevel(int i) { return getMaxWater() > 0 ? (waterTank.getFluid() != null ? waterTank.getFluid().amount*i / getMaxWater() : 0) : 0; } - + public int getScaledBrineLevel(int i) { return brineTank.getFluid() != null ? brineTank.getFluid().amount*i / MAX_BRINE : 0; } - + public int getScaledTempLevel(int i) { return (int)(getMaxTemperature() == 0 ? 0 : getTemperature()*i/getMaxTemperature()); } - + public Coord4D getRenderLocation() { if(!structured) { return null; } - + ForgeDirection right = MekanismUtils.getRight(facing); Coord4D startPoint = Coord4D.get(this).getFromSide(right); startPoint = isLeftOnFace ? startPoint.getFromSide(right) : startPoint; - + startPoint = startPoint.getFromSide(right.getOpposite()).getFromSide(MekanismUtils.getBack(facing)); startPoint.translate(0, -(height-2), 0); - + return startPoint; } @@ -642,24 +642,24 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp { return false; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { if(!worldObj.isRemote) { int type = dataStream.readInt(); - + if(type == 0) { refresh(true); } - + return; } - + super.handlePacketData(dataStream); - + if(dataStream.readBoolean()) { waterTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); @@ -667,7 +667,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp else { waterTank.setFluid(null); } - + if(dataStream.readBoolean()) { brineTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); @@ -675,9 +675,9 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp else { brineTank.setFluid(null); } - + boolean prev = structured; - + structured = dataStream.readBoolean(); controllerConflict = dataStream.readBoolean(); clientSolarAmount = dataStream.readInt(); @@ -685,21 +685,21 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp temperature = dataStream.readFloat(); biomeTemp = dataStream.readFloat(); isLeftOnFace = dataStream.readBoolean(); - + if(structured != prev) { waterTank.setCapacity(getMaxWater()); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } - + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + if(waterTank.getFluid() != null) { data.add(true); @@ -709,7 +709,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp else { data.add(false); } - + if(brineTank.getFluid() != null) { data.add(true); @@ -719,7 +719,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp else { data.add(false); } - + data.add(structured); data.add(controllerConflict); data.add(getActiveSolars()); @@ -727,42 +727,42 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp data.add(temperature); data.add(biomeTemp); data.add(isLeftOnFace); - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - waterTank.readFromNBT(nbtTags.getCompoundTag("waterTank")); - brineTank.readFromNBT(nbtTags.getCompoundTag("brineTank")); - - temperature = nbtTags.getFloat("temperature"); - - partialWater = nbtTags.getDouble("partialWater"); - partialBrine = nbtTags.getDouble("partialBrine"); - - cacheStructure = nbtTags.getBoolean("cacheStructure"); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setCompoundTag("waterTank", waterTank.writeToNBT(new NBTTagCompound())); - nbtTags.setCompoundTag("brineTank", brineTank.writeToNBT(new NBTTagCompound())); - - nbtTags.setFloat("temperature", temperature); - - nbtTags.setDouble("partialWater", partialWater); - nbtTags.setDouble("partialBrine", partialBrine); - - nbtTags.setBoolean("cacheStructure", structured); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + waterTank.readFromNBT(nbtTags.getCompoundTag("waterTank")); + brineTank.readFromNBT(nbtTags.getCompoundTag("brineTank")); + + temperature = nbtTags.getFloat("temperature"); + + partialWater = nbtTags.getDouble("partialWater"); + partialBrine = nbtTags.getDouble("partialBrine"); + + cacheStructure = nbtTags.getBoolean("cacheStructure"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setCompoundTag("waterTank", waterTank.writeToNBT(new NBTTagCompound())); + nbtTags.setCompoundTag("brineTank", brineTank.writeToNBT(new NBTTagCompound())); + + nbtTags.setFloat("temperature", temperature); + + nbtTags.setDouble("partialWater", partialWater); + nbtTags.setDouble("partialBrine", partialBrine); + + nbtTags.setBoolean("cacheStructure", structured); + } + @Override public boolean canSetFacing(int side) { @@ -775,11 +775,11 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp { tankPart.controllerGone(); } - + tankParts.clear(); solars = new TileEntityAdvancedSolarGenerator[] {null, null, null, null}; } - + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() diff --git a/common/mekanism/common/tile/TileEntitySalinationTank.java b/common/mekanism/common/tile/TileEntitySalinationTank.java index b7bf0f67d..4bb059c71 100644 --- a/common/mekanism/common/tile/TileEntitySalinationTank.java +++ b/common/mekanism/common/tile/TileEntitySalinationTank.java @@ -10,14 +10,14 @@ public class TileEntitySalinationTank extends TileEntityContainerBlock public TileEntitySalinationTank() { super("SalinationTank"); - + inventory = new ItemStack[0]; } public TileEntitySalinationTank(String fullName) { super(fullName); - + inventory = new ItemStack[0]; } @@ -33,23 +33,23 @@ public class TileEntitySalinationTank extends TileEntityContainerBlock { master = null; } - + @Override public void onChunkUnload() { super.onChunkUnload(); - + if(master != null) { master.refresh(false); } } - + @Override public void onNeighborChange(int id) { super.onNeighborChange(id); - + if(master != null) { master.refresh(false); diff --git a/common/mekanism/common/tile/TileEntitySalinationValve.java b/common/mekanism/common/tile/TileEntitySalinationValve.java index 9967178a0..f9c0ba123 100644 --- a/common/mekanism/common/tile/TileEntitySalinationValve.java +++ b/common/mekanism/common/tile/TileEntitySalinationValve.java @@ -56,7 +56,7 @@ public class TileEntitySalinationValve extends TileEntitySalinationTank implemen { return new FluidTankInfo[0]; } - + return new FluidTankInfo[] {new FluidTankInfo(master.waterTank), new FluidTankInfo(master.brineTank)}; } } diff --git a/common/mekanism/common/tile/TileEntityTeleporter.java b/common/mekanism/common/tile/TileEntityTeleporter.java index 3a7dec523..3dff14384 100644 --- a/common/mekanism/common/tile/TileEntityTeleporter.java +++ b/common/mekanism/common/tile/TileEntityTeleporter.java @@ -42,42 +42,42 @@ import dan200.computer.api.IPeripheral; public class TileEntityTeleporter extends TileEntityElectricBlock implements IPeripheral { private MinecraftServer server = MinecraftServer.getServer(); - + /** This teleporter's frequency. */ public Teleporter.Code code; - + public AxisAlignedBB teleportBounds = null; - + public Set didTeleport = new HashSet(); - + public int teleDelay = 0; - + public boolean shouldRender; - + public boolean prevShouldRender; - + /** This teleporter's current status. */ public String status = (EnumColor.DARK_RED + "Not ready."); - + public TileEntityTeleporter() { super("Teleporter", MachineType.TELEPORTER.baseEnergy); inventory = new ItemStack[1]; code = new Teleporter.Code(0, 0, 0, 0); } - + @Override public void onUpdate() { super.onUpdate(); - + if(teleportBounds == null) { resetBounds(); } - + if(!worldObj.isRemote) - { + { if(Mekanism.teleporters.containsKey(code)) { if(!Mekanism.teleporters.get(code).contains(Coord4D.get(this)) && hasFrame()) @@ -95,7 +95,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe newCoords.add(Coord4D.get(this)); Mekanism.teleporters.put(code, newCoords); } - + switch(canTeleport()) { case 1: @@ -117,38 +117,38 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe status = EnumColor.DARK_GREEN + "Idle."; break; } - + if(canTeleport() == 1 && teleDelay == 0) { teleport(); } - + if(teleDelay == 0 && didTeleport.size() > 0) { cleanTeleportCache(); } - + byte b = canTeleport(); shouldRender = b == 1 || b > 4; - + if(shouldRender != prevShouldRender) { PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this), 40D); } - + prevShouldRender = shouldRender; - + teleDelay = Math.max(0, teleDelay-1); } - + ChargeUtils.discharge(0, this); } - + public void cleanTeleportCache() { List list = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds); Set teleportCopy = (Set)((HashSet)didTeleport).clone(); - + for(Entity entity : teleportCopy) { if(!list.contains(entity)) @@ -157,13 +157,13 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe } } } - + @Override public int[] getAccessibleSlotsFromSide(int side) { return new int[] {0}; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -171,15 +171,15 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe { return ChargeUtils.canBeDischarged(itemstack); } - + return true; } - + public void resetBounds() { teleportBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+3, zCoord+1); } - + /** * 1: yes * 2: no frame @@ -195,23 +195,23 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe { return 2; } - + if(!Mekanism.teleporters.containsKey(code) || Mekanism.teleporters.get(code).isEmpty()) { return 3; } - - if(Mekanism.teleporters.get(code).size() > 2) + + if(Mekanism.teleporters.get(code).size() > 2) { return 4; } - + if(Mekanism.teleporters.get(code).size() == 2) { List entitiesInPortal = getToTeleport(); Coord4D closestCoords = null; - + for(Coord4D coords : Mekanism.teleporters.get(code)) { if(!coords.equals(Coord4D.get(this))) @@ -220,38 +220,38 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe break; } } - + int electricityNeeded = 0; - + for(Entity entity : entitiesInPortal) { electricityNeeded += calculateEnergyCost(entity, closestCoords); } - + if(entitiesInPortal.size() == 0) { return 6; } - + if(getEnergy() < electricityNeeded) { return 5; } - + return 1; } - + return 3; } - + public void teleport() { if(worldObj.isRemote) return; - + List entitiesInPortal = getToTeleport(); Coord4D closestCoords = null; - + for(Coord4D coords : Mekanism.teleporters.get(code)) { if(!coords.equals(Coord4D.get(this))) @@ -260,17 +260,17 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe break; } } - + for(Entity entity : entitiesInPortal) - { + { World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(closestCoords.dimensionId); TileEntityTeleporter teleporter = (TileEntityTeleporter)closestCoords.getTileEntity(teleWorld); - + if(teleporter != null) { teleporter.didTeleport.add(entity); teleporter.teleDelay = 5; - + if(entity instanceof EntityPlayerMP) { teleportPlayerTo((EntityPlayerMP)entity, closestCoords, teleporter); @@ -278,92 +278,92 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe else { teleportEntityTo(entity, closestCoords, teleporter); } - + for(Coord4D coords : Mekanism.teleporters.get(code)) { PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketPortalFX().setParams(coords), coords, 40D); } - + setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords)); - + worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F); } } } - + public void teleportPlayerTo(EntityPlayerMP player, Coord4D coord, TileEntityTeleporter teleporter) { if(player.dimension != coord.dimensionId) { - int id = player.dimension; - WorldServer oldWorld = server.worldServerForDimension(player.dimension); - player.dimension = coord.dimensionId; - WorldServer newWorld = server.worldServerForDimension(player.dimension); - player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType())); - oldWorld.removePlayerEntityDangerously(player); - player.isDead = false; - - if(player.isEntityAlive()) - { - newWorld.spawnEntityInWorld(player); - player.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); - newWorld.updateEntityWithOptionalForce(player, false); - player.setWorld(newWorld); - } - - server.getConfigurationManager().func_72375_a(player, oldWorld); - player.playerNetServerHandler.setPlayerLocation(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); - player.theItemInWorldManager.setWorld(newWorld); - server.getConfigurationManager().updateTimeAndWeatherForPlayer(player, newWorld); - server.getConfigurationManager().syncPlayerInventory(player); - Iterator iterator = player.getActivePotionEffects().iterator(); - - while(iterator.hasNext()) - { - PotionEffect potioneffect = (PotionEffect)iterator.next(); - player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, potioneffect)); - } - - GameRegistry.onPlayerChangedDimension(player); + int id = player.dimension; + WorldServer oldWorld = server.worldServerForDimension(player.dimension); + player.dimension = coord.dimensionId; + WorldServer newWorld = server.worldServerForDimension(player.dimension); + player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType())); + oldWorld.removePlayerEntityDangerously(player); + player.isDead = false; + + if(player.isEntityAlive()) + { + newWorld.spawnEntityInWorld(player); + player.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); + newWorld.updateEntityWithOptionalForce(player, false); + player.setWorld(newWorld); + } + + server.getConfigurationManager().func_72375_a(player, oldWorld); + player.playerNetServerHandler.setPlayerLocation(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); + player.theItemInWorldManager.setWorld(newWorld); + server.getConfigurationManager().updateTimeAndWeatherForPlayer(player, newWorld); + server.getConfigurationManager().syncPlayerInventory(player); + Iterator iterator = player.getActivePotionEffects().iterator(); + + while(iterator.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + player.playerNetServerHandler.sendPacketToPlayer(new Packet41EntityEffect(player.entityId, potioneffect)); + } + + GameRegistry.onPlayerChangedDimension(player); } else { player.playerNetServerHandler.setPlayerLocation(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); } } - + public void teleportEntityTo(Entity entity, Coord4D coord, TileEntityTeleporter teleporter) { WorldServer world = server.worldServerForDimension(coord.dimensionId); - + if(entity.worldObj.provider.dimensionId != coord.dimensionId) { entity.worldObj.removeEntity(entity); entity.isDead = false; - + world.spawnEntityInWorld(entity); entity.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, entity.rotationYaw, entity.rotationPitch); world.updateEntityWithOptionalForce(entity, false); entity.setWorld(world); world.resetUpdateEntityTick(); - + Entity e = EntityList.createEntityByName(EntityList.getEntityString(entity), world); - + if(e != null) { e.copyDataFrom(entity, true); world.spawnEntityInWorld(e); teleporter.didTeleport.add(e); } - + entity.isDead = true; } } - + public List getToTeleport() { List entities = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds); List ret = new ArrayList(); - + for(Entity entity : entities) { if(!didTeleport.contains(entity)) @@ -371,15 +371,15 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe ret.add(entity); } } - + return ret; } - + @Override public void invalidate() { super.invalidate(); - + if(!worldObj.isRemote) { if(Mekanism.teleporters.containsKey(code)) @@ -388,30 +388,30 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe { Mekanism.teleporters.get(code).remove(Coord4D.get(this)); } - - if(Mekanism.teleporters.get(code).isEmpty()) + + if(Mekanism.teleporters.get(code).isEmpty()) { Mekanism.teleporters.remove(code); } } } } - + public int calculateEnergyCost(Entity entity, Coord4D coords) { int energyCost = 1000; - + if(entity.worldObj.provider.dimensionId != coords.dimensionId) { energyCost+=10000; } - + int distance = (int)entity.getDistance(coords.xCoord, coords.yCoord, coords.zCoord); energyCost+=(distance*10); - + return energyCost; } - + public boolean hasFrame() { if(isFrame(xCoord-1, yCoord, zCoord) && isFrame(xCoord+1, yCoord, zCoord) @@ -426,34 +426,34 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe && isFrame(xCoord, yCoord+3, zCoord)) {return true;} return false; } - + public boolean isFrame(int x, int y, int z) { return worldObj.getBlockId(x, y, z) == Mekanism.basicBlockID && worldObj.getBlockMetadata(x, y, z) == 7; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - code.digitOne = nbtTags.getInteger("digitOne"); - code.digitTwo = nbtTags.getInteger("digitTwo"); - code.digitThree = nbtTags.getInteger("digitThree"); - code.digitFour = nbtTags.getInteger("digitFour"); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("digitOne", code.digitOne); - nbtTags.setInteger("digitTwo", code.digitTwo); - nbtTags.setInteger("digitThree", code.digitThree); - nbtTags.setInteger("digitFour", code.digitFour); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + code.digitOne = nbtTags.getInteger("digitOne"); + code.digitTwo = nbtTags.getInteger("digitTwo"); + code.digitThree = nbtTags.getInteger("digitThree"); + code.digitFour = nbtTags.getInteger("digitFour"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("digitOne", code.digitOne); + nbtTags.setInteger("digitTwo", code.digitTwo); + nbtTags.setInteger("digitThree", code.digitThree); + nbtTags.setInteger("digitFour", code.digitFour); + } + @Override public void handlePacketData(ByteArrayDataInput dataStream) { @@ -465,12 +465,12 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe { Mekanism.teleporters.get(code).remove(Coord4D.get(this)); } - + if(Mekanism.teleporters.get(code).isEmpty()) Mekanism.teleporters.remove(code); } - + int type = dataStream.readInt(); - + if(type == 0) { code.digitOne = dataStream.readInt(); @@ -489,9 +489,9 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe } return; } - + super.handlePacketData(dataStream); - + status = dataStream.readUTF().trim(); code.digitOne = dataStream.readInt(); code.digitTwo = dataStream.readInt(); @@ -499,22 +499,22 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe code.digitFour = dataStream.readInt(); shouldRender = dataStream.readBoolean(); } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(status); data.add(code.digitOne); data.add(code.digitTwo); data.add(code.digitThree); data.add(code.digitFour); data.add(shouldRender); - + return data; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -554,10 +554,10 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe { return new Object[] {"Invalid parameters."}; } - + int digit = ((Double)arguments[0]).intValue(); int newDigit = ((Double)arguments[1]).intValue(); - + switch(digit) { case 0: @@ -586,13 +586,13 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IPe { return true; } - + @Override public void attach(IComputerAccess computer) {} @Override public void detach(IComputerAccess computer) {} - + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() diff --git a/common/mekanism/common/tile/component/TileComponentEjector.java b/common/mekanism/common/tile/component/TileComponentEjector.java index 46696e0cd..c3968d110 100644 --- a/common/mekanism/common/tile/component/TileComponentEjector.java +++ b/common/mekanism/common/tile/component/TileComponentEjector.java @@ -26,34 +26,34 @@ import com.google.common.io.ByteArrayDataInput; public class TileComponentEjector implements ITileComponent, IEjector { public TileEntityContainerBlock tileEntity; - + public boolean strictInput; - + public boolean ejecting; - + public EnumColor outputColor; - + public EnumColor[] inputColors = new EnumColor[] {null, null, null, null, null, null}; - + public int tickDelay = 0; - + public SideData sideData; - + public int[] trackers; - + public TileComponentEjector(TileEntityContainerBlock tile, SideData data) { tileEntity = tile; sideData = data; trackers = new int[sideData.availableSlots.length]; - + tile.components.add(this); } - + private List getTrackedOutputs(int index, List dirs) { List sides = new ArrayList(); - + for(int i = trackers[index]+1; i <= trackers[index]+6; i++) { for(ForgeDirection side : dirs) @@ -64,12 +64,12 @@ public class TileComponentEjector implements ITileComponent, IEjector } } } - + return sides; } - + @Override - public void tick() + public void tick() { if(tickDelay == 0) { @@ -79,7 +79,7 @@ public class TileComponentEjector implements ITileComponent, IEjector tickDelay--; } } - + @Override public void onOutput() { @@ -87,11 +87,11 @@ public class TileComponentEjector implements ITileComponent, IEjector { return; } - + List outputSides = new ArrayList(); - + IInvConfiguration configurable = (IInvConfiguration)tileEntity; - + for(int i = 0; i < configurable.getConfiguration().length; i++) { if(configurable.getConfiguration()[i] == configurable.getSideData().indexOf(sideData)) @@ -99,24 +99,24 @@ public class TileComponentEjector implements ITileComponent, IEjector outputSides.add(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(i, tileEntity.facing))); } } - + for(int index = 0; index < sideData.availableSlots.length; index++) { int slotID = sideData.availableSlots[index]; - + if(tileEntity.inventory[slotID] == null) { continue; } - + ItemStack stack = tileEntity.inventory[slotID]; List outputs = getTrackedOutputs(index, outputSides); - + for(ForgeDirection side : outputs) { TileEntity tile = Coord4D.get(tileEntity).getFromSide(side).getTileEntity(tileEntity.worldObj); ItemStack prev = stack.copy(); - + if(tile instanceof IInventory && !(tile instanceof ILogisticalTransporter)) { stack = InventoryUtils.putStackInInventory((IInventory)tile, stack, side.ordinal(), false); @@ -124,77 +124,77 @@ public class TileComponentEjector implements ITileComponent, IEjector else if(tile instanceof ILogisticalTransporter) { ItemStack rejects = TransporterUtils.insert(tileEntity, (ILogisticalTransporter)tile, stack, outputColor, true, 0); - + if(TransporterManager.didEmit(stack, rejects)) { stack = rejects; } } - + if(stack == null || prev.stackSize != stack.stackSize) { trackers[index] = side.ordinal(); } - + if(stack == null) { break; } } - + tileEntity.inventory[slotID] = stack; tileEntity.onInventoryChanged(); } - + tickDelay = 20; } - + @Override public boolean isEjecting() { return ejecting; } - + @Override public void setEjecting(boolean eject) { ejecting = eject; MekanismUtils.saveChunk(tileEntity); } - + @Override public boolean hasStrictInput() { return strictInput; } - + @Override public void setStrictInput(boolean strict) { strictInput = strict; MekanismUtils.saveChunk(tileEntity); } - + @Override public void setOutputColor(EnumColor color) { outputColor = color; MekanismUtils.saveChunk(tileEntity); } - + @Override public EnumColor getOutputColor() { return outputColor; } - + @Override public void setInputColor(ForgeDirection side, EnumColor color) { inputColors[side.ordinal()] = color; MekanismUtils.saveChunk(tileEntity); } - + @Override public EnumColor getInputColor(ForgeDirection side) { @@ -202,27 +202,27 @@ public class TileComponentEjector implements ITileComponent, IEjector } @Override - public void read(NBTTagCompound nbtTags) + public void read(NBTTagCompound nbtTags) { ejecting = nbtTags.getBoolean("ejecting"); strictInput = nbtTags.getBoolean("strictInput"); - + if(nbtTags.hasKey("ejectColor")) { outputColor = TransporterUtils.colors.get(nbtTags.getInteger("ejectColor")); } - + for(int i = 0; i < sideData.availableSlots.length; i++) { trackers[i] = nbtTags.getInteger("tracker" + i); } - + for(int i = 0; i < 6; i++) { if(nbtTags.hasKey("inputColors" + i)) { int inC = nbtTags.getInteger("inputColors" + i); - + if(inC != -1) { inputColors[i] = TransporterUtils.colors.get(inC); @@ -235,13 +235,13 @@ public class TileComponentEjector implements ITileComponent, IEjector } @Override - public void read(ByteArrayDataInput dataStream) + public void read(ByteArrayDataInput dataStream) { ejecting = dataStream.readBoolean(); strictInput = dataStream.readBoolean(); - + int c = dataStream.readInt(); - + if(c != -1) { outputColor = TransporterUtils.colors.get(c); @@ -249,11 +249,11 @@ public class TileComponentEjector implements ITileComponent, IEjector else { outputColor = null; } - + for(int i = 0; i < 6; i++) { int inC = dataStream.readInt(); - + if(inC != -1) { inputColors[i] = TransporterUtils.colors.get(inC); @@ -265,21 +265,21 @@ public class TileComponentEjector implements ITileComponent, IEjector } @Override - public void write(NBTTagCompound nbtTags) + public void write(NBTTagCompound nbtTags) { nbtTags.setBoolean("ejecting", ejecting); nbtTags.setBoolean("strictInput", strictInput); - + if(outputColor != null) { nbtTags.setInteger("ejectColor", TransporterUtils.colors.indexOf(outputColor)); } - + for(int i = 0; i < sideData.availableSlots.length; i++) { nbtTags.setInteger("tracker" + i, trackers[i]); } - + for(int i = 0; i < 6; i++) { if(inputColors[i] == null) @@ -291,13 +291,13 @@ public class TileComponentEjector implements ITileComponent, IEjector } } } - + @Override - public void write(ArrayList data) + public void write(ArrayList data) { data.add(ejecting); data.add(strictInput); - + if(outputColor != null) { data.add(TransporterUtils.colors.indexOf(outputColor)); @@ -305,7 +305,7 @@ public class TileComponentEjector implements ITileComponent, IEjector else { data.add(-1); } - + for(int i = 0; i < 6; i++) { if(inputColors[i] == null) diff --git a/common/mekanism/common/tile/component/TileComponentUpgrade.java b/common/mekanism/common/tile/component/TileComponentUpgrade.java index 4328ebb18..be712ed8c 100644 --- a/common/mekanism/common/tile/component/TileComponentUpgrade.java +++ b/common/mekanism/common/tile/component/TileComponentUpgrade.java @@ -15,30 +15,30 @@ public class TileComponentUpgrade implements ITileComponent { /** How long it takes this machine to install an upgrade. */ public static int UPGRADE_TICKS_REQUIRED = 40; - + /** The inventory slot the upgrade slot of this component occupies. */ private int upgradeSlot; - + /** How many upgrade ticks have progressed. */ public int upgradeTicks; - + /** This machine's speed multiplier. */ public int speedMultiplier; - + /** This machine's energy multiplier. */ public int energyMultiplier; - + /** TileEntity implementing this component. */ public TileEntityContainerBlock tileEntity; - + public TileComponentUpgrade(TileEntityContainerBlock tile, int slot) { tileEntity = tile; upgradeSlot = slot; - + tile.components.add(this); } - + @Override public void tick() { @@ -56,9 +56,9 @@ public class TileComponentUpgrade implements ITileComponent { upgradeTicks = 0; energyMultiplier++; - + tileEntity.inventory[upgradeSlot].stackSize--; - + if(tileEntity.inventory[upgradeSlot].stackSize == 0) { tileEntity.inventory[upgradeSlot] = null; @@ -77,14 +77,14 @@ public class TileComponentUpgrade implements ITileComponent { upgradeTicks = 0; speedMultiplier++; - + tileEntity.inventory[upgradeSlot].stackSize--; - + if(tileEntity.inventory[upgradeSlot].stackSize == 0) { tileEntity.inventory[upgradeSlot] = null; } - + tileEntity.onInventoryChanged(); } } @@ -97,19 +97,19 @@ public class TileComponentUpgrade implements ITileComponent } } } - + public int getScaledUpgradeProgress(int i) { return upgradeTicks*i / UPGRADE_TICKS_REQUIRED; } - + @Override public void read(NBTTagCompound nbtTags) { - speedMultiplier = nbtTags.getInteger("speedMultiplier"); - energyMultiplier = nbtTags.getInteger("energyMultiplier"); + speedMultiplier = nbtTags.getInteger("speedMultiplier"); + energyMultiplier = nbtTags.getInteger("energyMultiplier"); } - + @Override public void read(ByteArrayDataInput dataStream) { @@ -117,14 +117,14 @@ public class TileComponentUpgrade implements ITileComponent energyMultiplier = dataStream.readInt(); upgradeTicks = dataStream.readInt(); } - + @Override public void write(NBTTagCompound nbtTags) { - nbtTags.setInteger("speedMultiplier", speedMultiplier); - nbtTags.setInteger("energyMultiplier", energyMultiplier); + nbtTags.setInteger("speedMultiplier", speedMultiplier); + nbtTags.setInteger("energyMultiplier", energyMultiplier); } - + @Override public void write(ArrayList data) { diff --git a/common/mekanism/common/transporter/Finder.java b/common/mekanism/common/transporter/Finder.java index 2cb6d5c6b..eebe3cf50 100644 --- a/common/mekanism/common/transporter/Finder.java +++ b/common/mekanism/common/transporter/Finder.java @@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack; public abstract class Finder { public abstract boolean modifies(ItemStack stack); - + public static class FirstFinder extends Finder { @Override @@ -18,26 +18,26 @@ public abstract class Finder return true; } } - + public static class OreDictFinder extends Finder { public String oreDictName; - + public OreDictFinder(String name) { oreDictName = name; } - + @Override public boolean modifies(ItemStack stack) { List oreKeys = MekanismUtils.getOreDictName(stack); - + if(oreKeys.isEmpty()) { return false; } - + for(String oreKey : oreKeys) { if(oreDictName.equals(oreKey) || oreDictName.equals("*")) @@ -66,20 +66,20 @@ public abstract class Finder } } } - + return false; } } - + public static class ItemStackFinder extends Finder { public ItemStack itemType; - + public ItemStackFinder(ItemStack type) { itemType = type; } - + @Override public boolean modifies(ItemStack stack) { diff --git a/common/mekanism/common/transporter/InvStack.java b/common/mekanism/common/transporter/InvStack.java index 321ed467c..fe79d2b2e 100644 --- a/common/mekanism/common/transporter/InvStack.java +++ b/common/mekanism/common/transporter/InvStack.java @@ -10,55 +10,55 @@ public final class InvStack public IInventory inventory; public ArrayList itemStacks; public ArrayList slotIDs; - + public InvStack(IInventory inv) { inventory = inv; itemStacks = new ArrayList(); slotIDs = new ArrayList(); } - + public InvStack(IInventory inv, int id, ItemStack stack) { inventory = inv; itemStacks = new ArrayList(); slotIDs = new ArrayList(); - + appendStack(id, stack); } - + public ItemStack getStack() { int size = 0; - + for(ItemStack stack : itemStacks) { size += stack.stackSize; } - + if(!itemStacks.isEmpty()) { ItemStack ret = itemStacks.get(0).copy(); ret.stackSize = size; - + return ret; } - + return null; } - + public void appendStack(int id, ItemStack stack) { slotIDs.add(id); itemStacks.add(stack); } - + public void use(int amount) { for(int i = 0; i < slotIDs.size(); i++) { ItemStack stack = itemStacks.get(i); - + if(inventory.getStackInSlot(slotIDs.get(i)).stackSize == stack.stackSize && stack.stackSize <= amount) { inventory.setInventorySlotContents(slotIDs.get(i), null); @@ -70,14 +70,14 @@ public final class InvStack inventory.setInventorySlotContents(slotIDs.get(i), ret); amount -= ret.stackSize; } - + if(amount == 0) { return; } } } - + public void use() { use(getStack().stackSize); diff --git a/common/mekanism/common/transporter/TItemStackFilter.java b/common/mekanism/common/transporter/TItemStackFilter.java index e7628525c..dbe5f7f63 100644 --- a/common/mekanism/common/transporter/TItemStackFilter.java +++ b/common/mekanism/common/transporter/TItemStackFilter.java @@ -14,12 +14,12 @@ import com.google.common.io.ByteArrayDataInput; public class TItemStackFilter extends TransporterFilter { public boolean sizeMode; - + public int min; public int max; - + public ItemStack itemType; - + @Override public boolean canFilter(ItemStack itemStack) { @@ -27,15 +27,15 @@ public class TItemStackFilter extends TransporterFilter { return false; } - + if(sizeMode && max == 0) { return false; } - + return (itemType.getHasSubtypes() ? itemType.isItemEqual(itemStack) : itemType.itemID == itemStack.itemID) && (!sizeMode || itemStack.stackSize >= min); } - + @Override public InvStack getStackFromInventory(IInventory inv, ForgeDirection side) { @@ -47,61 +47,61 @@ public class TItemStackFilter extends TransporterFilter return InventoryUtils.takeTopStack(inv, side.ordinal(), new ItemStackFinder(itemType)); } } - + @Override public void write(NBTTagCompound nbtTags) { super.write(nbtTags); - + nbtTags.setInteger("type", 0); nbtTags.setBoolean("sizeMode", sizeMode); nbtTags.setInteger("min", min); nbtTags.setInteger("max", max); itemType.writeToNBT(nbtTags); } - + @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - + sizeMode = nbtTags.getBoolean("sizeMode"); min = nbtTags.getInteger("min"); max = nbtTags.getInteger("max"); - + itemType = ItemStack.loadItemStackFromNBT(nbtTags); } - + @Override public void write(ArrayList data) { data.add(0); - + super.write(data); - + data.add(sizeMode); data.add(min); data.add(max); - + data.add(itemType.itemID); data.add(itemType.stackSize); data.add(itemType.getItemDamage()); } - + @Override protected void read(ByteArrayDataInput dataStream) { super.read(dataStream); - + sizeMode = dataStream.readBoolean(); min = dataStream.readInt(); max = dataStream.readInt(); - + itemType = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + super.hashCode(); @@ -113,14 +113,14 @@ public class TItemStackFilter extends TransporterFilter code = 31 * code + max; return code; } - + @Override public boolean equals(Object filter) { return super.equals(filter) && filter instanceof TItemStackFilter && ((TItemStackFilter)filter).itemType.isItemEqual(itemType) && ((TItemStackFilter)filter).sizeMode == sizeMode && ((TItemStackFilter)filter).min == min && ((TItemStackFilter)filter).max == max; } - + @Override public TItemStackFilter clone() { @@ -130,7 +130,7 @@ public class TItemStackFilter extends TransporterFilter filter.sizeMode = sizeMode; filter.min = min; filter.max = max; - + return filter; } } diff --git a/common/mekanism/common/transporter/TOreDictFilter.java b/common/mekanism/common/transporter/TOreDictFilter.java index 8c39e9b99..310b84ead 100644 --- a/common/mekanism/common/transporter/TOreDictFilter.java +++ b/common/mekanism/common/transporter/TOreDictFilter.java @@ -16,7 +16,7 @@ import com.google.common.io.ByteArrayDataInput; public class TOreDictFilter extends TransporterFilter { public String oreDictName; - + @Override public boolean canFilter(ItemStack itemStack) { @@ -24,73 +24,73 @@ public class TOreDictFilter extends TransporterFilter { return false; } - + return new OreDictFinder(oreDictName).modifies(itemStack); } - + @Override public InvStack getStackFromInventory(IInventory inv, ForgeDirection side) { return InventoryUtils.takeTopStack(inv, side.ordinal(), new OreDictFinder(oreDictName)); } - + @Override public void write(NBTTagCompound nbtTags) { super.write(nbtTags); - + nbtTags.setInteger("type", 1); nbtTags.setString("oreDictName", oreDictName); } - + @Override protected void read(NBTTagCompound nbtTags) { super.read(nbtTags); - + oreDictName = nbtTags.getString("oreDictName"); } - + @Override public void write(ArrayList data) { data.add(1); - + super.write(data); - + data.add(oreDictName); } - + @Override protected void read(ByteArrayDataInput dataStream) { super.read(dataStream); - + oreDictName = dataStream.readUTF(); } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + super.hashCode(); code = 31 * code + oreDictName.hashCode(); return code; } - + @Override public boolean equals(Object filter) { return super.equals(filter) && filter instanceof TOreDictFilter && ((TOreDictFilter)filter).oreDictName.equals(oreDictName); } - + @Override public TOreDictFilter clone() { TOreDictFilter filter = new TOreDictFilter(); filter.color = color; filter.oreDictName = oreDictName; - + return filter; } } diff --git a/common/mekanism/common/transporter/TransporterFilter.java b/common/mekanism/common/transporter/TransporterFilter.java index b4295abde..a7041dd08 100644 --- a/common/mekanism/common/transporter/TransporterFilter.java +++ b/common/mekanism/common/transporter/TransporterFilter.java @@ -11,14 +11,14 @@ import net.minecraftforge.common.ForgeDirection; import com.google.common.io.ByteArrayDataInput; -public abstract class TransporterFilter -{ +public abstract class TransporterFilter +{ public EnumColor color; - + public abstract boolean canFilter(ItemStack itemStack); - + public abstract InvStack getStackFromInventory(IInventory inv, ForgeDirection side); - + public void write(NBTTagCompound nbtTags) { if(color != null) @@ -26,7 +26,7 @@ public abstract class TransporterFilter nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); } } - + protected void read(NBTTagCompound nbtTags) { if(nbtTags.hasKey("color")) @@ -34,7 +34,7 @@ public abstract class TransporterFilter color = TransporterUtils.colors.get(nbtTags.getInteger("color")); } } - + public void write(ArrayList data) { if(color != null) @@ -45,11 +45,11 @@ public abstract class TransporterFilter data.add(-1); } } - + protected void read(ByteArrayDataInput dataStream) { int c = dataStream.readInt(); - + if(c != -1) { color = TransporterUtils.colors.get(c); @@ -58,13 +58,13 @@ public abstract class TransporterFilter color = null; } } - + public static TransporterFilter readFromNBT(NBTTagCompound nbtTags) { int type = nbtTags.getInteger("type"); - + TransporterFilter filter = null; - + if(type == 0) { filter = new TItemStackFilter(); @@ -72,18 +72,18 @@ public abstract class TransporterFilter else { filter = new TOreDictFilter(); } - + filter.read(nbtTags); - + return filter; } - + public static TransporterFilter readFromPacket(ByteArrayDataInput dataStream) { int type = dataStream.readInt(); - + TransporterFilter filter = null; - + if(type == 0) { filter = new TItemStackFilter(); @@ -92,20 +92,20 @@ public abstract class TransporterFilter { filter = new TOreDictFilter(); } - + filter.read(dataStream); - + return filter; } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + (color != null ? color.ordinal() : -1); return code; } - + @Override public boolean equals(Object filter) { diff --git a/common/mekanism/common/transporter/TransporterManager.java b/common/mekanism/common/transporter/TransporterManager.java index 9d880ca08..8a26f16b6 100644 --- a/common/mekanism/common/transporter/TransporterManager.java +++ b/common/mekanism/common/transporter/TransporterManager.java @@ -22,21 +22,21 @@ import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; public class TransporterManager { public static Set flowingStacks = new HashSet(); - + public static void add(TransporterStack stack) { flowingStacks.add(stack); } - + public static void remove(TransporterStack stack) { flowingStacks.remove(stack); } - + public static List getStacksToDest(Coord4D dest) { List ret = new ArrayList(); - + for(TransporterStack stack : flowingStacks) { if(stack != null && stack.pathType != Path.NONE && stack.hasPath()) @@ -47,16 +47,16 @@ public class TransporterManager } } } - + return ret; } - + public static ItemStack[] copyInvFromSide(IInventory inv, int side) { inv = InventoryUtils.checkChestInv(inv); - + ItemStack[] ret = new ItemStack[inv.getSizeInventory()]; - + if(!(inv instanceof ISidedInventory)) { for(int i = 0; i <= inv.getSizeInventory() - 1; i++) @@ -67,140 +67,140 @@ public class TransporterManager else { ISidedInventory sidedInventory = (ISidedInventory)inv; int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); - + if(slots == null || slots.length == 0) { return null; } - + for(int get = 0; get <= slots.length - 1; get++) { int slotID = slots[get]; - + ret[slotID] = sidedInventory.getStackInSlot(slotID) != null ? sidedInventory.getStackInSlot(slotID).copy() : null; } } - + return ret; } - + public static void testInsert(IInventory inv, ItemStack[] testInv, int side, TransporterStack stack) { ItemStack toInsert = stack.itemStack.copy(); - - if(stack.pathType != Path.HOME && inv instanceof IInvConfiguration) - { - IInvConfiguration config = (IInvConfiguration)inv; - int tileSide = config.getOrientation(); - EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); - - if(config.getEjector().hasStrictInput() && configColor != null && configColor != stack.color) - { - return; - } - } - - if(inv instanceof IDeepStorageUnit) - { - return; - } - + + if(stack.pathType != Path.HOME && inv instanceof IInvConfiguration) + { + IInvConfiguration config = (IInvConfiguration)inv; + int tileSide = config.getOrientation(); + EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); + + if(config.getEjector().hasStrictInput() && configColor != null && configColor != stack.color) + { + return; + } + } + + if(inv instanceof IDeepStorageUnit) + { + return; + } + if(!(inv instanceof ISidedInventory)) { for(int i = 0; i <= inv.getSizeInventory() - 1; i++) { if(stack.pathType != Path.HOME) { - if(!inv.isItemValidForSlot(i, toInsert)) + if(!inv.isItemValidForSlot(i, toInsert)) { continue; } } - + ItemStack inSlot = testInv[i]; - + if(inSlot == null) { testInv[i] = toInsert; return; - } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + } + else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) + if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { ItemStack toSet = toInsert.copy(); toSet.stackSize += inSlot.stackSize; - + testInv[i] = toSet; return; - } + } else { int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize(); - + ItemStack toSet = toInsert.copy(); toSet.stackSize = inSlot.getMaxStackSize(); - + ItemStack remains = toInsert.copy(); remains.stackSize = rejects; - + testInv[i] = toSet; - + toInsert = remains; } } } - } + } else { ISidedInventory sidedInventory = (ISidedInventory)inv; int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); - + if(slots != null && slots.length != 0) { if(stack.pathType != Path.HOME && sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0) { slots = sidedInventory.getAccessibleSlotsFromSide(1); } - - for(int get = 0; get <= slots.length - 1; get++) + + for(int get = 0; get <= slots.length - 1; get++) { int slotID = slots[get]; - + if(stack.pathType != Path.HOME) { - if(!sidedInventory.isItemValidForSlot(slotID, toInsert) && !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) + if(!sidedInventory.isItemValidForSlot(slotID, toInsert) && !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) { continue; } } - + ItemStack inSlot = testInv[slotID]; - - if(inSlot == null) + + if(inSlot == null) { testInv[slotID] = toInsert; return; - } + } else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) + if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { ItemStack toSet = toInsert.copy(); toSet.stackSize += inSlot.stackSize; - + testInv[slotID] = toSet; return; - } + } else { int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize(); - + ItemStack toSet = toInsert.copy(); toSet.stackSize = inSlot.getMaxStackSize(); - + ItemStack remains = toInsert.copy(); remains.stackSize = rejects; - + testInv[slotID] = toSet; - + toInsert = remains; } } @@ -208,84 +208,84 @@ public class TransporterManager } } } - + public static boolean didEmit(ItemStack stack, ItemStack returned) { return returned == null || returned.stackSize < stack.stackSize; } - + public static ItemStack getToUse(ItemStack stack, ItemStack returned) { if(returned == null || returned.stackSize == 0) { return stack; } - + return MekanismUtils.size(stack, stack.stackSize-returned.stackSize); } - + /** * @return rejects */ public static ItemStack getPredictedInsert(TileEntity tileEntity, EnumColor color, ItemStack itemStack, int side) { if(!(tileEntity instanceof IInventory)) - { - return itemStack; - } - - if(tileEntity instanceof IInvConfiguration) - { - IInvConfiguration config = (IInvConfiguration)tileEntity; - int tileSide = config.getOrientation(); - EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); - - if(config.getEjector().hasStrictInput() && configColor != null && configColor != color) - { - return itemStack; - } - } - - IInventory inventory = (IInventory)tileEntity; - ItemStack[] testInv = copyInvFromSide(inventory, side); - - if(testInv == null) - { - return itemStack; - } - - List insertQueue = getStacksToDest(Coord4D.get(tileEntity)); - - for(TransporterStack tStack : insertQueue) - { - testInsert(inventory, testInv, side, tStack); - } - - ItemStack toInsert = itemStack.copy(); - - if(!(inventory instanceof ISidedInventory)) { - inventory = InventoryUtils.checkChestInv(inventory); - + return itemStack; + } + + if(tileEntity instanceof IInvConfiguration) + { + IInvConfiguration config = (IInvConfiguration)tileEntity; + int tileSide = config.getOrientation(); + EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); + + if(config.getEjector().hasStrictInput() && configColor != null && configColor != color) + { + return itemStack; + } + } + + IInventory inventory = (IInventory)tileEntity; + ItemStack[] testInv = copyInvFromSide(inventory, side); + + if(testInv == null) + { + return itemStack; + } + + List insertQueue = getStacksToDest(Coord4D.get(tileEntity)); + + for(TransporterStack tStack : insertQueue) + { + testInsert(inventory, testInv, side, tStack); + } + + ItemStack toInsert = itemStack.copy(); + + if(!(inventory instanceof ISidedInventory)) + { + inventory = InventoryUtils.checkChestInv(inventory); + for(int i = 0; i <= inventory.getSizeInventory() - 1; i++) { - if(!inventory.isItemValidForSlot(i, toInsert)) + if(!inventory.isItemValidForSlot(i, toInsert)) { continue; } - + ItemStack inSlot = testInv[i]; if(inSlot == null) { return null; - } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + } + else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) + if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { return null; - } + } else { int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize(); @@ -296,7 +296,7 @@ public class TransporterManager } } } - } + } else { ISidedInventory sidedInventory = (ISidedInventory)inventory; int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); @@ -307,31 +307,31 @@ public class TransporterManager { slots = sidedInventory.getAccessibleSlotsFromSide(1); }*/ - - for(int get = 0; get <= slots.length - 1; get++) + + for(int get = 0; get <= slots.length - 1; get++) { int slotID = slots[get]; - - if(!sidedInventory.isItemValidForSlot(slotID, toInsert) || !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) + + if(!sidedInventory.isItemValidForSlot(slotID, toInsert) || !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) { continue; } - + ItemStack inSlot = testInv[slotID]; - if(inSlot == null) + if(inSlot == null) { return null; - } + } else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) + if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { return null; - } + } else { int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize(); - + if(rejects < toInsert.stackSize) { toInsert = MekanismUtils.size(toInsert, rejects); @@ -341,7 +341,7 @@ public class TransporterManager } } } - - return toInsert; + + return toInsert; } } diff --git a/common/mekanism/common/transporter/TransporterPathfinder.java b/common/mekanism/common/transporter/TransporterPathfinder.java index 839386edf..2c0300eee 100644 --- a/common/mekanism/common/transporter/TransporterPathfinder.java +++ b/common/mekanism/common/transporter/TransporterPathfinder.java @@ -25,56 +25,56 @@ public final class TransporterPathfinder public static class IdlePath { public World worldObj; - + public Coord4D start; - + public Set destinations = new HashSet(); - + public TransporterStack transportStack; - + public IdlePath(World world, Coord4D obj, TransporterStack stack) { worldObj = world; start = obj; transportStack = stack; } - + public void loop(Coord4D pointer, ArrayList currentPath, int dist) { if(pointer == null) { return; } - + currentPath.add(pointer); - + dist += ((ILogisticalTransporter)pointer.getTileEntity(worldObj)).getCost(); - + boolean found = false; - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = pointer.getFromSide(side).getTileEntity(worldObj); - + if(transportStack.canInsertToTransporter(tile, side) && !currentPath.contains(Coord4D.get(tile))) { loop(Coord4D.get(tile), (ArrayList)currentPath.clone(), dist); found = true; } } - + if(!found) { destinations.add(new Destination(currentPath, dist, true, null)); } } - + public List find() { loop(start, new ArrayList(), 0); - - Destination farthest = null; - + + Destination farthest = null; + for(Destination obj : destinations) { if(farthest == null || obj.score > farthest.score) @@ -85,44 +85,44 @@ public final class TransporterPathfinder } } } - + if(farthest == null) { return null; } - + return farthest.path; } } - + public static class Destination implements Comparable { public List path = new ArrayList(); public double score; public ItemStack rejected; - + public Destination(ArrayList list, double d, boolean inv, ItemStack rejects) { path = (List)list.clone(); - + if(inv) { Collections.reverse(path); } - + score = d; rejected = rejects; } - + @Override - public int hashCode() + public int hashCode() { int code = 1; code = 31 * code + path.hashCode(); code = 31 * code + new Double(score).hashCode(); return code; } - + @Override public boolean equals(Object dest) { @@ -145,62 +145,62 @@ public final class TransporterPathfinder } } } - + public static class InventoryFinder { public World worldObj; - + public Set iterated = new HashSet(); - + public Set destsFound = new HashSet(); - + public Map rejects = new HashMap(); - + public Coord4D start; - + public TransporterStack transportStack; - + public InventoryFinder(World world, Coord4D obj, TransporterStack stack) { worldObj = world; start = obj; transportStack = stack; } - + public void loop(Coord4D pointer) { if(pointer == null) { return; } - + iterated.add(pointer); - + for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = pointer.getFromSide(side).getTileEntity(worldObj); - + if(tile != null) { if(Coord4D.get(tile).equals(transportStack.originalLocation)) { continue; } - + if(tile instanceof IInventory) { if(pointer.getTileEntity(worldObj) instanceof ILogisticalTransporter) { ILogisticalTransporter trans = (ILogisticalTransporter)pointer.getTileEntity(worldObj); - + if(!trans.canEmitTo(tile, side)) { continue; } } - + ItemStack stack = TransporterManager.getPredictedInsert(tile, transportStack.color, transportStack.itemStack, side.ordinal()); - + if(TransporterManager.didEmit(transportStack.itemStack, stack)) { destsFound.add(Coord4D.get(tile)); @@ -214,15 +214,15 @@ public final class TransporterPathfinder } } } - + public Set find() { loop(start); - + return destsFound; } } - + public static List getPaths(ILogisticalTransporter start, TransporterStack stack, int min) { DestChecker checker = new DestChecker() @@ -233,15 +233,15 @@ public final class TransporterPathfinder return InventoryUtils.canInsert(tile, stack.color, stack.itemStack, side, false); } }; - + InventoryFinder d = new InventoryFinder(start.getTile().worldObj, Coord4D.get(start.getTile()), stack); Set destsFound = d.find(); List paths = new ArrayList(); - + for(Coord4D obj : destsFound) { Pathfinder p = new Pathfinder(checker, start.getTile().worldObj, obj, Coord4D.get(start.getTile()), stack); - + if(p.getPath().size() >= 2) { if(TransporterManager.getToUse(stack.itemStack, d.rejects.get(obj)).stackSize >= min) @@ -250,30 +250,30 @@ public final class TransporterPathfinder } } } - + Collections.sort(paths); - + return paths; } - + public static Destination getNewBasePath(ILogisticalTransporter start, TransporterStack stack, int min) { List paths = getPaths(start, stack, min); - + if(paths.isEmpty()) { return null; } - + return paths.get(0); } - + public static Destination getNewRRPath(ILogisticalTransporter start, TransporterStack stack, TileEntityLogisticalSorter outputter, int min) { List paths = getPaths(start, stack, min); - + Map destPaths = new HashMap(); - + for(Destination d : paths) { if(destPaths.get(d.path.get(0)) == null || destPaths.get(d.path.get(0)).score < d.score) @@ -281,43 +281,43 @@ public final class TransporterPathfinder destPaths.put(d.path.get(0), d); } } - + List dests = new ArrayList(); dests.addAll(destPaths.values()); - + Collections.sort(dests); - - Destination closest = null; - - if(!dests.isEmpty()) - { - if(outputter.rrIndex <= dests.size()-1) - { - closest = dests.get(outputter.rrIndex); - - if(outputter.rrIndex == dests.size()-1) - { - outputter.rrIndex = 0; - } - else if(outputter.rrIndex < dests.size()-1) - { - outputter.rrIndex++; - } - } - else { - closest = dests.get(dests.size()-1); - outputter.rrIndex = 0; - } - } - - if(closest == null) - { - return null; - } - + + Destination closest = null; + + if(!dests.isEmpty()) + { + if(outputter.rrIndex <= dests.size()-1) + { + closest = dests.get(outputter.rrIndex); + + if(outputter.rrIndex == dests.size()-1) + { + outputter.rrIndex = 0; + } + else if(outputter.rrIndex < dests.size()-1) + { + outputter.rrIndex++; + } + } + else { + closest = dests.get(dests.size()-1); + outputter.rrIndex = 0; + } + } + + if(closest == null) + { + return null; + } + return closest; } - + public static class Pathfinder { public final Set openSet, closedSet; @@ -331,23 +331,23 @@ public final class TransporterPathfinder public final Coord4D finalNode; public final TransporterStack transportStack; - + public final DestChecker destChecker; - + public double finalScore; public ArrayList results; private World worldObj; - public Pathfinder(DestChecker checker, World world, Coord4D finishObj, Coord4D startObj, TransporterStack stack) + public Pathfinder(DestChecker checker, World world, Coord4D finishObj, Coord4D startObj, TransporterStack stack) { destChecker = checker; worldObj = world; - + finalNode = finishObj; start = startObj; - + transportStack = stack; openSet = new HashSet(); @@ -359,11 +359,11 @@ public final class TransporterPathfinder fScore = new HashMap(); results = new ArrayList(); - + find(start); } - public boolean find(Coord4D start) + public boolean find(Coord4D start) { openSet.add(start); gScore.put(start, 0D); @@ -371,7 +371,7 @@ public final class TransporterPathfinder int blockCount = 0; - for(int i = 0; i < 6; i++) + for(int i = 0; i < 6; i++) { ForgeDirection direction = ForgeDirection.getOrientation(i); Coord4D neighbor = start.translate(direction.offsetX, direction.offsetY, direction.offsetZ); @@ -382,21 +382,21 @@ public final class TransporterPathfinder } } - if(blockCount >= 6) + if(blockCount >= 6) { return false; } double maxSearchDistance = start.distanceTo(finalNode) * 2; - while(!openSet.isEmpty()) + while(!openSet.isEmpty()) { Coord4D currentNode = null; double lowestFScore = 0; for(Coord4D node : openSet) { - if(currentNode == null || fScore.get(node) < lowestFScore) + if(currentNode == null || fScore.get(node) < lowestFScore) { currentNode = node; lowestFScore = fScore.get(node); @@ -411,7 +411,7 @@ public final class TransporterPathfinder openSet.remove(currentNode); closedSet.add(currentNode); - for(int i = 0; i < 6; i++) + for(int i = 0; i < 6; i++) { ForgeDirection direction = ForgeDirection.getOrientation(i); Coord4D neighbor = currentNode.getFromSide(direction); @@ -420,20 +420,20 @@ public final class TransporterPathfinder { TileEntity tile = neighbor.getTileEntity(worldObj); double tentativeG = gScore.get(currentNode) + currentNode.distanceTo(neighbor); - + tentativeG += ((ILogisticalTransporter)tile).getCost(); - if(closedSet.contains(neighbor)) + if(closedSet.contains(neighbor)) { if(tentativeG >= gScore.get(neighbor)) { continue; } } - + TileEntity currTile = currentNode.getTileEntity(worldObj); - if(!openSet.contains(neighbor) || tentativeG < gScore.get(neighbor)) + if(!openSet.contains(neighbor) || tentativeG < gScore.get(neighbor)) { navMap.put(neighbor, currentNode); gScore.put(neighbor, tentativeG); @@ -452,36 +452,36 @@ public final class TransporterPathfinder return false; } - private ArrayList reconstructPath(HashMap naviMap, Coord4D currentNode) + private ArrayList reconstructPath(HashMap naviMap, Coord4D currentNode) { ArrayList path = new ArrayList(); path.add(currentNode); - - if(naviMap.containsKey(currentNode)) + + if(naviMap.containsKey(currentNode)) { path.addAll(reconstructPath(naviMap, naviMap.get(currentNode))); } - + finalScore = gScore.get(currentNode) + currentNode.distanceTo(finalNode); return path; } - + public ArrayList getPath() { ArrayList path = new ArrayList(); path.add(finalNode); path.addAll((ArrayList)results.clone()); - + return path; } - private double getEstimate(Coord4D start, Coord4D target2) + private double getEstimate(Coord4D start, Coord4D target2) { return start.distanceTo(target2); } - + public static class DestChecker { public boolean isValid(TransporterStack stack, int side, TileEntity tile) @@ -490,12 +490,12 @@ public final class TransporterPathfinder } } } - + public static List getIdlePath(ILogisticalTransporter start, TransporterStack stack) { if(stack.homeLocation != null) { - DestChecker checker = new DestChecker() + DestChecker checker = new DestChecker() { @Override public boolean isValid(TransporterStack stack, int side, TileEntity tile) @@ -503,10 +503,10 @@ public final class TransporterPathfinder return InventoryUtils.canInsert(tile, stack.color, stack.itemStack, side, true); } }; - + Pathfinder p = new Pathfinder(checker, start.getTile().worldObj, stack.homeLocation, Coord4D.get(start.getTile()), stack); List path = p.getPath(); - + if(path.size() >= 2) { stack.pathType = Path.HOME; @@ -519,16 +519,16 @@ public final class TransporterPathfinder } } } - + IdlePath d = new IdlePath(start.getTile().worldObj, Coord4D.get(start.getTile()), stack); List path = d.find(); stack.pathType = Path.NONE; - + if(path == null) { return null; } - + return path; } } diff --git a/common/mekanism/common/transporter/TransporterStack.java b/common/mekanism/common/transporter/TransporterStack.java index 99ec6d009..9e22c125a 100644 --- a/common/mekanism/common/transporter/TransporterStack.java +++ b/common/mekanism/common/transporter/TransporterStack.java @@ -16,26 +16,26 @@ import net.minecraftforge.common.ForgeDirection; import com.google.common.io.ByteArrayDataInput; -public class TransporterStack +public class TransporterStack { public ItemStack itemStack; - + public int progress; - + public EnumColor color = null; - + public boolean initiatedPath = false; - + public List pathToTarget = new ArrayList(); - + public Coord4D originalLocation; public Coord4D homeLocation; - + public Coord4D clientNext; public Coord4D clientPrev; - + public Path pathType; - + public void write(ILogisticalTransporter tileEntity, ArrayList data) { if(color != null) @@ -45,10 +45,10 @@ public class TransporterStack else { data.add(-1); } - + data.add(progress); data.add(pathType.ordinal()); - + if(pathToTarget.indexOf(Coord4D.get(tileEntity.getTile())) > 0) { data.add(true); @@ -57,18 +57,18 @@ public class TransporterStack else { data.add(false); } - + getPrev(tileEntity).write(data); - + data.add(itemStack.itemID); data.add(itemStack.stackSize); data.add(itemStack.getItemDamage()); } - + public void read(ByteArrayDataInput dataStream) { int c = dataStream.readInt(); - + if(c != -1) { color = TransporterUtils.colors.get(c); @@ -76,159 +76,159 @@ public class TransporterStack else { color = null; } - + progress = dataStream.readInt(); pathType = Path.values()[dataStream.readInt()]; - + if(dataStream.readBoolean()) { clientNext = Coord4D.read(dataStream); } - + clientPrev = Coord4D.read(dataStream); - + itemStack = new ItemStack(dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); } - + public void write(NBTTagCompound nbtTags) { if(color != null) { nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); } - + nbtTags.setInteger("progress", progress); nbtTags.setCompoundTag("originalLocation", originalLocation.write(new NBTTagCompound())); - + if(homeLocation != null) { nbtTags.setCompoundTag("homeLocation", homeLocation.write(new NBTTagCompound())); } - + nbtTags.setInteger("pathType", pathType.ordinal()); itemStack.writeToNBT(nbtTags); } - + public void read(NBTTagCompound nbtTags) { if(nbtTags.hasKey("color")) { color = TransporterUtils.colors.get(nbtTags.getInteger("color")); } - + progress = nbtTags.getInteger("progress"); originalLocation = Coord4D.read(nbtTags.getCompoundTag("originalLocation")); - + if(nbtTags.hasKey("homeLocation")) { homeLocation = Coord4D.read(nbtTags.getCompoundTag("homeLocation")); } - + pathType = Path.values()[nbtTags.getInteger("pathType")]; itemStack = ItemStack.loadItemStackFromNBT(nbtTags); } - + public static TransporterStack readFromNBT(NBTTagCompound nbtTags) { TransporterStack stack = new TransporterStack(); stack.read(nbtTags); - + return stack; } - + public static TransporterStack readFromPacket(ByteArrayDataInput dataStream) { TransporterStack stack = new TransporterStack(); stack.read(dataStream); - + return stack; } - + public boolean hasPath() { return pathToTarget != null && pathToTarget.size() >= 2; } - + public ItemStack recalculatePath(ILogisticalTransporter tileEntity, int min) { Destination newPath = TransporterPathfinder.getNewBasePath(tileEntity, this, min); - + if(newPath == null) { return itemStack; } - + pathToTarget = newPath.path; - + pathType = Path.DEST; initiatedPath = true; - + return newPath.rejected; } - + public ItemStack recalculateRRPath(TileEntityLogisticalSorter outputter, ILogisticalTransporter tileEntity, int min) { Destination newPath = TransporterPathfinder.getNewRRPath(tileEntity, this, outputter, min); - + if(newPath == null) { return itemStack; } - + pathToTarget = newPath.path; - + pathType = Path.DEST; initiatedPath = true; - + return newPath.rejected; } - + public boolean calculateIdle(ILogisticalTransporter tileEntity) { List newPath = TransporterPathfinder.getIdlePath(tileEntity, this); - + if(newPath == null) { return false; } - + pathToTarget = newPath; - + originalLocation = Coord4D.get(tileEntity.getTile()); initiatedPath = true; - + return true; } - + public boolean isFinal(ILogisticalTransporter tileEntity) { return pathToTarget.indexOf(Coord4D.get(tileEntity.getTile())) == (pathType == Path.NONE ? 0 : 1); } - + public Coord4D getNext(ILogisticalTransporter tileEntity) { if(!tileEntity.getTile().worldObj.isRemote) { int index = pathToTarget.indexOf(Coord4D.get(tileEntity.getTile()))-1; - + if(index < 0) { return null; } - + return pathToTarget.get(index); } else { return clientNext; } } - + public Coord4D getPrev(ILogisticalTransporter tileEntity) { if(!tileEntity.getTile().worldObj.isRemote) { int index = pathToTarget.indexOf(Coord4D.get(tileEntity.getTile()))+1; - + if(index < pathToTarget.size()) { return pathToTarget.get(index); @@ -241,7 +241,7 @@ public class TransporterStack return clientPrev; } } - + public int getSide(ILogisticalTransporter tileEntity) { if(progress < 50) @@ -265,33 +265,33 @@ public class TransporterStack return getNext(tileEntity).sideDifference(Coord4D.get(tileEntity.getTile())).ordinal(); } } - + return 0; } - + public boolean canInsertToTransporter(TileEntity tileEntity, ForgeDirection side) { if(!(tileEntity instanceof ILogisticalTransporter)) { return false; } - + TileEntity from = Coord4D.get(tileEntity).getFromSide(side.getOpposite()).getTileEntity(tileEntity.worldObj); ILogisticalTransporter transporter = (ILogisticalTransporter)tileEntity; - + if(!transporter.canConnectMutual(side.getOpposite())) { return false; } - + return transporter.getColor() == color || transporter.getColor() == null; } - + public Coord4D getDest() { return pathToTarget.get(0); } - + public static enum Path { DEST, HOME, NONE diff --git a/common/mekanism/common/util/CableUtils.java b/common/mekanism/common/util/CableUtils.java index 784c4f9e3..94774a13a 100644 --- a/common/mekanism/common/util/CableUtils.java +++ b/common/mekanism/common/util/CableUtils.java @@ -35,27 +35,27 @@ public final class CableUtils allSides.remove(ForgeDirection.UNKNOWN); } - /** - * Gets all the connected energy acceptors, whether IC2-based or BuildCraft-based, surrounding a specific tile entity. - * @param tileEntity - center tile entity - * @return TileEntity[] of connected acceptors - */ - public static TileEntity[] getConnectedEnergyAcceptors(TileEntity tileEntity) - { - TileEntity[] acceptors = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + /** + * Gets all the connected energy acceptors, whether IC2-based or BuildCraft-based, surrounding a specific tile entity. + * @param tileEntity - center tile entity + * @return TileEntity[] of connected acceptors + */ + public static TileEntity[] getConnectedEnergyAcceptors(TileEntity tileEntity) + { + TileEntity[] acceptors = new TileEntity[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); - + if(isEnergyAcceptor(acceptor)) { acceptors[orientation.ordinal()] = acceptor; } - } - - return acceptors; - } + } + + return acceptors; + } public static boolean isEnergyAcceptor(TileEntity tileEntity) { @@ -64,28 +64,28 @@ public final class CableUtils (tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IGridTransmitter) && MekanismUtils.useBuildCraft()) || tileEntity instanceof IEnergyHandler); } - - /** - * Gets all the connected cables around a specific tile entity. - * @param tileEntity - center tile entity - * @return TileEntity[] of connected cables - */ - public static TileEntity[] getConnectedCables(TileEntity tileEntity) - { - TileEntity[] cables = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + + /** + * Gets all the connected cables around a specific tile entity. + * @param tileEntity - center tile entity + * @return TileEntity[] of connected cables + */ + public static TileEntity[] getConnectedCables(TileEntity tileEntity) + { + TileEntity[] cables = new TileEntity[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity cable = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); - + if(isCable(cable)) { cables[orientation.ordinal()] = cable; } - } - - return cables; - } + } + + return cables; + } public static boolean isCable(TileEntity tileEntity) { @@ -126,26 +126,26 @@ public final class CableUtils } /** - * Gets all the connected cables around a specific tile entity. - * @param tileEntity - center tile entity - * @return TileEntity[] of connected cables - */ - public static TileEntity[] getConnectedOutputters(TileEntity tileEntity) - { - TileEntity[] outputters = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + * Gets all the connected cables around a specific tile entity. + * @param tileEntity - center tile entity + * @return TileEntity[] of connected cables + */ + public static TileEntity[] getConnectedOutputters(TileEntity tileEntity) + { + TileEntity[] outputters = new TileEntity[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity outputter = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); - + if(isOutputter(tileEntity, orientation)) { outputters[orientation.ordinal()] = outputter; } - } - - return outputters; - } + } + + return outputters; + } public static boolean isOutputter(TileEntity tileEntity, ForgeDirection side) { @@ -154,152 +154,152 @@ public final class CableUtils (tileEntity instanceof IEnergyHandler && ((IEnergyHandler)tileEntity).canInterface(side.getOpposite())) || (tileEntity instanceof IPowerEmitter && ((IPowerEmitter)tileEntity).canEmitPowerFrom(side.getOpposite())); } - - /** - * Whether or not a cable can connect to a specific acceptor. - * @param side - side to check - * @param tile - cable TileEntity - * @return whether or not the cable can connect to the specific side - */ - public static boolean canConnectToAcceptor(ForgeDirection side, TileEntity tile) - { - if(tile == null) - { - return false; - } - - TileEntity tileEntity = Coord4D.get(tile).getFromSide(side).getTileEntity(tile.worldObj); - - return isConnectable(tile, tileEntity, side); - } - - public static boolean isConnectable(TileEntity orig, TileEntity tileEntity, ForgeDirection side) - { - if(tileEntity instanceof IGridTransmitter) - { - return false; - } - - if(tileEntity instanceof IStrictEnergyAcceptor) - { - if(((IStrictEnergyAcceptor)tileEntity).canReceiveEnergy(side.getOpposite())) - { - return true; - } - } - else if(tileEntity instanceof IEnergyAcceptor) - { - if(((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(orig, side.getOpposite())) - { - return true; - } - } - else if(tileEntity instanceof ICableOutputter) - { - if(((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) - { - return true; - } - } - else if(tileEntity instanceof IEnergyHandler) - { - if(((IEnergyHandler)tileEntity).canInterface(side.getOpposite())) - { - return true; - } - } - else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) - { - if(((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite()) != null) - { - return true; - } - } - - return false; - } - - public static void emit(TileEntityElectricBlock emitter) - { - if(!emitter.worldObj.isRemote && MekanismUtils.canFunction(emitter)) - { + + /** + * Whether or not a cable can connect to a specific acceptor. + * @param side - side to check + * @param tile - cable TileEntity + * @return whether or not the cable can connect to the specific side + */ + public static boolean canConnectToAcceptor(ForgeDirection side, TileEntity tile) + { + if(tile == null) + { + return false; + } + + TileEntity tileEntity = Coord4D.get(tile).getFromSide(side).getTileEntity(tile.worldObj); + + return isConnectable(tile, tileEntity, side); + } + + public static boolean isConnectable(TileEntity orig, TileEntity tileEntity, ForgeDirection side) + { + if(tileEntity instanceof IGridTransmitter) + { + return false; + } + + if(tileEntity instanceof IStrictEnergyAcceptor) + { + if(((IStrictEnergyAcceptor)tileEntity).canReceiveEnergy(side.getOpposite())) + { + return true; + } + } + else if(tileEntity instanceof IEnergyAcceptor) + { + if(((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(orig, side.getOpposite())) + { + return true; + } + } + else if(tileEntity instanceof ICableOutputter) + { + if(((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) + { + return true; + } + } + else if(tileEntity instanceof IEnergyHandler) + { + if(((IEnergyHandler)tileEntity).canInterface(side.getOpposite())) + { + return true; + } + } + else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) + { + if(((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite()) != null) + { + return true; + } + } + + return false; + } + + public static void emit(TileEntityElectricBlock emitter) + { + if(!emitter.worldObj.isRemote && MekanismUtils.canFunction(emitter)) + { double sendingEnergy = Math.min(emitter.getEnergy(), emitter.getMaxOutput()); - + if(sendingEnergy > 0) { - List outputtingSides = new ArrayList(); - boolean[] connectable = getConnections(emitter, emitter.getOutputtingSides()); - - for(ForgeDirection side : emitter.getOutputtingSides()) - { - if(connectable[side.ordinal()]) - { - outputtingSides.add(side); - } - } - - if(outputtingSides.size() > 0) - { - double sent = 0; - - boolean cont = false; - - do { - cont = false; - double prev = sent; - sent += emit_do(emitter, outputtingSides, sendingEnergy-sent); - - if(sendingEnergy-sent > 0 && sent-prev > 0) - { - cont = true; - } - } while(cont); - - emitter.setEnergy(emitter.getEnergy() - sent); - } + List outputtingSides = new ArrayList(); + boolean[] connectable = getConnections(emitter, emitter.getOutputtingSides()); + + for(ForgeDirection side : emitter.getOutputtingSides()) + { + if(connectable[side.ordinal()]) + { + outputtingSides.add(side); + } + } + + if(outputtingSides.size() > 0) + { + double sent = 0; + + boolean cont = false; + + do { + cont = false; + double prev = sent; + sent += emit_do(emitter, outputtingSides, sendingEnergy-sent); + + if(sendingEnergy-sent > 0 && sent-prev > 0) + { + cont = true; + } + } while(cont); + + emitter.setEnergy(emitter.getEnergy() - sent); + } } - } - } - - private static double emit_do(TileEntityElectricBlock emitter, List outputtingSides, double totalToSend) - { + } + } + + private static double emit_do(TileEntityElectricBlock emitter, List outputtingSides, double totalToSend) + { double remains = totalToSend%outputtingSides.size(); double splitSend = (totalToSend-remains)/outputtingSides.size(); double sent = 0; - + List toRemove = new ArrayList(); - - for(ForgeDirection side : outputtingSides) + + for(ForgeDirection side : outputtingSides) { TileEntity tileEntity = Coord4D.get(emitter).getFromSide(side).getTileEntity(emitter.worldObj); double toSend = splitSend+remains; remains = 0; - + double prev = sent; sent += emit_do_do(emitter, tileEntity, side, toSend); - + if(sent-prev == 0) { toRemove.add(side); } } - - for(ForgeDirection side : toRemove) - { - outputtingSides.remove(side); - } - - return sent; - } - - private static double emit_do_do(TileEntityElectricBlock from, TileEntity tileEntity, ForgeDirection side, double sendingEnergy) - { - double sent = 0; - + + for(ForgeDirection side : toRemove) + { + outputtingSides.remove(side); + } + + return sent; + } + + private static double emit_do_do(TileEntityElectricBlock from, TileEntity tileEntity, ForgeDirection side, double sendingEnergy) + { + double sent = 0; + if(tileEntity instanceof IStrictEnergyAcceptor) { IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor)tileEntity; - + if(acceptor.canReceiveEnergy(side.getOpposite())) { double prev = sent; @@ -309,7 +309,7 @@ public final class CableUtils else if(tileEntity instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)tileEntity; - + if(handler.canInterface(side.getOpposite())) { int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(sendingEnergy*Mekanism.TO_TE), false); @@ -328,15 +328,15 @@ public final class CableUtils else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft()) { PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite()); - + if(receiver != null) { - double transferEnergy = Math.min(sendingEnergy, receiver.powerRequest()*Mekanism.FROM_BC); - float used = receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), side.getOpposite()); - sent += used*Mekanism.FROM_BC; + double transferEnergy = Math.min(sendingEnergy, receiver.powerRequest()*Mekanism.FROM_BC); + float used = receiver.receiveEnergy(Type.STORAGE, (float)(transferEnergy*Mekanism.TO_BC), side.getOpposite()); + sent += used*Mekanism.FROM_BC; } } - + return sent; - } + } } diff --git a/common/mekanism/common/util/ChargeUtils.java b/common/mekanism/common/util/ChargeUtils.java index 4a653af35..9cb93628a 100644 --- a/common/mekanism/common/util/ChargeUtils.java +++ b/common/mekanism/common/util/ChargeUtils.java @@ -28,7 +28,7 @@ public final class ChargeUtils else if(Mekanism.hooks.IC2Loaded && storer.inventory[slotID].getItem() instanceof IElectricItem) { IElectricItem item = (IElectricItem)storer.inventory[slotID].getItem(); - + if(item.canProvideEnergy(storer.inventory[slotID])) { double gain = ElectricItem.manager.discharge(storer.inventory[slotID], (int)((storer.getMaxEnergy() - storer.getEnergy())*Mekanism.TO_IC2), 4, true, false)*Mekanism.FROM_IC2; @@ -39,25 +39,25 @@ public final class ChargeUtils { ItemStack itemStack = storer.inventory[slotID]; IEnergyContainerItem item = (IEnergyContainerItem)storer.inventory[slotID].getItem(); - + int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getEnergyStored(itemStack))); int toTransfer = (int)Math.round(Math.min(itemEnergy, ((storer.getMaxEnergy() - storer.getEnergy())*Mekanism.TO_TE))); - + storer.setEnergy(storer.getEnergy() + (item.extractEnergy(itemStack, toTransfer, false)*Mekanism.FROM_TE)); } else if(storer.inventory[slotID].itemID == Item.redstone.itemID && storer.getEnergy()+Mekanism.ENERGY_PER_REDSTONE <= storer.getMaxEnergy()) { storer.setEnergy(storer.getEnergy() + Mekanism.ENERGY_PER_REDSTONE); storer.inventory[slotID].stackSize--; - - if(storer.inventory[slotID].stackSize <= 0) - { - storer.inventory[slotID] = null; - } + + if(storer.inventory[slotID].stackSize <= 0) + { + storer.inventory[slotID] = null; + } } } } - + /** * Universally charges an item, and updates the TileEntity's energy level. * @param slotID - ID of the slot of which to discharge @@ -80,10 +80,10 @@ public final class ChargeUtils { ItemStack itemStack = storer.inventory[slotID]; IEnergyContainerItem item = (IEnergyContainerItem)storer.inventory[slotID].getItem(); - + int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getMaxEnergyStored(itemStack) - item.getEnergyStored(itemStack))); int toTransfer = (int)Math.round(Math.min(itemEnergy, (storer.getEnergy()*Mekanism.TO_TE))); - + storer.setEnergy(storer.getEnergy() - (item.receiveEnergy(itemStack, toTransfer, false)*Mekanism.FROM_TE)); } } @@ -96,8 +96,8 @@ public final class ChargeUtils */ public static boolean canBeDischarged(ItemStack itemstack) { - return (itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) || - (itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canSend(itemstack)) || + return (itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) || + (itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canSend(itemstack)) || (itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) || itemstack.itemID == Item.redstone.itemID; } @@ -109,7 +109,7 @@ public final class ChargeUtils */ public static boolean canBeCharged(ItemStack itemstack) { - return itemstack.getItem() instanceof IElectricItem || + return itemstack.getItem() instanceof IElectricItem || (itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canReceive(itemstack)) || (itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0); } @@ -125,7 +125,7 @@ public final class ChargeUtils { if(chargeSlot) { - return itemstack.getItem() instanceof IElectricItem; + return itemstack.getItem() instanceof IElectricItem; } else { return itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack); diff --git a/common/mekanism/common/util/InventoryUtils.java b/common/mekanism/common/util/InventoryUtils.java index a11f28358..7330f3e0d 100644 --- a/common/mekanism/common/util/InventoryUtils.java +++ b/common/mekanism/common/util/InventoryUtils.java @@ -14,17 +14,17 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraftforge.common.ForgeDirection; -public final class InventoryUtils +public final class InventoryUtils { public static final int[] EMPTY = new int[] {}; - + public static IInventory checkChestInv(IInventory inv) { if(inv instanceof TileEntityChest) { TileEntityChest main = (TileEntityChest)inv; TileEntityChest adj = null; - + if(main.adjacentChestXNeg != null) { adj = main.adjacentChestXNeg; @@ -41,137 +41,137 @@ public final class InventoryUtils { adj = main.adjacentChestZPosition; } - + if(adj != null) { return new InventoryLargeChest("", main, adj); } } - + return inv; } - public static ItemStack putStackInInventory(IInventory inventory, ItemStack itemStack, int side, boolean force) + public static ItemStack putStackInInventory(IInventory inventory, ItemStack itemStack, int side, boolean force) { inventory = checkChestInv(inventory); - + if(force && inventory instanceof TileEntityLogisticalSorter) { return ((TileEntityLogisticalSorter)inventory).sendHome(itemStack.copy()); } - + ItemStack toInsert = itemStack.copy(); - + if(!(inventory instanceof ISidedInventory)) { for(int i = 0; i <= inventory.getSizeInventory() - 1; i++) { if(!force) { - if(!inventory.isItemValidForSlot(i, toInsert)) + if(!inventory.isItemValidForSlot(i, toInsert)) { continue; } } - + ItemStack inSlot = inventory.getStackInSlot(i); - + if(inSlot == null) { inventory.setInventorySlotContents(i, toInsert); return null; - } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + } + else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) + if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { ItemStack toSet = toInsert.copy(); toSet.stackSize += inSlot.stackSize; - + inventory.setInventorySlotContents(i, toSet); return null; - } + } else { int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize(); - + ItemStack toSet = toInsert.copy(); toSet.stackSize = inSlot.getMaxStackSize(); - + ItemStack remains = toInsert.copy(); remains.stackSize = rejects; - + inventory.setInventorySlotContents(i, toSet); - + toInsert = remains; } } } - } + } else { ISidedInventory sidedInventory = (ISidedInventory)inventory; int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); - + if(slots != null && slots.length != 0) { if(force && sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0) { slots = sidedInventory.getAccessibleSlotsFromSide(1); } - - for(int get = 0; get <= slots.length - 1; get++) + + for(int get = 0; get <= slots.length - 1; get++) { int slotID = slots[get]; - + if(!force) { - if(!sidedInventory.isItemValidForSlot(slotID, toInsert) && !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) + if(!sidedInventory.isItemValidForSlot(slotID, toInsert) && !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) { continue; } } - + ItemStack inSlot = inventory.getStackInSlot(slotID); - - if(inSlot == null) + + if(inSlot == null) { inventory.setInventorySlotContents(slotID, toInsert); return null; - } + } else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) + if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { ItemStack toSet = toInsert.copy(); toSet.stackSize += inSlot.stackSize; - + inventory.setInventorySlotContents(slotID, toSet); return null; - } + } else { int rejects = (inSlot.stackSize + toInsert.stackSize) - inSlot.getMaxStackSize(); - + ItemStack toSet = toInsert.copy(); toSet.stackSize = inSlot.getMaxStackSize(); - + ItemStack remains = toInsert.copy(); remains.stackSize = rejects; - + inventory.setInventorySlotContents(slotID, toSet); - + toInsert = remains; } } } } } - + return toInsert; } - + public static InvStack takeTopItem(IInventory inventory, int side) { inventory = checkChestInv(inventory); - + if(!(inventory instanceof ISidedInventory)) { for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) @@ -215,18 +215,18 @@ public final class InventoryUtils public static InvStack takeDefinedItem(IInventory inventory, int side, ItemStack type, int min, int max) { inventory = checkChestInv(inventory); - + InvStack ret = new InvStack(inventory); - - if(!(inventory instanceof ISidedInventory)) - { - for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) + + if(!(inventory instanceof ISidedInventory)) + { + for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) { - if(inventory.getStackInSlot(i) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(i), type)) + if(inventory.getStackInSlot(i) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(i), type)) { ItemStack stack = inventory.getStackInSlot(i); int current = ret.getStack() != null ? ret.getStack().stackSize : 0; - + if(current+stack.stackSize <= max) { ret.appendStack(i, stack.copy()); @@ -236,48 +236,48 @@ public final class InventoryUtils copy.stackSize = max-current; ret.appendStack(i, copy); } - + if(ret.getStack() != null && ret.getStack().stackSize == max) { return ret; } } } - } + } else { ISidedInventory sidedInventory = (ISidedInventory)inventory; int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); - - if(slots != null && slots.length != 0) + + if(slots != null && slots.length != 0) { - for(int get = slots.length - 1; get >= 0; get--) + for(int get = slots.length - 1; get >= 0; get--) { int slotID = slots[get]; - - if(sidedInventory.getStackInSlot(slotID) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(slotID), type)) + + if(sidedInventory.getStackInSlot(slotID) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(slotID), type)) { ItemStack stack = sidedInventory.getStackInSlot(slotID); int current = ret.getStack() != null ? ret.getStack().stackSize : 0; - + if(current+stack.stackSize <= max) { ItemStack copy = stack.copy(); - - if(sidedInventory.canExtractItem(slotID, copy, ForgeDirection.getOrientation(side).getOpposite().ordinal())) + + if(sidedInventory.canExtractItem(slotID, copy, ForgeDirection.getOrientation(side).getOpposite().ordinal())) { ret.appendStack(slotID, copy); } } else { ItemStack copy = stack.copy(); - - if(sidedInventory.canExtractItem(slotID, copy, ForgeDirection.getOrientation(side).getOpposite().ordinal())) + + if(sidedInventory.canExtractItem(slotID, copy, ForgeDirection.getOrientation(side).getOpposite().ordinal())) { copy.stackSize = max-current; ret.appendStack(slotID, copy); } } - + if(ret.getStack() != null && ret.getStack().stackSize == max) { return ret; @@ -286,45 +286,45 @@ public final class InventoryUtils } } } - + if(ret != null && ret.getStack() != null && ret.getStack().stackSize >= min) { return ret; } - + return null; } - public static InvStack takeTopStack(IInventory inventory, int side, Finder id) + public static InvStack takeTopStack(IInventory inventory, int side, Finder id) { inventory = checkChestInv(inventory); - - if(!(inventory instanceof ISidedInventory)) - { - for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) + + if(!(inventory instanceof ISidedInventory)) + { + for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) { - if(inventory.getStackInSlot(i) != null && id.modifies(inventory.getStackInSlot(i))) + if(inventory.getStackInSlot(i) != null && id.modifies(inventory.getStackInSlot(i))) { ItemStack toSend = inventory.getStackInSlot(i).copy(); return new InvStack(inventory, i, toSend); } } - } + } else { ISidedInventory sidedInventory = (ISidedInventory)inventory; int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); - - if(slots != null && slots.length != 0) + + if(slots != null && slots.length != 0) { - for(int get = slots.length - 1; get >= 0; get--) + for(int get = slots.length - 1; get >= 0; get--) { int slotID = slots[get]; - - if(sidedInventory.getStackInSlot(slotID) != null && id.modifies(sidedInventory.getStackInSlot(slotID))) + + if(sidedInventory.getStackInSlot(slotID) != null && id.modifies(sidedInventory.getStackInSlot(slotID))) { ItemStack toSend = sidedInventory.getStackInSlot(slotID); - - if(sidedInventory.canExtractItem(slotID, toSend, ForgeDirection.getOrientation(side).getOpposite().ordinal())) + + if(sidedInventory.canExtractItem(slotID, toSend, ForgeDirection.getOrientation(side).getOpposite().ordinal())) { return new InvStack(inventory, slotID, toSend); } @@ -332,60 +332,60 @@ public final class InventoryUtils } } } - + return null; } - public static boolean canInsert(TileEntity tileEntity, EnumColor color, ItemStack itemStack, int side, boolean force) - { - if(!(tileEntity instanceof IInventory)) - { - return false; - } - - if(force && tileEntity instanceof TileEntityLogisticalSorter) - { - return ((TileEntityLogisticalSorter)tileEntity).canSendHome(itemStack); - } - - if(!force && tileEntity instanceof IInvConfiguration) - { - IInvConfiguration config = (IInvConfiguration)tileEntity; - int tileSide = config.getOrientation(); - EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); - - if(config.getEjector().hasStrictInput() && configColor != null && configColor != color) - { - return false; - } - } - - IInventory inventory = checkChestInv((IInventory)tileEntity); - - if(!(inventory instanceof ISidedInventory)) - { + public static boolean canInsert(TileEntity tileEntity, EnumColor color, ItemStack itemStack, int side, boolean force) + { + if(!(tileEntity instanceof IInventory)) + { + return false; + } + + if(force && tileEntity instanceof TileEntityLogisticalSorter) + { + return ((TileEntityLogisticalSorter)tileEntity).canSendHome(itemStack); + } + + if(!force && tileEntity instanceof IInvConfiguration) + { + IInvConfiguration config = (IInvConfiguration)tileEntity; + int tileSide = config.getOrientation(); + EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); + + if(config.getEjector().hasStrictInput() && configColor != null && configColor != color) + { + return false; + } + } + + IInventory inventory = checkChestInv((IInventory)tileEntity); + + if(!(inventory instanceof ISidedInventory)) + { for(int i = 0; i <= inventory.getSizeInventory() - 1; i++) { if(!force) { - if(!inventory.isItemValidForSlot(i, itemStack)) + if(!inventory.isItemValidForSlot(i, itemStack)) { continue; } } - + ItemStack inSlot = inventory.getStackInSlot(i); if(inSlot == null) { return true; - } - else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) + } + else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) + if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) { return true; - } + } else { int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize(); @@ -396,7 +396,7 @@ public final class InventoryUtils } } } - } + } else { ISidedInventory sidedInventory = (ISidedInventory)inventory; int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); @@ -407,34 +407,34 @@ public final class InventoryUtils { slots = sidedInventory.getAccessibleSlotsFromSide(1); } - - for(int get = 0; get <= slots.length - 1; get++) + + for(int get = 0; get <= slots.length - 1; get++) { int slotID = slots[get]; - + if(!force) { - if(!sidedInventory.isItemValidForSlot(slotID, itemStack) || !sidedInventory.canInsertItem(slotID, itemStack, ForgeDirection.getOrientation(side).getOpposite().ordinal())) + if(!sidedInventory.isItemValidForSlot(slotID, itemStack) || !sidedInventory.canInsertItem(slotID, itemStack, ForgeDirection.getOrientation(side).getOpposite().ordinal())) { continue; } } - + ItemStack inSlot = inventory.getStackInSlot(slotID); - if(inSlot == null) + if(inSlot == null) { return true; - } + } else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) + if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) { return true; - } + } else { int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize(); - + if(rejects < itemStack.stackSize) { return true; @@ -444,7 +444,7 @@ public final class InventoryUtils } } } - - return false; - } + + return false; + } } diff --git a/common/mekanism/common/util/MekanismUtils.java b/common/mekanism/common/util/MekanismUtils.java index f4fd97351..cbe6e0e8b 100644 --- a/common/mekanism/common/util/MekanismUtils.java +++ b/common/mekanism/common/util/MekanismUtils.java @@ -79,7 +79,7 @@ import cpw.mods.fml.server.FMLServerHandler; public final class MekanismUtils { public static final ForgeDirection[] SIDE_DIRS = new ForgeDirection[] {ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST}; - + /** * Checks for a new version of Mekanism. */ @@ -91,7 +91,7 @@ public final class MekanismUtils if(!Mekanism.latestVersionNumber.equals("null")) { ArrayList list = new ArrayList(); - + for(IModule module : Mekanism.modulesLoaded) { if(Version.get(Mekanism.latestVersionNumber).comparedState(module.getVersion()) == 1) @@ -99,22 +99,22 @@ public final class MekanismUtils list.add(module); } } - + if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1 || !list.isEmpty()) { entityplayer.addChatMessage(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------"); entityplayer.addChatMessage(EnumColor.GREY + " Using outdated version on one or more modules."); - + if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1) { entityplayer.addChatMessage(EnumColor.INDIGO + " Mekanism: " + EnumColor.DARK_RED + Mekanism.versionNumber); } - + for(IModule module : list) { entityplayer.addChatMessage(EnumColor.INDIGO + " Mekanism" + module.getName() + ": " + EnumColor.DARK_RED + module.getVersion()); } - + entityplayer.addChatMessage(EnumColor.GREY + " Consider updating to version " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber); entityplayer.addChatMessage(EnumColor.GREY + " New features: " + EnumColor.INDIGO + Mekanism.recentNews); entityplayer.addChatMessage(EnumColor.GREY + " Visit " + EnumColor.DARK_GREY + "aidancbrady.com/mekanism" + EnumColor.GREY + " to download."); @@ -132,10 +132,10 @@ public final class MekanismUtils } } } catch(Exception e) {} - + return false; } - + /** * Gets the latest version using getHTML and returns it as a string. * @return latest version @@ -146,7 +146,7 @@ public final class MekanismUtils if(!text[0].contains("UTF-8") && !text[0].contains("HTML") && !text[0].contains("http")) return text[0]; return "null"; } - + /** * Gets the recent news using getHTML and returns it as a string. * @return recent news @@ -157,64 +157,64 @@ public final class MekanismUtils if(text.length > 1 && !text[1].contains("UTF-8") && !text[1].contains("HTML") && !text[1].contains("http")) return text[1]; return "null"; } - + public static void updateDonators() { Mekanism.donators.clear(); List text = getHTML("http://dl.dropbox.com/u/90411166/Donators/Mekanism.txt"); - + for(String s : text) { Mekanism.donators.add(s); } } - + /** * Returns one line of HTML from the url. * @param urlToRead - URL to read from. * @return HTML text from the url. */ - public static List getHTML(String urlToRead) + public static List getHTML(String urlToRead) { URL url; HttpURLConnection conn; BufferedReader rd; String line; List result = new ArrayList(); - + try { url = new URL(urlToRead); conn = (HttpURLConnection)url.openConnection(); conn.setRequestMethod("GET"); rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); - - while((line = rd.readLine()) != null) + + while((line = rd.readLine()) != null) { result.add(line.trim()); } - + rd.close(); } catch(Exception e) { result.clear(); result.add("null"); System.err.println("[Mekanism] An error occured while connecting to URL '" + urlToRead + ".'"); } - + return result; } - + public static String merge(List text) { StringBuilder builder = new StringBuilder(); - + for(String s : text) { builder.append(s); } - + return builder.toString(); } - + /** * Sends a Packet3Chat packet to the defined player, with the defined message. * @param player - Player to send packet to. @@ -224,13 +224,13 @@ public final class MekanismUtils { EntityPlayer player = FMLServerHandler.instance().getServer().getConfigurationManager().getPlayerForUsername(playerUsername); Packet3Chat chatPacket = new Packet3Chat(msg); - + if(player != null) { ((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(chatPacket); } } - + /** * Returns the closest teleporter between a selection of one or two. */ @@ -242,13 +242,13 @@ public final class MekanismUtils } else { int dimensionId = player.worldObj.provider.dimensionId; - + Coord4D coords0 = Mekanism.teleporters.get(teleCode).get(0); Coord4D coords1 = Mekanism.teleporters.get(teleCode).get(1); - + int distance0 = (int)player.getDistance(coords0.xCoord, coords0.yCoord, coords0.zCoord); int distance1 = (int)player.getDistance(coords1.xCoord, coords1.yCoord, coords1.zCoord); - + if(dimensionId == coords0.dimensionId && dimensionId != coords1.dimensionId) { return coords0; @@ -280,10 +280,10 @@ public final class MekanismUtils } } } - + return null; } - + /** * Sends the defined message to all players. * @param msg - message to send @@ -292,7 +292,7 @@ public final class MekanismUtils { PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(msg)); } - + /** * Checks if the mod doesn't need an update. * @return if mod doesn't need an update @@ -303,12 +303,12 @@ public final class MekanismUtils { return true; } - + if(Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) == -1) { return false; } - + for(IModule module : Mekanism.modulesLoaded) { if(module.getVersion().comparedState(Version.get(Mekanism.latestVersionNumber)) == -1) @@ -316,10 +316,10 @@ public final class MekanismUtils return false; } } - + return true; } - + /** * Checks if Minecraft is running in offline mode. * @return if mod is running in offline mode. @@ -334,7 +334,7 @@ public final class MekanismUtils return false; } } - + /** * Creates a fake explosion at the declared player, with only sounds and effects. No damage is caused to either blocks or the player. * @param entityplayer - player to explode @@ -345,7 +345,7 @@ public final class MekanismUtils world.spawnParticle("hugeexplosion", entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D); world.playSoundAtEntity(entityplayer, "random.explode", 1.0F, 1.0F); } - + /** * Creates a fake explosion at the declared coords, with only sounds and effects. No damage is caused to either blocks or the player. * @param world - world where the explosion will occur @@ -358,7 +358,7 @@ public final class MekanismUtils world.spawnParticle("hugeexplosion", x, y, z, 0.0D, 0.0D, 0.0D); world.playSound(x, y, z, "random.explode", 1.0F, 1.0F, true); } - + /** * Copies an ItemStack and returns it with a defined stackSize. * @param itemstack - stack to change size @@ -371,7 +371,7 @@ public final class MekanismUtils newStack.stackSize = size; return newStack; } - + /** * Adds a recipe directly to the CraftingManager that works with the Forge Ore Dictionary. * @param output the ItemStack produced by this recipe @@ -381,7 +381,7 @@ public final class MekanismUtils { CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, params)); } - + /** * Retrieves an empty Energy Cube with a defined tier. * @param tier - tier to add to the Energy Cube @@ -392,7 +392,7 @@ public final class MekanismUtils ItemStack itemstack = ((ItemBlockEnergyCube)new ItemStack(Mekanism.EnergyCube).getItem()).getUnchargedItem(tier); return itemstack; } - + /** * Retrieves an empty Gas Tank. * @return empty gas tank @@ -402,7 +402,7 @@ public final class MekanismUtils ItemStack itemstack = ((ItemBlockGasTank)new ItemStack(Mekanism.GasTank).getItem()).getEmptyItem(); return itemstack; } - + /** * Retrieves a Factory with a defined tier and recipe type. * @param tier - tier to add to the Factory @@ -415,7 +415,7 @@ public final class MekanismUtils ((IFactory)itemstack.getItem()).setRecipeType(type.ordinal(), itemstack); return itemstack; } - + /** * Checks if a machine is in it's active state. * @param world @@ -424,50 +424,50 @@ public final class MekanismUtils * @param z * @return if machine is active */ - public static boolean isActive(IBlockAccess world, int x, int y, int z) - { - TileEntity tileEntity = (TileEntity)world.getBlockTileEntity(x, y, z); - - if(tileEntity != null) - { - if(tileEntity instanceof IActiveState) - { - return ((IActiveState)tileEntity).getActive(); - } - } - - return false; - } - - /** - * Gets the left side of a certain orientation. - * @param orientation - * @return left side - */ - public static ForgeDirection getLeft(int orientation) - { - switch(orientation) - { - case 2: - return ForgeDirection.EAST; - case 3: - return ForgeDirection.WEST; - case 4: - return ForgeDirection.NORTH; - default: - return ForgeDirection.SOUTH; - } - } - - /** - * Gets the right side of a certain orientation. - * @param orientation - * @return right side - */ - public static ForgeDirection getRight(int orientation) - { - return getLeft(orientation).getOpposite(); - } + public static boolean isActive(IBlockAccess world, int x, int y, int z) + { + TileEntity tileEntity = (TileEntity)world.getBlockTileEntity(x, y, z); + + if(tileEntity != null) + { + if(tileEntity instanceof IActiveState) + { + return ((IActiveState)tileEntity).getActive(); + } + } + + return false; + } + + /** + * Gets the left side of a certain orientation. + * @param orientation + * @return left side + */ + public static ForgeDirection getLeft(int orientation) + { + switch(orientation) + { + case 2: + return ForgeDirection.EAST; + case 3: + return ForgeDirection.WEST; + case 4: + return ForgeDirection.NORTH; + default: + return ForgeDirection.SOUTH; + } + } + + /** + * Gets the right side of a certain orientation. + * @param orientation + * @return right side + */ + public static ForgeDirection getRight(int orientation) + { + return getLeft(orientation).getOpposite(); + } /** * Gets the opposite side of a certain orientation. @@ -478,379 +478,379 @@ public final class MekanismUtils { return ForgeDirection.getOrientation(orientation).getOpposite(); } - - /** - * Checks to see if a specified ItemStack is stored in the Ore Dictionary with the specified name. - * @param check - ItemStack to check - * @param oreDict - name to check with - * @return if the ItemStack has the Ore Dictionary key - */ - public static boolean oreDictCheck(ItemStack check, String oreDict) - { - boolean hasResource = false; - - for(ItemStack ore : OreDictionary.getOres(oreDict)) - { - if(ore.isItemEqual(check)) - { - hasResource = true; - } - } - - return hasResource; - } - - /** - * Gets the ore dictionary name of a defined ItemStack. - * @param check - ItemStack to check OreDict name of - * @return OreDict name - */ - public static List getOreDictName(ItemStack check) - { - return OreDictCache.getOreDictName(check); - } - - /** - * Returns an integer facing that converts a world-based orientation to a machine-based oriention. - * @param side - world based - * @param blockFacing - what orientation the block is facing - * @return machine orientation - */ - public static int getBaseOrientation(int side, int blockFacing) - { - if(blockFacing == 3 || side == 1 || side == 0) - { - if(side == 2 || side == 3) - { - return ForgeDirection.getOrientation(side).getOpposite().ordinal(); - } - - return side; - } - else if(blockFacing == 2) - { - if(side == 2 || side == 3) - { - return side; - } - - return ForgeDirection.getOrientation(side).getOpposite().ordinal(); - } - else if(blockFacing == 4) - { - if(side == 2 || side == 3) - { - return getRight(side).ordinal(); - } - - return getLeft(side).ordinal(); - } - else if(blockFacing == 5) - { - if(side == 2 || side == 3) - { - return getLeft(side).ordinal(); - } - - return getRight(side).ordinal(); - } - - return side; - } - - /** - * Localizes the defined string. - * @param s - string to localized - * @return localized string - */ - public static String localize(String s) - { - return StatCollector.translateToLocal(s); - } - - /** - * Increments the output type of a machine's side. - * @param config - configurable machine - * @param side - side to increment output of - */ - public static void incrementOutput(IInvConfiguration config, int side) - { - int max = config.getSideData().size()-1; - int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side])); - - if(current < max) - { - config.getConfiguration()[side] = (byte)(current+1); - } - else if(current == max) - { - config.getConfiguration()[side] = 0; - } - - TileEntity tile = (TileEntity)config; - Coord4D coord = Coord4D.get(tile).getFromSide(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, config.getOrientation()))); - - tile.worldObj.notifyBlockOfNeighborChange(coord.xCoord, coord.yCoord, coord.zCoord, tile.getBlockType().blockID); - } - - /** - * Decrements the output type of a machine's side. - * @param config - configurable machine - * @param side - side to increment output of - */ - public static void decrementOutput(IInvConfiguration config, int side) - { - int max = config.getSideData().size()-1; - int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side])); - - if(current > 0) - { - config.getConfiguration()[side] = (byte)(current-1); - } - else if(current == 0) - { - config.getConfiguration()[side] = (byte)max; - } - - TileEntity tile = (TileEntity)config; - Coord4D coord = Coord4D.get(tile).getFromSide(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, config.getOrientation()))); - - tile.worldObj.notifyBlockOfNeighborChange(coord.xCoord, coord.yCoord, coord.zCoord, tile.getBlockType().blockID); - } - - /** - * Gets the operating ticks required for a machine via it's upgrades. - * @param speedUpgrade - number of speed upgrades - * @param def - the original, default ticks required - * @return max operating ticks - */ - public static int getTicks(int speedUpgrade, int def) - { - return (int)(def * Math.pow(Mekanism.maxUpgradeMultiplier, -speedUpgrade/8.0)); - } - - /** - * Gets the energy required per tick for a machine via it's upgrades. - * @param speedUpgrade - number of speed upgrades - * @param energyUpgrade - number of energy upgrades - * @param def - the original, default energy required - * @return max energy per tick - */ - public static double getEnergyPerTick(int speedUpgrade, int energyUpgrade, double def) - { - return def * Math.pow(Mekanism.maxUpgradeMultiplier, (2*speedUpgrade-energyUpgrade)/8.0); - } - - /** - * Gets the maximum energy for a machine via it's upgrades. - * @param energyUpgrade - number of energy upgrades - * @param def - original, default max energy - * @return max energy - */ - public static double getMaxEnergy(int energyUpgrade, double def) - { - return def * Math.pow(Mekanism.maxUpgradeMultiplier, energyUpgrade/8.0); - } - - /** - * Places a fake bounding block at the defined location. - * @param world - world to place block in - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @param orig - original block - */ - public static void makeBoundingBlock(World world, int x, int y, int z, Coord4D orig) - { + + /** + * Checks to see if a specified ItemStack is stored in the Ore Dictionary with the specified name. + * @param check - ItemStack to check + * @param oreDict - name to check with + * @return if the ItemStack has the Ore Dictionary key + */ + public static boolean oreDictCheck(ItemStack check, String oreDict) + { + boolean hasResource = false; + + for(ItemStack ore : OreDictionary.getOres(oreDict)) + { + if(ore.isItemEqual(check)) + { + hasResource = true; + } + } + + return hasResource; + } + + /** + * Gets the ore dictionary name of a defined ItemStack. + * @param check - ItemStack to check OreDict name of + * @return OreDict name + */ + public static List getOreDictName(ItemStack check) + { + return OreDictCache.getOreDictName(check); + } + + /** + * Returns an integer facing that converts a world-based orientation to a machine-based oriention. + * @param side - world based + * @param blockFacing - what orientation the block is facing + * @return machine orientation + */ + public static int getBaseOrientation(int side, int blockFacing) + { + if(blockFacing == 3 || side == 1 || side == 0) + { + if(side == 2 || side == 3) + { + return ForgeDirection.getOrientation(side).getOpposite().ordinal(); + } + + return side; + } + else if(blockFacing == 2) + { + if(side == 2 || side == 3) + { + return side; + } + + return ForgeDirection.getOrientation(side).getOpposite().ordinal(); + } + else if(blockFacing == 4) + { + if(side == 2 || side == 3) + { + return getRight(side).ordinal(); + } + + return getLeft(side).ordinal(); + } + else if(blockFacing == 5) + { + if(side == 2 || side == 3) + { + return getLeft(side).ordinal(); + } + + return getRight(side).ordinal(); + } + + return side; + } + + /** + * Localizes the defined string. + * @param s - string to localized + * @return localized string + */ + public static String localize(String s) + { + return StatCollector.translateToLocal(s); + } + + /** + * Increments the output type of a machine's side. + * @param config - configurable machine + * @param side - side to increment output of + */ + public static void incrementOutput(IInvConfiguration config, int side) + { + int max = config.getSideData().size()-1; + int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side])); + + if(current < max) + { + config.getConfiguration()[side] = (byte)(current+1); + } + else if(current == max) + { + config.getConfiguration()[side] = 0; + } + + TileEntity tile = (TileEntity)config; + Coord4D coord = Coord4D.get(tile).getFromSide(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, config.getOrientation()))); + + tile.worldObj.notifyBlockOfNeighborChange(coord.xCoord, coord.yCoord, coord.zCoord, tile.getBlockType().blockID); + } + + /** + * Decrements the output type of a machine's side. + * @param config - configurable machine + * @param side - side to increment output of + */ + public static void decrementOutput(IInvConfiguration config, int side) + { + int max = config.getSideData().size()-1; + int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side])); + + if(current > 0) + { + config.getConfiguration()[side] = (byte)(current-1); + } + else if(current == 0) + { + config.getConfiguration()[side] = (byte)max; + } + + TileEntity tile = (TileEntity)config; + Coord4D coord = Coord4D.get(tile).getFromSide(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, config.getOrientation()))); + + tile.worldObj.notifyBlockOfNeighborChange(coord.xCoord, coord.yCoord, coord.zCoord, tile.getBlockType().blockID); + } + + /** + * Gets the operating ticks required for a machine via it's upgrades. + * @param speedUpgrade - number of speed upgrades + * @param def - the original, default ticks required + * @return max operating ticks + */ + public static int getTicks(int speedUpgrade, int def) + { + return (int)(def * Math.pow(Mekanism.maxUpgradeMultiplier, -speedUpgrade/8.0)); + } + + /** + * Gets the energy required per tick for a machine via it's upgrades. + * @param speedUpgrade - number of speed upgrades + * @param energyUpgrade - number of energy upgrades + * @param def - the original, default energy required + * @return max energy per tick + */ + public static double getEnergyPerTick(int speedUpgrade, int energyUpgrade, double def) + { + return def * Math.pow(Mekanism.maxUpgradeMultiplier, (2*speedUpgrade-energyUpgrade)/8.0); + } + + /** + * Gets the maximum energy for a machine via it's upgrades. + * @param energyUpgrade - number of energy upgrades + * @param def - original, default max energy + * @return max energy + */ + public static double getMaxEnergy(int energyUpgrade, double def) + { + return def * Math.pow(Mekanism.maxUpgradeMultiplier, energyUpgrade/8.0); + } + + /** + * Places a fake bounding block at the defined location. + * @param world - world to place block in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @param orig - original block + */ + public static void makeBoundingBlock(World world, int x, int y, int z, Coord4D orig) + { world.setBlock(x, y, z, Mekanism.BoundingBlock.blockID); - + if(!world.isRemote) { ((TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z)).setMainLocation(orig.xCoord, orig.yCoord, orig.zCoord); } - } - - /** - * Places a fake advanced bounding block at the defined location. - * @param world - world to place block in - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @param orig - original block - */ - public static void makeAdvancedBoundingBlock(World world, int x, int y, int z, Coord4D orig) - { + } + + /** + * Places a fake advanced bounding block at the defined location. + * @param world - world to place block in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @param orig - original block + */ + public static void makeAdvancedBoundingBlock(World world, int x, int y, int z, Coord4D orig) + { world.setBlock(x, y, z, Mekanism.BoundingBlock.blockID, 1, 0); - + if(!world.isRemote) { ((TileEntityAdvancedBoundingBlock)world.getBlockTileEntity(x, y, z)).setMainLocation(orig.xCoord, orig.yCoord, orig.zCoord); } - } - - /** - * Updates a block's light value and marks it for a render update. - * @param world - world the block is in - * @param x - x coord - * @param y - y coord - * @param z - z coord - */ - public static void updateBlock(World world, int x, int y, int z) - { - if(!(world.getBlockTileEntity(x, y, z) instanceof IActiveState) || ((IActiveState)world.getBlockTileEntity(x, y, z)).renderUpdate()) - { - world.markBlockForRenderUpdate(x, y, z); - } - - if(!(world.getBlockTileEntity(x, y, z) instanceof IActiveState) || ((IActiveState)world.getBlockTileEntity(x, y, z)).lightUpdate() && Mekanism.machineEffects) - { - world.updateAllLightTypes(x, y, z); - } - } - - /** - * Whether or not a certain block is considered a fluid. - * @param world - world the block is in - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @return if the block is a fluid - */ - public static boolean isFluid(World world, int x, int y, int z) - { - return getFluid(world, x, y, z) != null; - } - - /** - * Gets a fluid from a certain location. - * @param world - world the block is in - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @return the fluid at the certain location, null if it doesn't exist - */ - public static FluidStack getFluid(World world, int x, int y, int z) - { - int id = world.getBlockId(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if(id == 0) - { - return null; - } - - if((id == Block.waterStill.blockID || id == Block.waterMoving.blockID) && meta == 0) - { - return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME); - } - else if((id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID) && meta == 0) - { - return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME); - } - else if(Block.blocksList[id] instanceof IFluidBlock) - { - IFluidBlock fluid = (IFluidBlock)Block.blocksList[id]; - - if(meta == 0) - { - return fluid.drain(world, x, y, z, false); - } - } - - return null; - } - - /** - * Gets the fluid ID at a certain location, 0 if there isn't one - * @param world - world the block is in - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @return fluid ID - */ - public static int getFluidId(World world, int x, int y, int z) - { - int id = world.getBlockId(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if(id == 0) - { - return 0; - } - - if(id == Block.waterMoving.blockID) - { - return FluidRegistry.WATER.getID(); - } - else if(id == Block.lavaMoving.blockID) - { - return FluidRegistry.LAVA.getID(); - } - - for(Fluid fluid : FluidRegistry.getRegisteredFluids().values()) - { - if(fluid.getBlockID() == id) - { - return fluid.getID(); - } - } - - return 0; - } - - /** - * Whether or not a block is a dead fluid. - * @param world - world the block is in - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @return if the block is a dead fluid - */ - public static boolean isDeadFluid(World world, int x, int y, int z) - { - int id = world.getBlockId(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - - if(id == 0) - { - return false; - } - - if((id == Block.waterStill.blockID || id == Block.waterMoving.blockID) && meta != 0) - { - return true; - } - else if((id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID) && meta != 0) - { - return true; - } - else if(Block.blocksList[id] instanceof IFluidBlock) - { - IFluidBlock fluid = (IFluidBlock)Block.blocksList[id]; - - if(meta != 0) - { - return true; - } - } - - return false; - } - - /** - * FML doesn't really do GUIs the way it's supposed to -- opens Electric Chest GUI on client and server. - * Call this method server-side only! - * @param player - player to open GUI - * @param tileEntity - TileEntity of the chest, if it's not an item - * @param inventory - IInventory of the item, if it's not a block + } + + /** + * Updates a block's light value and marks it for a render update. + * @param world - world the block is in + * @param x - x coord + * @param y - y coord + * @param z - z coord + */ + public static void updateBlock(World world, int x, int y, int z) + { + if(!(world.getBlockTileEntity(x, y, z) instanceof IActiveState) || ((IActiveState)world.getBlockTileEntity(x, y, z)).renderUpdate()) + { + world.markBlockForRenderUpdate(x, y, z); + } + + if(!(world.getBlockTileEntity(x, y, z) instanceof IActiveState) || ((IActiveState)world.getBlockTileEntity(x, y, z)).lightUpdate() && Mekanism.machineEffects) + { + world.updateAllLightTypes(x, y, z); + } + } + + /** + * Whether or not a certain block is considered a fluid. + * @param world - world the block is in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @return if the block is a fluid + */ + public static boolean isFluid(World world, int x, int y, int z) + { + return getFluid(world, x, y, z) != null; + } + + /** + * Gets a fluid from a certain location. + * @param world - world the block is in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @return the fluid at the certain location, null if it doesn't exist + */ + public static FluidStack getFluid(World world, int x, int y, int z) + { + int id = world.getBlockId(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if(id == 0) + { + return null; + } + + if((id == Block.waterStill.blockID || id == Block.waterMoving.blockID) && meta == 0) + { + return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME); + } + else if((id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID) && meta == 0) + { + return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME); + } + else if(Block.blocksList[id] instanceof IFluidBlock) + { + IFluidBlock fluid = (IFluidBlock)Block.blocksList[id]; + + if(meta == 0) + { + return fluid.drain(world, x, y, z, false); + } + } + + return null; + } + + /** + * Gets the fluid ID at a certain location, 0 if there isn't one + * @param world - world the block is in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @return fluid ID + */ + public static int getFluidId(World world, int x, int y, int z) + { + int id = world.getBlockId(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if(id == 0) + { + return 0; + } + + if(id == Block.waterMoving.blockID) + { + return FluidRegistry.WATER.getID(); + } + else if(id == Block.lavaMoving.blockID) + { + return FluidRegistry.LAVA.getID(); + } + + for(Fluid fluid : FluidRegistry.getRegisteredFluids().values()) + { + if(fluid.getBlockID() == id) + { + return fluid.getID(); + } + } + + return 0; + } + + /** + * Whether or not a block is a dead fluid. + * @param world - world the block is in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @return if the block is a dead fluid + */ + public static boolean isDeadFluid(World world, int x, int y, int z) + { + int id = world.getBlockId(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if(id == 0) + { + return false; + } + + if((id == Block.waterStill.blockID || id == Block.waterMoving.blockID) && meta != 0) + { + return true; + } + else if((id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID) && meta != 0) + { + return true; + } + else if(Block.blocksList[id] instanceof IFluidBlock) + { + IFluidBlock fluid = (IFluidBlock)Block.blocksList[id]; + + if(meta != 0) + { + return true; + } + } + + return false; + } + + /** + * FML doesn't really do GUIs the way it's supposed to -- opens Electric Chest GUI on client and server. + * Call this method server-side only! + * @param player - player to open GUI + * @param tileEntity - TileEntity of the chest, if it's not an item + * @param inventory - IInventory of the item, if it's not a block * @param isBlock - whether or not this electric chest is in it's block form - */ - public static void openElectricChestGui(EntityPlayerMP player, TileEntityElectricChest tileEntity, IInventory inventory, boolean isBlock) - { + */ + public static void openElectricChestGui(EntityPlayerMP player, TileEntityElectricChest tileEntity, IInventory inventory, boolean isBlock) + { player.incrementWindowID(); player.closeContainer(); int id = player.currentWindowId; - + if(isBlock) { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 0, id, true, Coord4D.get(tileEntity)), player); @@ -858,173 +858,173 @@ public final class MekanismUtils else { PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketElectricChest().setParams(ElectricChestPacketType.CLIENT_OPEN, 0, id, false), player); } - + player.openContainer = new ContainerElectricChest(player.inventory, tileEntity, inventory, isBlock); player.openContainer.windowId = id; player.openContainer.addCraftingToCrafters(player); - } - - /** - * Grabs an inventory from the world's caches, and removes all the world's references to it. - * @param world - world the cache is stored in - * @param id - inventory ID to pull - * @return correct Dynamic Tank inventory cache - */ - public static DynamicTankCache pullInventory(World world, int id) - { - DynamicTankCache toReturn = Mekanism.dynamicInventories.get(id); - - for(Coord4D obj : Mekanism.dynamicInventories.get(id).locations) - { - TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(world); - - if(tileEntity != null) - { - tileEntity.cachedFluid = null; - tileEntity.inventory = new ItemStack[2]; - tileEntity.inventoryID = -1; - } - } - - Mekanism.dynamicInventories.remove(id); - - return toReturn; - } - - /** - * Updates a dynamic tank cache with the defined inventory ID with the parameterized values. - * @param inventoryID - inventory ID of the dynamic tank - * @param fluid - cached fluid of the dynamic tank - * @param inventory - inventory of the dynamic tank - * @param tileEntity - dynamic tank TileEntity - */ - public static void updateCache(int inventoryID, FluidStack fluid, ItemStack[] inventory, TileEntityDynamicTank tileEntity) - { - if(!Mekanism.dynamicInventories.containsKey(inventoryID)) - { - DynamicTankCache cache = new DynamicTankCache(); - cache.inventory = inventory; - cache.fluid = fluid; - cache.locations.add(Coord4D.get(tileEntity)); - - Mekanism.dynamicInventories.put(inventoryID, cache); - - return; - } - - Mekanism.dynamicInventories.get(inventoryID).inventory = inventory; - Mekanism.dynamicInventories.get(inventoryID).fluid = fluid; - + } + + /** + * Grabs an inventory from the world's caches, and removes all the world's references to it. + * @param world - world the cache is stored in + * @param id - inventory ID to pull + * @return correct Dynamic Tank inventory cache + */ + public static DynamicTankCache pullInventory(World world, int id) + { + DynamicTankCache toReturn = Mekanism.dynamicInventories.get(id); + + for(Coord4D obj : Mekanism.dynamicInventories.get(id).locations) + { + TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(world); + + if(tileEntity != null) + { + tileEntity.cachedFluid = null; + tileEntity.inventory = new ItemStack[2]; + tileEntity.inventoryID = -1; + } + } + + Mekanism.dynamicInventories.remove(id); + + return toReturn; + } + + /** + * Updates a dynamic tank cache with the defined inventory ID with the parameterized values. + * @param inventoryID - inventory ID of the dynamic tank + * @param fluid - cached fluid of the dynamic tank + * @param inventory - inventory of the dynamic tank + * @param tileEntity - dynamic tank TileEntity + */ + public static void updateCache(int inventoryID, FluidStack fluid, ItemStack[] inventory, TileEntityDynamicTank tileEntity) + { + if(!Mekanism.dynamicInventories.containsKey(inventoryID)) + { + DynamicTankCache cache = new DynamicTankCache(); + cache.inventory = inventory; + cache.fluid = fluid; + cache.locations.add(Coord4D.get(tileEntity)); + + Mekanism.dynamicInventories.put(inventoryID, cache); + + return; + } + + Mekanism.dynamicInventories.get(inventoryID).inventory = inventory; + Mekanism.dynamicInventories.get(inventoryID).fluid = fluid; + Mekanism.dynamicInventories.get(inventoryID).locations.add(Coord4D.get(tileEntity)); - } - - /** - * Grabs a unique inventory ID for a dynamic tank. - * @return unique inventory ID - */ - public static int getUniqueInventoryID() - { - int id = 0; - - while(true) - { - for(Integer i : Mekanism.dynamicInventories.keySet()) - { - if(id == i) - { - id++; - continue; - } - } - - return id; - } - } - - /** - * Retrieves a private value from a defined class and field. - * @param obj - the Object to retrieve the value from, null if static - * @param c - Class to retrieve field value from - * @param fields - possible names of field to iterate through - * @return value as an Object, cast as necessary - */ - public static Object getPrivateValue(Object obj, Class c, String[] fields) - { - for(String field : fields) - { - try { - Field f = c.getDeclaredField(field); - f.setAccessible(true); - return f.get(obj); - } catch(Exception e) { - continue; - } - } - - return null; - } - - /** - * Sets a private value from a defined class and field to a new value. - * @param obj - the Object to perform the operation on, null if static - * @param value - value to set the field to - * @param c - Class the operation will be performed on - * @param fields - possible names of field to iterate through - */ - public static void setPrivateValue(Object obj, Object value, Class c, String[] fields) - { - for(String field : fields) - { - try { - Field f = c.getDeclaredField(field); - f.setAccessible(true); - f.set(obj, value); - } catch(Exception e) { - continue; - } - } - } - - /** - * Retrieves a private method from a class, sets it as accessible, and returns it. - * @param c - Class the method is located in - * @param methods - possible names of the method to iterate through - * @param params - the Types inserted as parameters into the method - * @return private method - */ - public static Method getPrivateMethod(Class c, String[] methods, Class... params) - { - for(String method : methods) - { - try { - Method m = c.getDeclaredMethod(method, params); - m.setAccessible(true); - return m; - } catch(Exception e) { - continue; - } - } - - return null; - } - - /** - * Gets a ResourceLocation with a defined resource type and name. - * @param type - type of resource to retrieve - * @param name - simple name of file to retrieve as a ResourceLocation - * @return the corresponding ResourceLocation - */ - public static ResourceLocation getResource(ResourceType type, String name) - { - return new ResourceLocation("mekanism", type.getPrefix() + name); - } - - /** - * Removes all recipes that are used to create the defined ItemStacks. - * @param itemStacks - ItemStacks to perform the operation on - * @return if any recipes were removed - */ - public static boolean removeRecipes(ItemStack... itemStacks) + } + + /** + * Grabs a unique inventory ID for a dynamic tank. + * @return unique inventory ID + */ + public static int getUniqueInventoryID() + { + int id = 0; + + while(true) + { + for(Integer i : Mekanism.dynamicInventories.keySet()) + { + if(id == i) + { + id++; + continue; + } + } + + return id; + } + } + + /** + * Retrieves a private value from a defined class and field. + * @param obj - the Object to retrieve the value from, null if static + * @param c - Class to retrieve field value from + * @param fields - possible names of field to iterate through + * @return value as an Object, cast as necessary + */ + public static Object getPrivateValue(Object obj, Class c, String[] fields) + { + for(String field : fields) + { + try { + Field f = c.getDeclaredField(field); + f.setAccessible(true); + return f.get(obj); + } catch(Exception e) { + continue; + } + } + + return null; + } + + /** + * Sets a private value from a defined class and field to a new value. + * @param obj - the Object to perform the operation on, null if static + * @param value - value to set the field to + * @param c - Class the operation will be performed on + * @param fields - possible names of field to iterate through + */ + public static void setPrivateValue(Object obj, Object value, Class c, String[] fields) + { + for(String field : fields) + { + try { + Field f = c.getDeclaredField(field); + f.setAccessible(true); + f.set(obj, value); + } catch(Exception e) { + continue; + } + } + } + + /** + * Retrieves a private method from a class, sets it as accessible, and returns it. + * @param c - Class the method is located in + * @param methods - possible names of the method to iterate through + * @param params - the Types inserted as parameters into the method + * @return private method + */ + public static Method getPrivateMethod(Class c, String[] methods, Class... params) + { + for(String method : methods) + { + try { + Method m = c.getDeclaredMethod(method, params); + m.setAccessible(true); + return m; + } catch(Exception e) { + continue; + } + } + + return null; + } + + /** + * Gets a ResourceLocation with a defined resource type and name. + * @param type - type of resource to retrieve + * @param name - simple name of file to retrieve as a ResourceLocation + * @return the corresponding ResourceLocation + */ + public static ResourceLocation getResource(ResourceType type, String name) + { + return new ResourceLocation("mekanism", type.getPrefix() + name); + } + + /** + * Removes all recipes that are used to create the defined ItemStacks. + * @param itemStacks - ItemStacks to perform the operation on + * @return if any recipes were removed + */ + public static boolean removeRecipes(ItemStack... itemStacks) { boolean didRemove = false; @@ -1048,183 +1048,183 @@ public final class MekanismUtils return didRemove; } - - /** - * Marks the chunk this TileEntity is in as modified. Call this method to be sure NBT is written by the defined tile entity. - * @param tileEntity - TileEntity to save - */ - public static void saveChunk(TileEntity tileEntity) - { - if(tileEntity == null || tileEntity.isInvalid() || tileEntity.worldObj == null) - { - return; - } - - tileEntity.worldObj.markTileEntityChunkModified(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity); - } - - /** - * Whether or not a certain TileEntity can function with redstone logic. Illogical to use unless the defined TileEntity implements - * IRedstoneControl. - * @param tileEntity - TileEntity to check - * @return if the TileEntity can function with redstone logic - */ - public static boolean canFunction(TileEntity tileEntity) - { - if(!(tileEntity instanceof IRedstoneControl)) - { - return true; - } - - World world = tileEntity.worldObj; - IRedstoneControl control = (IRedstoneControl)tileEntity; - - if(control.getControlType() == RedstoneControl.DISABLED) - { - return true; - } - else if(control.getControlType() == RedstoneControl.HIGH) - { - return control.isPowered(); - } - else if(control.getControlType() == RedstoneControl.LOW) - { - return !control.isPowered(); - } - - return false; - } - - /** - * Ray-traces what block a player is looking at. - * @param world - world the player is in - * @param player - player to raytrace - * @return raytraced value - */ - public static MovingObjectPosition rayTrace(World world, EntityPlayer player) - { - double reach = Mekanism.proxy.getReach(player); - - Vec3 headVec = getHeadVec(player); - Vec3 lookVec = player.getLook(1); - Vec3 endVec = headVec.addVector(lookVec.xCoord*reach, lookVec.yCoord*reach, lookVec.zCoord*reach); - - return world.rayTraceBlocks_do_do(headVec, endVec, true, false); - } - - /** - * Gets the head vector of a player for a ray trace. - * @param player - player to check - * @return head location - */ - private static Vec3 getHeadVec(EntityPlayer player) - { - Vec3 vec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ); - - if(!player.worldObj.isRemote) - { - vec.yCoord += player.getEyeHeight(); - - if(player instanceof EntityPlayerMP && player.isSneaking()) - { - vec.yCoord -= 0.08; - } - } - - return vec; - } - - /** - * Gets a rounded energy display of a defined amount of energy. - * @param energy - energy to display - * @return rounded energy display - */ - public static String getEnergyDisplay(double energy) - { - switch(Mekanism.activeType) - { - case J: - return EnergyDisplay.getDisplayShort(energy, ElectricUnit.JOULES); - case RF: - return Math.round(energy*Mekanism.TO_TE) + " RF"; - case EU: - return Math.round(energy*Mekanism.TO_IC2) + " EU"; - case MJ: - return (Math.round((energy*Mekanism.TO_BC)*100)/100) + " MJ"; - } - - return "error"; - } - - /** - * Gets a rounded power display of a defined amount of energy. - * @param energy - energy to display - * @return rounded power display - */ - public static String getPowerDisplay(double energy) - { - return EnergyDisplay.getDisplayShort(energy, ElectricUnit.WATT); - } - - /** - * Whether or not BuildCraft power should be used, taking into account both whether or not it is installed or if - * the player has configured the mod to do so. - * @return if BuildCraft power should be used - */ - public static boolean useBuildCraft() - { - return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft; - } - - /** - * Gets a clean view of a coordinate value without the dimension ID. - * @param obj - coordinate to check - * @return coordinate display - */ - public static String getCoordDisplay(Coord4D obj) - { - return "[" + obj.xCoord + ", " + obj.yCoord + ", " + obj.zCoord + "]"; - } - - /** - * Splits a string of text into a list of new segments, using the splitter "!n." - * @param s - string to split - * @return split string - */ - public static List splitLines(String s) - { - ArrayList ret = new ArrayList(); - - String[] split = s.split("!n"); - ret.addAll(Arrays.asList(split)); - - return ret; - } - - /** - * Creates and returns a full gas tank with the specified gas type. - * @param gas - gas to fill the tank with - * @return filled gas tank - */ - public static ItemStack getFullGasTank(Gas gas) - { - ItemStack tank = getEmptyGasTank(); - ItemBlockGasTank item = (ItemBlockGasTank)tank.getItem(); - item.setGas(tank, new GasStack(gas, item.MAX_GAS)); - - return tank; - } - - /** - * Finds the output of a defined InventoryCrafting grid. Taken from CofhCore. - * @param inv - InventoryCrafting to check - * @param world - world reference - * @return output ItemStack - */ + + /** + * Marks the chunk this TileEntity is in as modified. Call this method to be sure NBT is written by the defined tile entity. + * @param tileEntity - TileEntity to save + */ + public static void saveChunk(TileEntity tileEntity) + { + if(tileEntity == null || tileEntity.isInvalid() || tileEntity.worldObj == null) + { + return; + } + + tileEntity.worldObj.markTileEntityChunkModified(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity); + } + + /** + * Whether or not a certain TileEntity can function with redstone logic. Illogical to use unless the defined TileEntity implements + * IRedstoneControl. + * @param tileEntity - TileEntity to check + * @return if the TileEntity can function with redstone logic + */ + public static boolean canFunction(TileEntity tileEntity) + { + if(!(tileEntity instanceof IRedstoneControl)) + { + return true; + } + + World world = tileEntity.worldObj; + IRedstoneControl control = (IRedstoneControl)tileEntity; + + if(control.getControlType() == RedstoneControl.DISABLED) + { + return true; + } + else if(control.getControlType() == RedstoneControl.HIGH) + { + return control.isPowered(); + } + else if(control.getControlType() == RedstoneControl.LOW) + { + return !control.isPowered(); + } + + return false; + } + + /** + * Ray-traces what block a player is looking at. + * @param world - world the player is in + * @param player - player to raytrace + * @return raytraced value + */ + public static MovingObjectPosition rayTrace(World world, EntityPlayer player) + { + double reach = Mekanism.proxy.getReach(player); + + Vec3 headVec = getHeadVec(player); + Vec3 lookVec = player.getLook(1); + Vec3 endVec = headVec.addVector(lookVec.xCoord*reach, lookVec.yCoord*reach, lookVec.zCoord*reach); + + return world.rayTraceBlocks_do_do(headVec, endVec, true, false); + } + + /** + * Gets the head vector of a player for a ray trace. + * @param player - player to check + * @return head location + */ + private static Vec3 getHeadVec(EntityPlayer player) + { + Vec3 vec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ); + + if(!player.worldObj.isRemote) + { + vec.yCoord += player.getEyeHeight(); + + if(player instanceof EntityPlayerMP && player.isSneaking()) + { + vec.yCoord -= 0.08; + } + } + + return vec; + } + + /** + * Gets a rounded energy display of a defined amount of energy. + * @param energy - energy to display + * @return rounded energy display + */ + public static String getEnergyDisplay(double energy) + { + switch(Mekanism.activeType) + { + case J: + return EnergyDisplay.getDisplayShort(energy, ElectricUnit.JOULES); + case RF: + return Math.round(energy*Mekanism.TO_TE) + " RF"; + case EU: + return Math.round(energy*Mekanism.TO_IC2) + " EU"; + case MJ: + return (Math.round((energy*Mekanism.TO_BC)*100)/100) + " MJ"; + } + + return "error"; + } + + /** + * Gets a rounded power display of a defined amount of energy. + * @param energy - energy to display + * @return rounded power display + */ + public static String getPowerDisplay(double energy) + { + return EnergyDisplay.getDisplayShort(energy, ElectricUnit.WATT); + } + + /** + * Whether or not BuildCraft power should be used, taking into account both whether or not it is installed or if + * the player has configured the mod to do so. + * @return if BuildCraft power should be used + */ + public static boolean useBuildCraft() + { + return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft; + } + + /** + * Gets a clean view of a coordinate value without the dimension ID. + * @param obj - coordinate to check + * @return coordinate display + */ + public static String getCoordDisplay(Coord4D obj) + { + return "[" + obj.xCoord + ", " + obj.yCoord + ", " + obj.zCoord + "]"; + } + + /** + * Splits a string of text into a list of new segments, using the splitter "!n." + * @param s - string to split + * @return split string + */ + public static List splitLines(String s) + { + ArrayList ret = new ArrayList(); + + String[] split = s.split("!n"); + ret.addAll(Arrays.asList(split)); + + return ret; + } + + /** + * Creates and returns a full gas tank with the specified gas type. + * @param gas - gas to fill the tank with + * @return filled gas tank + */ + public static ItemStack getFullGasTank(Gas gas) + { + ItemStack tank = getEmptyGasTank(); + ItemBlockGasTank item = (ItemBlockGasTank)tank.getItem(); + item.setGas(tank, new GasStack(gas, item.MAX_GAS)); + + return tank; + } + + /** + * Finds the output of a defined InventoryCrafting grid. Taken from CofhCore. + * @param inv - InventoryCrafting to check + * @param world - world reference + * @return output ItemStack + */ public static ItemStack findMatchingRecipe(InventoryCrafting inv, World world) { ItemStack[] dmgItems = new ItemStack[2]; - + for(int i = 0; i < inv.getSizeInventory(); i++) { if(inv.getStackInSlot(i) != null) @@ -1244,7 +1244,7 @@ public final class MekanismUtils { return null; } - + if((dmgItems[1] != null) && (dmgItems[0].itemID == dmgItems[1].itemID) && (dmgItems[0].stackSize == 1) && (dmgItems[1].stackSize == 1) && (Item.itemsList[dmgItems[0].itemID].isRepairable())) { Item theItem = Item.itemsList[dmgItems[0].itemID]; @@ -1262,31 +1262,31 @@ public final class MekanismUtils return recipe.getCraftingResult(inv); } } - + return null; } - - public static enum ResourceType - { - GUI("gui"), + + public static enum ResourceType + { + GUI("gui"), GUI_ELEMENT("gui/elements"), - SOUND("sound"), - RENDER("render"), - TEXTURE_BLOCKS("textures/blocks"), - TEXTURE_ITEMS("textures/items"), - MODEL("models"), - INFUSE("infuse"); - - private String prefix; - - private ResourceType(String s) - { - prefix = s; - } - - public String getPrefix() - { - return prefix + "/"; - } - } + SOUND("sound"), + RENDER("render"), + TEXTURE_BLOCKS("textures/blocks"), + TEXTURE_ITEMS("textures/items"), + MODEL("models"), + INFUSE("infuse"); + + private String prefix; + + private ResourceType(String s) + { + prefix = s; + } + + public String getPrefix() + { + return prefix + "/"; + } + } } diff --git a/common/mekanism/common/util/MinerUtils.java b/common/mekanism/common/util/MinerUtils.java index 4a2493edd..158d8b476 100644 --- a/common/mekanism/common/util/MinerUtils.java +++ b/common/mekanism/common/util/MinerUtils.java @@ -9,40 +9,40 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public final class MinerUtils +public final class MinerUtils { public static List specialSilkIDs = ListUtils.asList(Block.ice.blockID); - + public static List getDrops(World world, Coord4D obj, boolean silk) { Block block = Block.blocksList[obj.getBlockId(world)]; - if(block == null) - { - return new ArrayList(); - } - - if(block.isAirBlock(world, obj.xCoord, obj.yCoord, obj.zCoord)) - { - return new ArrayList(); - } + if(block == null) + { + return new ArrayList(); + } - int meta = obj.getMetadata(world); + if(block.isAirBlock(world, obj.xCoord, obj.yCoord, obj.zCoord)) + { + return new ArrayList(); + } - if(!silk) - { - return block.getBlockDropped(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0); - } - else { - List ret = new ArrayList(); - ret.add(new ItemStack(block.blockID, 1, meta)); - - if(specialSilkIDs.contains(block.blockID) || (block.getBlockDropped(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0) != null && block.getBlockDropped(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0).size() > 0)) - { - return ret; - } - } - - return new ArrayList(); + int meta = obj.getMetadata(world); + + if(!silk) + { + return block.getBlockDropped(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0); + } + else { + List ret = new ArrayList(); + ret.add(new ItemStack(block.blockID, 1, meta)); + + if(specialSilkIDs.contains(block.blockID) || (block.getBlockDropped(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0) != null && block.getBlockDropped(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0).size() > 0)) + { + return ret; + } + } + + return new ArrayList(); } } diff --git a/common/mekanism/common/util/PipeUtils.java b/common/mekanism/common/util/PipeUtils.java index 6adf10e7a..bfe5b1422 100644 --- a/common/mekanism/common/util/PipeUtils.java +++ b/common/mekanism/common/util/PipeUtils.java @@ -10,56 +10,56 @@ import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public final class PipeUtils +public final class PipeUtils { public static final FluidTankInfo[] EMPTY = new FluidTankInfo[] {}; - - /** - * Gets all the pipes around a tile entity. - * @param tileEntity - center tile entity - * @return array of TileEntities - */ - public static TileEntity[] getConnectedPipes(TileEntity tileEntity) - { - TileEntity[] pipes = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + + /** + * Gets all the pipes around a tile entity. + * @param tileEntity - center tile entity + * @return array of TileEntities + */ + public static TileEntity[] getConnectedPipes(TileEntity tileEntity) + { + TileEntity[] pipes = new TileEntity[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity pipe = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); - + if(TransmissionType.checkTransmissionType(pipe, TransmissionType.FLUID)) { pipes[orientation.ordinal()] = pipe; } - } - - return pipes; - } + } - /** - * Gets all the adjacent connections to a TileEntity. - * @param tileEntity - center TileEntity - * @return boolean[] of adjacent connections - */ - public static boolean[] getConnections(TileEntity tileEntity) - { + return pipes; + } + + /** + * Gets all the adjacent connections to a TileEntity. + * @param tileEntity - center TileEntity + * @return boolean[] of adjacent connections + */ + public static boolean[] getConnections(TileEntity tileEntity) + { boolean[] connectable = new boolean[] {false, false, false, false, false, false}; - + TileEntity[] connectedPipes = PipeUtils.getConnectedPipes(tileEntity); IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tileEntity); - + for(IFluidHandler container : connectedAcceptors) { if(container != null) { int side = Arrays.asList(connectedAcceptors).indexOf(container); - + FluidTankInfo[] infoArray = container.getTankInfo(ForgeDirection.getOrientation(side).getOpposite()); - + if(infoArray != null && infoArray.length > 0) { boolean notNull = false; - + for(FluidTankInfo info : container.getTankInfo(ForgeDirection.getOrientation(side).getOpposite())) { if(info != null) @@ -68,7 +68,7 @@ public final class PipeUtils break; } } - + if(notNull) { connectable[side] = true; @@ -76,39 +76,39 @@ public final class PipeUtils } } } - + for(TileEntity tile : connectedPipes) { if(tile != null) { int side = Arrays.asList(connectedPipes).indexOf(tile); - + connectable[side] = true; } } - - return connectable; - } - - /** - * Gets all the acceptors around a tile entity. - * @param tileEntity - center tile entity - * @return array of IFluidHandlers - */ - public static IFluidHandler[] getConnectedAcceptors(TileEntity tileEntity) - { - IFluidHandler[] acceptors = new IFluidHandler[] {null, null, null, null, null, null}; - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + return connectable; + } + + /** + * Gets all the acceptors around a tile entity. + * @param tileEntity - center tile entity + * @return array of IFluidHandlers + */ + public static IFluidHandler[] getConnectedAcceptors(TileEntity tileEntity) + { + IFluidHandler[] acceptors = new IFluidHandler[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj); - + if(acceptor instanceof IFluidHandler && !(acceptor instanceof IGridTransmitter)) { acceptors[orientation.ordinal()] = (IFluidHandler)acceptor; } - } - - return acceptors; - } + } + + return acceptors; + } } diff --git a/common/mekanism/common/util/StackUtils.java b/common/mekanism/common/util/StackUtils.java index 8512250e3..e6d9186b0 100644 --- a/common/mekanism/common/util/StackUtils.java +++ b/common/mekanism/common/util/StackUtils.java @@ -15,83 +15,83 @@ public final class StackUtils { return null; } - + List ret = new ArrayList(); - + if(stack.stackSize == 1) { ret.add(stack); return ret; } - + int remain = stack.stackSize % 2; int split = (int)((float)(stack.stackSize)/2F); - + ret.add(size(stack, split+remain)); ret.add(size(stack, split)); - + return ret; } - + public static Item getItem(ItemStack stack) { if(stack == null) { return null; } - + return stack.getItem(); } - + public static boolean diffIgnoreNull(ItemStack stack1, ItemStack stack2) { if(stack1 == null || stack2 == null) { return false; } - + return stack1.itemID != stack2.itemID || stack1.getItemDamage() != stack2.getItemDamage(); } - + public static boolean equalsWildcard(ItemStack wild, ItemStack check) { return wild.itemID == check.itemID && (wild.getItemDamage() == OreDictionary.WILDCARD_VALUE || wild.getItemDamage() == check.getItemDamage()); } - + public static List even(ItemStack stack1, ItemStack stack2) { ArrayList ret = new ArrayList(); - + if(getSize(stack1) == getSize(stack2) || Math.abs(getSize(stack1)-getSize(stack2)) == 1) { ret.add(stack1); ret.add(stack2); - + return ret; } - + if(getSize(stack1) > getSize(stack2)) { int diff = getSize(stack1)-getSize(stack2); - + List split = split(size(stack1, diff)); - + ret.add(subtract(stack1, split.get(0))); ret.add(add(stack2, split.get(0))); } else if(getSize(stack2) > getSize(stack1)) { int diff = getSize(stack2)-getSize(stack1); - + List split = split(size(stack2, diff)); - + ret.add(subtract(stack2, split.get(0))); ret.add(add(stack1, split.get(0))); } - + return ret; } - + public static ItemStack add(ItemStack stack1, ItemStack stack2) { if(stack1 == null) @@ -102,10 +102,10 @@ public final class StackUtils { return stack1; } - + return size(stack1, getSize(stack1)+getSize(stack2)); } - + public static ItemStack subtract(ItemStack stack1, ItemStack stack2) { if(stack1 == null) @@ -116,32 +116,32 @@ public final class StackUtils { return stack1; } - + return size(stack1, getSize(stack1)-getSize(stack2)); } - + public static ItemStack size(ItemStack stack, int size) { if(size <= 0 || stack == null) { return null; } - + ItemStack ret = stack.copy(); ret.stackSize = size; return ret; } - + public static ItemStack copy(ItemStack stack) { if(stack == null) { return null; } - + return stack.copy(); } - + public static int getSize(ItemStack stack) { return stack != null ? stack.stackSize : 0; diff --git a/common/mekanism/common/util/TransporterUtils.java b/common/mekanism/common/util/TransporterUtils.java index ddb01baa8..ab360f94d 100644 --- a/common/mekanism/common/util/TransporterUtils.java +++ b/common/mekanism/common/util/TransporterUtils.java @@ -21,63 +21,63 @@ import net.minecraftforge.common.ForgeDirection; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler.Type; -public final class TransporterUtils +public final class TransporterUtils { public static List colors = ListUtils.asList(EnumColor.DARK_BLUE, EnumColor.DARK_GREEN, EnumColor.DARK_AQUA, EnumColor.DARK_RED, EnumColor.PURPLE, EnumColor.INDIGO, EnumColor.BRIGHT_GREEN, EnumColor.AQUA, EnumColor.RED, EnumColor.PINK, EnumColor.YELLOW, EnumColor.BLACK); - /** - * Gets all the transporters around a tile entity. - * @param tileEntity - center tile entity - * @return array of TileEntities - */ - public static TileEntity[] getConnectedTransporters(ILogisticalTransporter tileEntity) - { - TileEntity[] transporters = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + /** + * Gets all the transporters around a tile entity. + * @param tileEntity - center tile entity + * @return array of TileEntities + */ + public static TileEntity[] getConnectedTransporters(ILogisticalTransporter tileEntity) + { + TileEntity[] transporters = new TileEntity[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity tile = Coord4D.get(tileEntity.getTile()).getFromSide(orientation).getTileEntity(tileEntity.getTile().worldObj); - + if(tile instanceof ILogisticalTransporter) { ILogisticalTransporter transporter = (ILogisticalTransporter)tile; - + if(transporter.getColor() == null || tileEntity.getColor() == null || transporter.getColor() == tileEntity.getColor()) { transporters[orientation.ordinal()] = transporter.getTile(); } } - } - - return transporters; - } + } - /** - * Gets all the adjacent connections to a TileEntity. - * @param tileEntity - center TileEntity - * @return boolean[] of adjacent connections - */ - public static boolean[] getConnections(ILogisticalTransporter tileEntity) - { + return transporters; + } + + /** + * Gets all the adjacent connections to a TileEntity. + * @param tileEntity - center TileEntity + * @return boolean[] of adjacent connections + */ + public static boolean[] getConnections(ILogisticalTransporter tileEntity) + { boolean[] connectable = new boolean[] {false, false, false, false, false, false}; - + TileEntity[] connectedTransporters = getConnectedTransporters(tileEntity); IInventory[] connectedInventories = getConnectedInventories(tileEntity); - + for(IInventory inventory : connectedInventories) { if(inventory != null) { int side = Arrays.asList(connectedInventories).indexOf(inventory); - + if(!tileEntity.canConnect(ForgeDirection.getOrientation(side))) { continue; } - + ForgeDirection forgeSide = ForgeDirection.getOrientation(side).getOpposite(); - + //Immature BuildCraft inv check if(MekanismUtils.useBuildCraft() && inventory instanceof IPowerReceptor) { @@ -87,13 +87,13 @@ public final class TransporterUtils continue; } } - + if(inventory.getSizeInventory() > 0) { if(inventory instanceof ISidedInventory) { ISidedInventory sidedInventory = (ISidedInventory)inventory; - + if(sidedInventory.getAccessibleSlotsFromSide(forgeSide.ordinal()) != null) { if(sidedInventory.getAccessibleSlotsFromSide(forgeSide.ordinal()).length > 0) @@ -108,56 +108,56 @@ public final class TransporterUtils } } } - + for(TileEntity tile : connectedTransporters) { if(tile != null) { int side = Arrays.asList(connectedTransporters).indexOf(tile); - + if(tileEntity.canConnectMutual(ForgeDirection.getOrientation(side))) { connectable[side] = true; } } } - - return connectable; - } - - /** - * Gets all the inventories around a tile entity. - * @param tileEntity - center tile entity - * @return array of IInventories - */ - public static IInventory[] getConnectedInventories(ILogisticalTransporter tileEntity) - { - IInventory[] inventories = new IInventory[] {null, null, null, null, null, null}; - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { + return connectable; + } + + /** + * Gets all the inventories around a tile entity. + * @param tileEntity - center tile entity + * @return array of IInventories + */ + public static IInventory[] getConnectedInventories(ILogisticalTransporter tileEntity) + { + IInventory[] inventories = new IInventory[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) + { TileEntity inventory = Coord4D.get(tileEntity.getTile()).getFromSide(orientation).getTileEntity(tileEntity.getTile().worldObj); - + if(inventory instanceof IInventory && !(inventory instanceof IGridTransmitter)) { inventories[orientation.ordinal()] = (IInventory)inventory; } - } - - return inventories; - } - - public static ItemStack insert(TileEntity outputter, ILogisticalTransporter tileEntity, ItemStack itemStack, EnumColor color, boolean doEmit, int min) - { - return tileEntity.insert(Coord4D.get(outputter), itemStack.copy(), color, doEmit, min); - } - - public static ItemStack insertRR(TileEntityLogisticalSorter outputter, ILogisticalTransporter tileEntity, ItemStack itemStack, EnumColor color, boolean doEmit, int min) - { - return tileEntity.insertRR(outputter, itemStack.copy(), color, doEmit, min); - } - - public static EnumColor increment(EnumColor color) + } + + return inventories; + } + + public static ItemStack insert(TileEntity outputter, ILogisticalTransporter tileEntity, ItemStack itemStack, EnumColor color, boolean doEmit, int min) + { + return tileEntity.insert(Coord4D.get(outputter), itemStack.copy(), color, doEmit, min); + } + + public static ItemStack insertRR(TileEntityLogisticalSorter outputter, ILogisticalTransporter tileEntity, ItemStack itemStack, EnumColor color, boolean doEmit, int min) + { + return tileEntity.insertRR(outputter, itemStack.copy(), color, doEmit, min); + } + + public static EnumColor increment(EnumColor color) { if(color == null) { @@ -167,28 +167,28 @@ public final class TransporterUtils { return null; } - + return colors.get(colors.indexOf(color)+1); } - - public static EnumColor decrement(EnumColor color) - { - if(color == null) - { - return colors.get(colors.size()-1); - } - else if(colors.indexOf(color) == 0) - { - return null; - } - - return colors.get(colors.indexOf(color)-1); - } - + + public static EnumColor decrement(EnumColor color) + { + if(color == null) + { + return colors.get(colors.size()-1); + } + else if(colors.indexOf(color) == 0) + { + return null; + } + + return colors.get(colors.indexOf(color)-1); + } + public static void drop(ILogisticalTransporter tileEntity, TransporterStack stack) { float[] pos = null; - + if(stack.pathToTarget != null) { pos = TransporterUtils.getStackPosition(tileEntity, stack, 0); @@ -196,47 +196,47 @@ public final class TransporterUtils else { pos = new float[] {0, 0, 0}; } - + TransporterManager.remove(stack); - + EntityItem entityItem = new EntityItem(tileEntity.getTile().worldObj, tileEntity.getTile().xCoord + pos[0], tileEntity.getTile().yCoord + pos[1], tileEntity.getTile().zCoord + pos[2], stack.itemStack); - + entityItem.motionX = 0; entityItem.motionY = 0; entityItem.motionZ = 0; - - tileEntity.getTile().worldObj.spawnEntityInWorld(entityItem); + + tileEntity.getTile().worldObj.spawnEntityInWorld(entityItem); } - + public static float[] getStackPosition(ILogisticalTransporter tileEntity, TransporterStack stack, float partial) { Coord4D offset = new Coord4D(0, 0, 0, tileEntity.getTile().worldObj.provider.dimensionId).step(ForgeDirection.getOrientation(stack.getSide(tileEntity))); float progress = (((float)stack.progress + partial) / 100F) - 0.5F; - + float itemFix = 0; - + if(!(stack.itemStack.getItem() instanceof ItemBlock)) { itemFix = 0.1F; } - + return new float[] {0.5F + offset.xCoord*progress, 0.5F + offset.yCoord*progress - itemFix, 0.5F + offset.zCoord*progress}; } - - public static void incrementColor(ILogisticalTransporter tileEntity) - { - if(tileEntity.getColor() == null) - { - tileEntity.setColor(colors.get(0)); - return; - } - else if(colors.indexOf(tileEntity.getColor()) == colors.size()-1) - { - tileEntity.setColor(null); - return; - } - - int index = colors.indexOf(tileEntity.getColor()); - tileEntity.setColor(colors.get(index+1)); - } + + public static void incrementColor(ILogisticalTransporter tileEntity) + { + if(tileEntity.getColor() == null) + { + tileEntity.setColor(colors.get(0)); + return; + } + else if(colors.indexOf(tileEntity.getColor()) == colors.size()-1) + { + tileEntity.setColor(null); + return; + } + + int index = colors.indexOf(tileEntity.getColor()); + tileEntity.setColor(colors.get(index+1)); + } } \ No newline at end of file diff --git a/common/mekanism/common/voice/VoiceConnection.java b/common/mekanism/common/voice/VoiceConnection.java index acae3321a..0740c66f9 100644 --- a/common/mekanism/common/voice/VoiceConnection.java +++ b/common/mekanism/common/voice/VoiceConnection.java @@ -19,44 +19,44 @@ import cpw.mods.fml.common.FMLCommonHandler; public class VoiceConnection extends Thread { public Socket socket; - + public String username; - + public boolean open = true; - + public DataInputStream input; public DataOutputStream output; - + public MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - + public VoiceConnection(Socket s) { socket = s; } - + @Override public void run() { try { input = new DataInputStream(new BufferedInputStream(socket.getInputStream())); output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); - + synchronized(Mekanism.voiceManager) { int retryCount = 0; - + while(username == null && retryCount <= 100) { try { List l = Collections.synchronizedList((List)((ArrayList)server.getConfigurationManager().playerEntityList).clone()); - + for(Object obj : l) { if(obj instanceof EntityPlayerMP) { EntityPlayerMP playerMP = (EntityPlayerMP)obj; String playerIP = playerMP.getPlayerIP(); - + if(!server.isDedicatedServer() && playerIP.equals("127.0.0.1") && !Mekanism.voiceManager.foundLocal) { Mekanism.voiceManager.foundLocal = true; @@ -70,12 +70,12 @@ public class VoiceConnection extends Thread } } } - + retryCount++; Thread.sleep(50); } catch(Exception e) {} } - + if(username == null) { System.out.println("[Mekanism] VoiceServer: Unable to trace connection's IP address."); @@ -91,7 +91,7 @@ public class VoiceConnection extends Thread e.printStackTrace(); open = false; } - + //Main client listen thread new Thread(new Runnable() { @@ -104,7 +104,7 @@ public class VoiceConnection extends Thread short byteCount = VoiceConnection.this.input.readShort(); byte[] audioData = new byte[byteCount]; VoiceConnection.this.input.readFully(audioData); - + if(byteCount > 0) { Mekanism.voiceManager.sendToPlayers(byteCount, audioData, VoiceConnection.this); @@ -113,7 +113,7 @@ public class VoiceConnection extends Thread open = false; } } - + if(!open) { kill(); @@ -121,39 +121,39 @@ public class VoiceConnection extends Thread } }).start(); } - + public void kill() { try { input.close(); output.close(); socket.close(); - + Mekanism.voiceManager.connections.remove(this); } catch(Exception e) { System.err.println("[Mekanism] VoiceServer: Error while stopping server-based connection."); e.printStackTrace(); } } - + public void sendToPlayer(short byteCount, byte[] audioData, VoiceConnection connection) { if(!open) { kill(); } - + try { output.writeShort(byteCount); output.write(audioData); - + output.flush(); } catch(Exception e) { System.err.println("[Mekanism] VoiceServer: Error while sending data to player."); e.printStackTrace(); } } - + public boolean canListen(int channel) { for(ItemStack itemStack : getPlayer().inventory.mainInventory) @@ -172,18 +172,18 @@ public class VoiceConnection extends Thread } } } - + return false; } - + public int getCurrentChannel() { ItemStack itemStack = getPlayer().getCurrentEquippedItem(); - + if(itemStack != null) { ItemWalkieTalkie walkieTalkie = (ItemWalkieTalkie)itemStack.getItem(); - + if(walkieTalkie != null) { if(walkieTalkie.getOn(itemStack)) @@ -192,10 +192,10 @@ public class VoiceConnection extends Thread } } } - + return 0; } - + public EntityPlayerMP getPlayer() { return server.getConfigurationManager().getPlayerForUsername(username); diff --git a/common/mekanism/common/voice/VoiceServerManager.java b/common/mekanism/common/voice/VoiceServerManager.java index 4993e95a1..7f708c18d 100644 --- a/common/mekanism/common/voice/VoiceServerManager.java +++ b/common/mekanism/common/voice/VoiceServerManager.java @@ -11,37 +11,37 @@ import mekanism.common.Mekanism; public class VoiceServerManager { public Set connections = new HashSet(); - + public ServerSocket serverSocket; - + public boolean running; - + public boolean foundLocal = false; - + public Thread listenThread; - + public void start() { System.out.println("[Mekanism] VoiceServer: Starting up server..."); - + try { running = true; serverSocket = new ServerSocket(Mekanism.VOICE_PORT); (listenThread = new ListenThread()).start(); } catch(Exception e) {} } - + public void stop() { try { System.out.println("[Mekanism] VoiceServer: Shutting down server..."); - + try { listenThread.interrupt(); } catch(Exception e) {} - + foundLocal = false; - + try { serverSocket.close(); serverSocket = null; @@ -50,35 +50,35 @@ public class VoiceServerManager System.err.println("[Mekanism] VoiceServer: Error while shutting down server."); e.printStackTrace(); } - + running = false; } - + public void sendToPlayers(short byteCount, byte[] audioData, VoiceConnection connection) { if(connection.getPlayer() == null) { return; } - + int channel = connection.getCurrentChannel(); - + if(channel == 0) { return; } - + for(VoiceConnection iterConn : connections) { if(iterConn.getPlayer() == null || iterConn == connection || !iterConn.canListen(channel)) { continue; } - + iterConn.sendToPlayer(byteCount, audioData, connection); } } - + public class ListenThread extends Thread { public ListenThread() @@ -86,7 +86,7 @@ public class VoiceServerManager setDaemon(true); setName("VoiceServer Listen Thread"); } - + @Override public void run() { @@ -97,7 +97,7 @@ public class VoiceServerManager VoiceConnection connection = new VoiceConnection(s); connection.start(); connections.add(connection); - + System.out.println("[Mekanism] VoiceServer: Accepted new connection."); } catch(SocketException e) { } catch(NullPointerException e) { diff --git a/common/mekanism/generators/client/BlockRenderingHandler.java b/common/mekanism/generators/client/BlockRenderingHandler.java index ad1fdf00c..e590178f5 100644 --- a/common/mekanism/generators/client/BlockRenderingHandler.java +++ b/common/mekanism/generators/client/BlockRenderingHandler.java @@ -24,69 +24,69 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler public ModelHeatGenerator heatGenerator = new ModelHeatGenerator(); public ModelHydrogenGenerator hydrogenGenerator = new ModelHydrogenGenerator(); public ModelWindTurbine windTurbine = new ModelWindTurbine(); - + @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - GL11.glPushMatrix(); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - - if(block.blockID == MekanismGenerators.generatorID) - { - if(metadata == GeneratorType.BIO_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png")); - bioGenerator.render(0.0625F); - } - else if(metadata == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.2F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png")); - advancedSolarGenerator.render(0.022F); - } - else if(metadata == GeneratorType.SOLAR_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png")); - solarGenerator.render(0.0625F); - } - else if(metadata == GeneratorType.HEAT_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png")); - heatGenerator.render(0.0625F); - } - else if(metadata == GeneratorType.HYDROGEN_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 1.0F, 1.0F); - GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HydrogenGenerator.png")); - hydrogenGenerator.render(0.0625F); - } - else if(metadata == GeneratorType.WIND_TURBINE.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.35F, 0.0F); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindTurbine.png")); - windTurbine.render(0.018F, 0); - } - else if(metadata != 2) { - MekanismRenderer.renderItem(renderer, metadata, block); - } - } - - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + + if(block.blockID == MekanismGenerators.generatorID) + { + if(metadata == GeneratorType.BIO_GENERATOR.meta) + { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png")); + bioGenerator.render(0.0625F); + } + else if(metadata == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) + { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.2F, 0.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png")); + advancedSolarGenerator.render(0.022F); + } + else if(metadata == GeneratorType.SOLAR_GENERATOR.meta) + { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png")); + solarGenerator.render(0.0625F); + } + else if(metadata == GeneratorType.HEAT_GENERATOR.meta) + { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png")); + heatGenerator.render(0.0625F); + } + else if(metadata == GeneratorType.HYDROGEN_GENERATOR.meta) + { + GL11.glRotatef(180F, 0.0F, 1.0F, 1.0F); + GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HydrogenGenerator.png")); + hydrogenGenerator.render(0.0625F); + } + else if(metadata == GeneratorType.WIND_TURBINE.meta) + { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.35F, 0.0F); + Minecraft.getMinecraft().renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindTurbine.png")); + windTurbine.render(0.018F, 0); + } + else if(metadata != 2) { + MekanismRenderer.renderItem(renderer, metadata, block); + } + } + + GL11.glPopMatrix(); } @Override @@ -95,7 +95,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler if(block.blockID == MekanismGenerators.generatorID) { int metadata = world.getBlockMetadata(x, y, z); - + if(GeneratorType.getFromMetadata(metadata) == null || !GeneratorType.getFromMetadata(metadata).hasModel) { renderer.renderStandardBlock(block, x, y, z); @@ -103,18 +103,18 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler return true; } } - + return false; } @Override - public boolean shouldRender3DInInventory() + public boolean shouldRender3DInInventory() { return true; } @Override - public int getRenderId() + public int getRenderId() { return GeneratorsClientProxy.GENERATOR_RENDER_ID; } diff --git a/common/mekanism/generators/client/GeneratorsClientProxy.java b/common/mekanism/generators/client/GeneratorsClientProxy.java index 3aaa06beb..2bf05db36 100644 --- a/common/mekanism/generators/client/GeneratorsClientProxy.java +++ b/common/mekanism/generators/client/GeneratorsClientProxy.java @@ -17,9 +17,9 @@ import net.minecraft.world.World; public class GeneratorsClientProxy extends GeneratorsCommonProxy { public static int GENERATOR_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); - + @Override - public void registerSpecialTileEntities() + public void registerSpecialTileEntities() { ClientRegistry.registerTileEntity(TileEntityAdvancedSolarGenerator.class, "AdvancedSolarGenerator", new RenderAdvancedSolarGenerator()); ClientRegistry.registerTileEntity(TileEntitySolarGenerator.class, "SolarGenerator", new RenderSolarGenerator()); @@ -28,21 +28,21 @@ public class GeneratorsClientProxy extends GeneratorsCommonProxy ClientRegistry.registerTileEntity(TileEntityHydrogenGenerator.class, "HydrogenGenerator", new RenderHydrogenGenerator()); ClientRegistry.registerTileEntity(TileEntityWindTurbine.class, "WindTurbine", new RenderWindTurbine()); } - + @Override public void registerRenderInformation() { //Register block handler RenderingRegistry.registerBlockHandler(new BlockRenderingHandler()); - + System.out.println("[MekanismGenerators] Render registrations complete."); } - + @Override - public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + switch(ID) { case 0: diff --git a/common/mekanism/generators/client/gui/GuiBioGenerator.java b/common/mekanism/generators/client/gui/GuiBioGenerator.java index 2e85cbbff..aa0b31c31 100644 --- a/common/mekanism/generators/client/gui/GuiBioGenerator.java +++ b/common/mekanism/generators/client/gui/GuiBioGenerator.java @@ -17,54 +17,54 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiBioGenerator extends GuiMekanism { public TileEntityBioGenerator tileEntity; - + public GuiBioGenerator(InventoryPlayer inventory, TileEntityBioGenerator tentity) - { - super(new ContainerBioGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"))); - } + { + super(new ContainerBioGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"))); + } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.bioGenerator.bioFuel") + ": " + tileEntity.bioFuelSlot.fluidStored, 51, 35, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); - - if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.bioGenerator.bioFuel") + ": " + tileEntity.bioFuelSlot.fluidStored, 51, 35, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); + + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledFuelLevel(52); - drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176, 52 + 52 - displayInt, 4, displayInt); - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - } + + int displayInt; + + displayInt = tileEntity.getScaledFuelLevel(52); + drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176, 52 + 52 - displayInt, 4, displayInt); + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + } } diff --git a/common/mekanism/generators/client/gui/GuiHeatGenerator.java b/common/mekanism/generators/client/gui/GuiHeatGenerator.java index a3e95fc92..9a6e47355 100644 --- a/common/mekanism/generators/client/gui/GuiHeatGenerator.java +++ b/common/mekanism/generators/client/gui/GuiHeatGenerator.java @@ -17,54 +17,54 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiHeatGenerator extends GuiMekanism { public TileEntityHeatGenerator tileEntity; - + public GuiHeatGenerator(InventoryPlayer inventory, TileEntityHeatGenerator tentity) - { - super(new ContainerHeatGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"))); - } + { + super(new ContainerHeatGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"))); + } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.heatGenerator.fuel") + ": " + (tileEntity.lavaTank.getFluid() != null ? tileEntity.lavaTank.getFluid().amount : 0), 51, 35, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); - - if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.heatGenerator.fuel") + ": " + (tileEntity.lavaTank.getFluid() != null ? tileEntity.lavaTank.getFluid().amount : 0), 51, 35, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); + + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledFuelLevel(52); - drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176, 52 + 52 - displayInt, 4, displayInt); - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - } + + int displayInt; + + displayInt = tileEntity.getScaledFuelLevel(52); + drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176, 52 + 52 - displayInt, 4, displayInt); + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + } } diff --git a/common/mekanism/generators/client/gui/GuiHydrogenGenerator.java b/common/mekanism/generators/client/gui/GuiHydrogenGenerator.java index e528cb739..81d8e5670 100644 --- a/common/mekanism/generators/client/gui/GuiHydrogenGenerator.java +++ b/common/mekanism/generators/client/gui/GuiHydrogenGenerator.java @@ -17,54 +17,54 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiHydrogenGenerator extends GuiMekanism { public TileEntityHydrogenGenerator tileEntity; - + public GuiHydrogenGenerator(InventoryPlayer inventory, TileEntityHydrogenGenerator tentity) - { - super(new ContainerHydrogenGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png"))); - } + { + super(new ContainerHydrogenGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png"))); + } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRenderer.drawString("H: " + tileEntity.hydrogenStored, 51, 35, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); - - if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRenderer.drawString("H: " + tileEntity.hydrogenStored, 51, 35, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); + + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = mouseX - guiWidth; + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledHydrogenLevel(52); - drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176, 52 + 52 - displayInt, 4, displayInt); - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - } + + int displayInt; + + displayInt = tileEntity.getScaledHydrogenLevel(52); + drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176, 52 + 52 - displayInt, 4, displayInt); + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + } } diff --git a/common/mekanism/generators/client/gui/GuiSolarGenerator.java b/common/mekanism/generators/client/gui/GuiSolarGenerator.java index 32a400ffb..f554a551a 100644 --- a/common/mekanism/generators/client/gui/GuiSolarGenerator.java +++ b/common/mekanism/generators/client/gui/GuiSolarGenerator.java @@ -17,53 +17,53 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiSolarGenerator extends GuiMekanism { public TileEntitySolarGenerator tileEntity; - + public GuiSolarGenerator(InventoryPlayer inventory, TileEntitySolarGenerator tentity) - { - super(new ContainerSolarGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"))); - } + { + super(new ContainerSolarGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"))); + } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), !tileEntity.fullName.contains("Advanced") ? 45 : 30, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.solarGenerator.sun") + ": " + tileEntity.seesSun, 51, 35, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); - - if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) + + fontRenderer.drawString(tileEntity.getInvName(), !tileEntity.fullName.contains("Advanced") ? 45 : 30, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.solarGenerator.sun") + ": " + tileEntity.seesSun, 51, 35, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); + + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - - drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.seesSun ? 52 : 64), 12, 12); - } + + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + + drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.seesSun ? 52 : 64), 12, 12); + } } diff --git a/common/mekanism/generators/client/gui/GuiWindTurbine.java b/common/mekanism/generators/client/gui/GuiWindTurbine.java index 8700b7a14..d25324c3c 100644 --- a/common/mekanism/generators/client/gui/GuiWindTurbine.java +++ b/common/mekanism/generators/client/gui/GuiWindTurbine.java @@ -19,61 +19,61 @@ import cpw.mods.fml.relauncher.SideOnly; public class GuiWindTurbine extends GuiMekanism { public TileEntityWindTurbine tileEntity; - + public GuiWindTurbine(InventoryPlayer inventory, TileEntityWindTurbine tentity) - { - super(new ContainerWindTurbine(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"))); - } + { + super(new ContainerWindTurbine(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"))); + } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { + { super.drawGuiContainerForegroundLayer(mouseX, mouseY); - + int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); - fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.power") + ": " + MekanismGenerators.windGeneration*tileEntity.getMultiplier(), 51, 35, 0x00CD00); - fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); - - int size = 44; - - if(!tileEntity.worldObj.canBlockSeeTheSky(tileEntity.xCoord, tileEntity.yCoord+4, tileEntity.zCoord)) - { - size += 9; - fontRenderer.drawString(EnumColor.DARK_RED + "Sky blocked", 51, size, 0x00CD00); - } - - if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) + + fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.power") + ": " + MekanismGenerators.windGeneration*tileEntity.getMultiplier(), 51, 35, 0x00CD00); + fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); + + int size = 44; + + if(!tileEntity.worldObj.canBlockSeeTheSky(tileEntity.xCoord, tileEntity.yCoord+4, tileEntity.zCoord)) + { + size += 9; + fontRenderer.drawString(EnumColor.DARK_RED + "Sky blocked", 51, size, 0x00CD00); + } + + if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); } - } + } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; - - int displayInt; - - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); - - drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.getVolumeMultiplier() > 0 ? 52 : 64), 12, 12); - } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + + drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.getVolumeMultiplier() > 0 ? 52 : 64), 12, 12); + } } diff --git a/common/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java b/common/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java index 8aa049e7c..107882f0c 100644 --- a/common/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java +++ b/common/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java @@ -286,7 +286,7 @@ public class ModelAdvancedSolarGenerator extends ModelBase Panel10.render(size); Panel11.render(size); Panel12.render(size); - + MekanismRenderer.glowOn(); Inputlight.render(size); light1.render(size); diff --git a/common/mekanism/generators/client/model/ModelBioGenerator.java b/common/mekanism/generators/client/model/ModelBioGenerator.java index ffcd52001..019b2aa54 100644 --- a/common/mekanism/generators/client/model/ModelBioGenerator.java +++ b/common/mekanism/generators/client/model/ModelBioGenerator.java @@ -3,7 +3,7 @@ package mekanism.generators.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelBioGenerator extends ModelBase +public class ModelBioGenerator extends ModelBase { ModelRenderer Base; ModelRenderer Pipe1; @@ -23,7 +23,7 @@ public class ModelBioGenerator extends ModelBase ModelRenderer RightPanel; ModelRenderer BackPanel; - public ModelBioGenerator() + public ModelBioGenerator() { textureWidth = 64; textureHeight = 64; @@ -153,7 +153,7 @@ public class ModelBioGenerator extends ModelBase BackPanel.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/generators/client/model/ModelHeatGenerator.java b/common/mekanism/generators/client/model/ModelHeatGenerator.java index 546004509..52091620e 100644 --- a/common/mekanism/generators/client/model/ModelHeatGenerator.java +++ b/common/mekanism/generators/client/model/ModelHeatGenerator.java @@ -9,142 +9,142 @@ import net.minecraft.entity.Entity; @SideOnly(Side.CLIENT) public class ModelHeatGenerator extends ModelBase { - ModelRenderer A; - ModelRenderer B; - ModelRenderer C; - ModelRenderer D; - ModelRenderer E; - ModelRenderer F; - ModelRenderer G; - ModelRenderer H; - ModelRenderer I; - ModelRenderer J; - ModelRenderer K; - ModelRenderer L; - ModelRenderer M; - ModelRenderer N; - ModelRenderer O; - - public ModelHeatGenerator() - { - textureWidth = 128; - textureHeight = 128; - - A = new ModelRenderer(this, 0, 0); - A.addBox(-8F, 0F, -8F, 16, 1, 16); - A.setRotationPoint(0F, 23F, 0F); - A.setTextureSize(128, 128); - A.mirror = true; - setRotation(A, 0F, 0F, 0F); - B = new ModelRenderer(this, 0, 85); - B.addBox(0F, 0F, 0F, 8, 6, 10); - B.setRotationPoint(-8F, 17F, -5F); - B.setTextureSize(128, 128); - B.mirror = true; - setRotation(B, 0F, 0F, 0F); - C = new ModelRenderer(this, 0, 67); - C.addBox(-1F, -2F, 0F, 2, 4, 12); - C.setRotationPoint(-5F, 20F, -6F); - C.setTextureSize(128, 128); - C.mirror = true; - setRotation(C, 0F, 0F, 1.570796F); - D = new ModelRenderer(this, 0, 67); - D.addBox(-1F, -2F, 0F, 2, 4, 12); - D.setRotationPoint(-5F, 20F, -6F); - D.setTextureSize(128, 128); - D.mirror = true; - setRotation(D, 0F, 0F, 0.5235988F); - E = new ModelRenderer(this, 0, 67); - E.addBox(-1F, -2F, 0F, 2, 4, 12); - E.setRotationPoint(-5F, 20F, -6F); - E.setTextureSize(128, 128); - E.mirror = true; - setRotation(E, 0F, 0F, -0.5235988F); - F = new ModelRenderer(this, 68, 0); - F.addBox(-2F, -4F, 0F, 4, 8, 10); - F.setRotationPoint(-4F, 13F, -5F); - F.setTextureSize(128, 128); - F.mirror = true; - setRotation(F, 0F, 0F, 0.5235988F); - G = new ModelRenderer(this, 68, 0); - G.addBox(-2F, -4F, 0F, 4, 8, 10); - G.setRotationPoint(-4F, 13F, -5F); - G.setTextureSize(128, 128); - G.mirror = true; - setRotation(G, 0F, 0F, -0.5235988F); - H = new ModelRenderer(this, 68, 0); - H.addBox(-2F, -4F, 0F, 4, 8, 10); - H.setRotationPoint(-4F, 13F, -5F); - H.setTextureSize(128, 128); - H.mirror = true; - setRotation(H, 0F, 0F, 1.570796F); - I = new ModelRenderer(this, 0, 18); - I.addBox(0F, 0F, 0F, 8, 13, 14); - I.setRotationPoint(0F, 10F, -6F); - I.setTextureSize(128, 128); - I.mirror = true; - setRotation(I, 0F, 0F, 0F); - J = new ModelRenderer(this, 0, 47); - J.addBox(0F, 0F, 0F, 6, 11, 1); - J.setRotationPoint(1F, 11F, -7F); - J.setTextureSize(128, 128); - J.mirror = true; - setRotation(J, 0F, 0F, 0F); - K = new ModelRenderer(this, 51, 21); - K.addBox(0F, 0F, 0F, 10, 4, 1); - K.setRotationPoint(-8F, 13F, -4F); - K.setTextureSize(128, 128); - K.mirror = true; - setRotation(K, 0F, 0F, 0F); - L = new ModelRenderer(this, 51, 21); - L.addBox(0F, 0F, 0F, 10, 4, 1); - L.setRotationPoint(-8F, 13F, 3F); - L.setTextureSize(128, 128); - L.mirror = true; - setRotation(L, 0F, 0F, 0F); - M = new ModelRenderer(this, 0, 103); - M.addBox(0F, 0F, 0F, 2, 4, 2); - M.setRotationPoint(-2F, 19F, -7F); - M.setTextureSize(128, 128); - M.mirror = true; - setRotation(M, 0F, 0F, 0F); - N = new ModelRenderer(this, 51, 0); - N.addBox(0F, 0F, 0F, 6, 1, 1); - N.setRotationPoint(-3F, 9F, 0F); - N.setTextureSize(128, 128); - N.mirror = true; - setRotation(N, 0F, 0F, 0F); - O = new ModelRenderer(this, 51, 0); - O.addBox(0F, 0F, 0F, 6, 1, 1); - O.setRotationPoint(-3F, 9F, 2F); - O.setTextureSize(128, 128); - O.mirror = true; - setRotation(O, 0F, 0F, 0F); - } - - public void render(float size) - { - A.render(size); - B.render(size); - C.render(size); - D.render(size); - E.render(size); - F.render(size); - G.render(size); - H.render(size); - I.render(size); - J.render(size); - K.render(size); - L.render(size); - M.render(size); - N.render(size); - O.render(size); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + ModelRenderer A; + ModelRenderer B; + ModelRenderer C; + ModelRenderer D; + ModelRenderer E; + ModelRenderer F; + ModelRenderer G; + ModelRenderer H; + ModelRenderer I; + ModelRenderer J; + ModelRenderer K; + ModelRenderer L; + ModelRenderer M; + ModelRenderer N; + ModelRenderer O; + + public ModelHeatGenerator() + { + textureWidth = 128; + textureHeight = 128; + + A = new ModelRenderer(this, 0, 0); + A.addBox(-8F, 0F, -8F, 16, 1, 16); + A.setRotationPoint(0F, 23F, 0F); + A.setTextureSize(128, 128); + A.mirror = true; + setRotation(A, 0F, 0F, 0F); + B = new ModelRenderer(this, 0, 85); + B.addBox(0F, 0F, 0F, 8, 6, 10); + B.setRotationPoint(-8F, 17F, -5F); + B.setTextureSize(128, 128); + B.mirror = true; + setRotation(B, 0F, 0F, 0F); + C = new ModelRenderer(this, 0, 67); + C.addBox(-1F, -2F, 0F, 2, 4, 12); + C.setRotationPoint(-5F, 20F, -6F); + C.setTextureSize(128, 128); + C.mirror = true; + setRotation(C, 0F, 0F, 1.570796F); + D = new ModelRenderer(this, 0, 67); + D.addBox(-1F, -2F, 0F, 2, 4, 12); + D.setRotationPoint(-5F, 20F, -6F); + D.setTextureSize(128, 128); + D.mirror = true; + setRotation(D, 0F, 0F, 0.5235988F); + E = new ModelRenderer(this, 0, 67); + E.addBox(-1F, -2F, 0F, 2, 4, 12); + E.setRotationPoint(-5F, 20F, -6F); + E.setTextureSize(128, 128); + E.mirror = true; + setRotation(E, 0F, 0F, -0.5235988F); + F = new ModelRenderer(this, 68, 0); + F.addBox(-2F, -4F, 0F, 4, 8, 10); + F.setRotationPoint(-4F, 13F, -5F); + F.setTextureSize(128, 128); + F.mirror = true; + setRotation(F, 0F, 0F, 0.5235988F); + G = new ModelRenderer(this, 68, 0); + G.addBox(-2F, -4F, 0F, 4, 8, 10); + G.setRotationPoint(-4F, 13F, -5F); + G.setTextureSize(128, 128); + G.mirror = true; + setRotation(G, 0F, 0F, -0.5235988F); + H = new ModelRenderer(this, 68, 0); + H.addBox(-2F, -4F, 0F, 4, 8, 10); + H.setRotationPoint(-4F, 13F, -5F); + H.setTextureSize(128, 128); + H.mirror = true; + setRotation(H, 0F, 0F, 1.570796F); + I = new ModelRenderer(this, 0, 18); + I.addBox(0F, 0F, 0F, 8, 13, 14); + I.setRotationPoint(0F, 10F, -6F); + I.setTextureSize(128, 128); + I.mirror = true; + setRotation(I, 0F, 0F, 0F); + J = new ModelRenderer(this, 0, 47); + J.addBox(0F, 0F, 0F, 6, 11, 1); + J.setRotationPoint(1F, 11F, -7F); + J.setTextureSize(128, 128); + J.mirror = true; + setRotation(J, 0F, 0F, 0F); + K = new ModelRenderer(this, 51, 21); + K.addBox(0F, 0F, 0F, 10, 4, 1); + K.setRotationPoint(-8F, 13F, -4F); + K.setTextureSize(128, 128); + K.mirror = true; + setRotation(K, 0F, 0F, 0F); + L = new ModelRenderer(this, 51, 21); + L.addBox(0F, 0F, 0F, 10, 4, 1); + L.setRotationPoint(-8F, 13F, 3F); + L.setTextureSize(128, 128); + L.mirror = true; + setRotation(L, 0F, 0F, 0F); + M = new ModelRenderer(this, 0, 103); + M.addBox(0F, 0F, 0F, 2, 4, 2); + M.setRotationPoint(-2F, 19F, -7F); + M.setTextureSize(128, 128); + M.mirror = true; + setRotation(M, 0F, 0F, 0F); + N = new ModelRenderer(this, 51, 0); + N.addBox(0F, 0F, 0F, 6, 1, 1); + N.setRotationPoint(-3F, 9F, 0F); + N.setTextureSize(128, 128); + N.mirror = true; + setRotation(N, 0F, 0F, 0F); + O = new ModelRenderer(this, 51, 0); + O.addBox(0F, 0F, 0F, 6, 1, 1); + O.setRotationPoint(-3F, 9F, 2F); + O.setTextureSize(128, 128); + O.mirror = true; + setRotation(O, 0F, 0F, 0F); + } + + public void render(float size) + { + A.render(size); + B.render(size); + C.render(size); + D.render(size); + E.render(size); + F.render(size); + G.render(size); + H.render(size); + I.render(size); + J.render(size); + K.render(size); + L.render(size); + M.render(size); + N.render(size); + O.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/common/mekanism/generators/client/model/ModelHydrogenGenerator.java b/common/mekanism/generators/client/model/ModelHydrogenGenerator.java index 49082aa73..23db6d443 100644 --- a/common/mekanism/generators/client/model/ModelHydrogenGenerator.java +++ b/common/mekanism/generators/client/model/ModelHydrogenGenerator.java @@ -9,174 +9,174 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelHydrogenGenerator extends ModelBase { - ModelRenderer A; - ModelRenderer B; - ModelRenderer C; - ModelRenderer D; - ModelRenderer E; - ModelRenderer F; - ModelRenderer G; - ModelRenderer H; - ModelRenderer I; - ModelRenderer J; - ModelRenderer K; - ModelRenderer L; - ModelRenderer M; - ModelRenderer N; - ModelRenderer O; - ModelRenderer P; - ModelRenderer Q; - ModelRenderer R; - ModelRenderer S; - - public ModelHydrogenGenerator() - { - textureWidth = 128; - textureHeight = 128; - - A = new ModelRenderer(this, 0, 0); - A.addBox(0F, 0F, 0F, 16, 1, 16); - A.setRotationPoint(-8F, 23F, -8F); - A.setTextureSize(128, 128); - A.mirror = true; - setRotation(A, 0F, 0F, 0F); - B = new ModelRenderer(this, 0, 45); - B.addBox(0F, 0F, 0F, 16, 12, 6); - B.setRotationPoint(-8F, 11F, -3F); - B.setTextureSize(128, 128); - B.mirror = true; - setRotation(B, 0F, 0F, 0F); - C = new ModelRenderer(this, 0, 64); - C.addBox(-3F, 0F, -8F, 6, 12, 12); - C.setRotationPoint(0F, 11F, 0F); - C.setTextureSize(128, 128); - C.mirror = true; - setRotation(C, 0F, 0F, 0F); - D = new ModelRenderer(this, 66, 0); - D.addBox(-3F, 0F, 0F, 6, 10, 4); - D.setRotationPoint(0F, 13F, 4F); - D.setTextureSize(128, 128); - D.mirror = true; - setRotation(D, 0F, 0F, 0F); - E = new ModelRenderer(this, 0, 20); - E.addBox(-5F, 0F, -3F, 10, 13, 6); - E.setRotationPoint(0F, 10F, 0F); - E.setTextureSize(128, 128); - E.mirror = true; - setRotation(E, 0F, 0.5235988F, 0F); - F = new ModelRenderer(this, 0, 20); - F.addBox(-5F, 0F, -3F, 10, 13, 6); - F.setRotationPoint(0F, 10F, 0F); - F.setTextureSize(128, 128); - F.mirror = true; - setRotation(F, 0F, -0.5235988F, 0F); - G = new ModelRenderer(this, 34, 20); - G.addBox(-3F, 0F, -5F, 6, 13, 10); - G.setRotationPoint(0F, 10F, 0F); - G.setTextureSize(128, 128); - G.mirror = true; - setRotation(G, 0F, 0F, 0F); - H = new ModelRenderer(this, 67, 20); - H.addBox(-2F, 0F, -1F, 4, 2, 2); - H.setRotationPoint(0F, 8F, 0F); - H.setTextureSize(128, 128); - H.mirror = true; - setRotation(H, 0F, -0.5235988F, 0F); - I = new ModelRenderer(this, 67, 20); - I.addBox(-2F, 0F, -1F, 4, 2, 2); - I.setRotationPoint(0F, 8F, 0F); - I.setTextureSize(128, 128); - I.mirror = true; - setRotation(I, 0F, 0.5235988F, 0F); - J = new ModelRenderer(this, 67, 26); - J.addBox(-1F, 0F, -2F, 2, 2, 4); - J.setRotationPoint(0F, 8F, 0F); - J.setTextureSize(128, 128); - J.mirror = true; - setRotation(J, 0F, 0F, 0F); - K = new ModelRenderer(this, 88, 0); - K.addBox(-3F, 0F, 0F, 6, 2, 5); - K.setRotationPoint(0F, 10F, 4F); - K.setTextureSize(128, 128); - K.mirror = true; - setRotation(K, -0.6457718F, 0F, 0F); - L = new ModelRenderer(this, 0, 97); - L.addBox(0F, 0F, 0F, 4, 10, 4); - L.setRotationPoint(2F, 13F, -5F); - L.setTextureSize(128, 128); - L.mirror = true; - setRotation(L, 0F, 0.7853982F, 0F); - M = new ModelRenderer(this, 0, 90); - M.addBox(0F, 0F, 0F, 3, 1, 2); - M.setRotationPoint(2F, 12F, -4F); - M.setTextureSize(128, 128); - M.mirror = true; - setRotation(M, 0F, 0.7853982F, 0F); - N = new ModelRenderer(this, 0, 97); - N.addBox(0F, 0F, 0F, 4, 10, 4); - N.setRotationPoint(-8F, 13F, -5F); - N.setTextureSize(128, 128); - N.mirror = true; - setRotation(N, 0F, 0.7853982F, 0F); - O = new ModelRenderer(this, 0, 90); - O.addBox(0F, 0F, 0F, 2, 1, 3); - O.setRotationPoint(-6F, 12F, -5F); - O.setTextureSize(128, 128); - O.mirror = true; - setRotation(O, 0F, 0.7853982F, 0F); - P = new ModelRenderer(this, 0, 118); - P.addBox(-5F, 0F, 0F, 10, 1, 1); - P.setRotationPoint(0F, 15F, -7F); - P.setTextureSize(128, 128); - P.mirror = true; - setRotation(P, 0F, 0F, 0F); - Q = new ModelRenderer(this, 0, 118); - Q.addBox(-5F, 0F, 0F, 10, 1, 1); - Q.setRotationPoint(0F, 19F, -7F); - Q.setTextureSize(128, 128); - Q.mirror = true; - setRotation(Q, 0F, 0F, 0F); - R = new ModelRenderer(this, 0, 112); - R.addBox(-7F, 0F, -3F, 14, 1, 3); - R.setRotationPoint(0F, 15F, -2F); - R.setTextureSize(128, 128); - R.mirror = true; - setRotation(R, 0F, 0F, 0F); - S = new ModelRenderer(this, 0, 112); - S.addBox(-7F, 0F, -3F, 14, 1, 3); - S.setRotationPoint(0F, 19F, -2F); - S.setTextureSize(128, 128); - S.mirror = true; - setRotation(S, 0F, 0F, 0F); - } - - public void render(float size) - { - A.render(size); - B.render(size); - C.render(size); - D.render(size); - E.render(size); - F.render(size); - G.render(size); - H.render(size); - I.render(size); - J.render(size); - K.render(size); - L.render(size); - M.render(size); - N.render(size); - O.render(size); - P.render(size); - Q.render(size); - R.render(size); - S.render(size); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + ModelRenderer A; + ModelRenderer B; + ModelRenderer C; + ModelRenderer D; + ModelRenderer E; + ModelRenderer F; + ModelRenderer G; + ModelRenderer H; + ModelRenderer I; + ModelRenderer J; + ModelRenderer K; + ModelRenderer L; + ModelRenderer M; + ModelRenderer N; + ModelRenderer O; + ModelRenderer P; + ModelRenderer Q; + ModelRenderer R; + ModelRenderer S; + + public ModelHydrogenGenerator() + { + textureWidth = 128; + textureHeight = 128; + + A = new ModelRenderer(this, 0, 0); + A.addBox(0F, 0F, 0F, 16, 1, 16); + A.setRotationPoint(-8F, 23F, -8F); + A.setTextureSize(128, 128); + A.mirror = true; + setRotation(A, 0F, 0F, 0F); + B = new ModelRenderer(this, 0, 45); + B.addBox(0F, 0F, 0F, 16, 12, 6); + B.setRotationPoint(-8F, 11F, -3F); + B.setTextureSize(128, 128); + B.mirror = true; + setRotation(B, 0F, 0F, 0F); + C = new ModelRenderer(this, 0, 64); + C.addBox(-3F, 0F, -8F, 6, 12, 12); + C.setRotationPoint(0F, 11F, 0F); + C.setTextureSize(128, 128); + C.mirror = true; + setRotation(C, 0F, 0F, 0F); + D = new ModelRenderer(this, 66, 0); + D.addBox(-3F, 0F, 0F, 6, 10, 4); + D.setRotationPoint(0F, 13F, 4F); + D.setTextureSize(128, 128); + D.mirror = true; + setRotation(D, 0F, 0F, 0F); + E = new ModelRenderer(this, 0, 20); + E.addBox(-5F, 0F, -3F, 10, 13, 6); + E.setRotationPoint(0F, 10F, 0F); + E.setTextureSize(128, 128); + E.mirror = true; + setRotation(E, 0F, 0.5235988F, 0F); + F = new ModelRenderer(this, 0, 20); + F.addBox(-5F, 0F, -3F, 10, 13, 6); + F.setRotationPoint(0F, 10F, 0F); + F.setTextureSize(128, 128); + F.mirror = true; + setRotation(F, 0F, -0.5235988F, 0F); + G = new ModelRenderer(this, 34, 20); + G.addBox(-3F, 0F, -5F, 6, 13, 10); + G.setRotationPoint(0F, 10F, 0F); + G.setTextureSize(128, 128); + G.mirror = true; + setRotation(G, 0F, 0F, 0F); + H = new ModelRenderer(this, 67, 20); + H.addBox(-2F, 0F, -1F, 4, 2, 2); + H.setRotationPoint(0F, 8F, 0F); + H.setTextureSize(128, 128); + H.mirror = true; + setRotation(H, 0F, -0.5235988F, 0F); + I = new ModelRenderer(this, 67, 20); + I.addBox(-2F, 0F, -1F, 4, 2, 2); + I.setRotationPoint(0F, 8F, 0F); + I.setTextureSize(128, 128); + I.mirror = true; + setRotation(I, 0F, 0.5235988F, 0F); + J = new ModelRenderer(this, 67, 26); + J.addBox(-1F, 0F, -2F, 2, 2, 4); + J.setRotationPoint(0F, 8F, 0F); + J.setTextureSize(128, 128); + J.mirror = true; + setRotation(J, 0F, 0F, 0F); + K = new ModelRenderer(this, 88, 0); + K.addBox(-3F, 0F, 0F, 6, 2, 5); + K.setRotationPoint(0F, 10F, 4F); + K.setTextureSize(128, 128); + K.mirror = true; + setRotation(K, -0.6457718F, 0F, 0F); + L = new ModelRenderer(this, 0, 97); + L.addBox(0F, 0F, 0F, 4, 10, 4); + L.setRotationPoint(2F, 13F, -5F); + L.setTextureSize(128, 128); + L.mirror = true; + setRotation(L, 0F, 0.7853982F, 0F); + M = new ModelRenderer(this, 0, 90); + M.addBox(0F, 0F, 0F, 3, 1, 2); + M.setRotationPoint(2F, 12F, -4F); + M.setTextureSize(128, 128); + M.mirror = true; + setRotation(M, 0F, 0.7853982F, 0F); + N = new ModelRenderer(this, 0, 97); + N.addBox(0F, 0F, 0F, 4, 10, 4); + N.setRotationPoint(-8F, 13F, -5F); + N.setTextureSize(128, 128); + N.mirror = true; + setRotation(N, 0F, 0.7853982F, 0F); + O = new ModelRenderer(this, 0, 90); + O.addBox(0F, 0F, 0F, 2, 1, 3); + O.setRotationPoint(-6F, 12F, -5F); + O.setTextureSize(128, 128); + O.mirror = true; + setRotation(O, 0F, 0.7853982F, 0F); + P = new ModelRenderer(this, 0, 118); + P.addBox(-5F, 0F, 0F, 10, 1, 1); + P.setRotationPoint(0F, 15F, -7F); + P.setTextureSize(128, 128); + P.mirror = true; + setRotation(P, 0F, 0F, 0F); + Q = new ModelRenderer(this, 0, 118); + Q.addBox(-5F, 0F, 0F, 10, 1, 1); + Q.setRotationPoint(0F, 19F, -7F); + Q.setTextureSize(128, 128); + Q.mirror = true; + setRotation(Q, 0F, 0F, 0F); + R = new ModelRenderer(this, 0, 112); + R.addBox(-7F, 0F, -3F, 14, 1, 3); + R.setRotationPoint(0F, 15F, -2F); + R.setTextureSize(128, 128); + R.mirror = true; + setRotation(R, 0F, 0F, 0F); + S = new ModelRenderer(this, 0, 112); + S.addBox(-7F, 0F, -3F, 14, 1, 3); + S.setRotationPoint(0F, 19F, -2F); + S.setTextureSize(128, 128); + S.mirror = true; + setRotation(S, 0F, 0F, 0F); + } + + public void render(float size) + { + A.render(size); + B.render(size); + C.render(size); + D.render(size); + E.render(size); + F.render(size); + G.render(size); + H.render(size); + I.render(size); + J.render(size); + K.render(size); + L.render(size); + M.render(size); + N.render(size); + O.render(size); + P.render(size); + Q.render(size); + R.render(size); + S.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/common/mekanism/generators/client/model/ModelSolarGenerator.java b/common/mekanism/generators/client/model/ModelSolarGenerator.java index 24a7a9472..a45c61326 100644 --- a/common/mekanism/generators/client/model/ModelSolarGenerator.java +++ b/common/mekanism/generators/client/model/ModelSolarGenerator.java @@ -4,14 +4,14 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelSolarGenerator extends ModelBase +public class ModelSolarGenerator extends ModelBase { ModelRenderer Base; ModelRenderer Base2; ModelRenderer Stand; ModelRenderer PhotovoltaicCells; - public ModelSolarGenerator() + public ModelSolarGenerator() { textureWidth = 64; textureHeight = 32; @@ -41,7 +41,7 @@ public class ModelSolarGenerator extends ModelBase PhotovoltaicCells.mirror = true; setRotation(PhotovoltaicCells, 0F, 0F, 0F); } - + public void render(float size) { Base.render(size); @@ -50,7 +50,7 @@ public class ModelSolarGenerator extends ModelBase PhotovoltaicCells.render(size); } - private void setRotation(ModelRenderer model, float x, float y, float z) + private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; diff --git a/common/mekanism/generators/client/model/ModelWindTurbine.java b/common/mekanism/generators/client/model/ModelWindTurbine.java index a79c82948..a621e4f23 100644 --- a/common/mekanism/generators/client/model/ModelWindTurbine.java +++ b/common/mekanism/generators/client/model/ModelWindTurbine.java @@ -4,7 +4,7 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; -public class ModelWindTurbine extends ModelBase +public class ModelWindTurbine extends ModelBase { ModelRenderer Base; ModelRenderer TowerFront; @@ -21,7 +21,7 @@ public class ModelWindTurbine extends ModelBase ModelRenderer BladeBaseB; ModelRenderer BladeBaseA; - public ModelWindTurbine() + public ModelWindTurbine() { textureWidth = 128; textureHeight = 64; @@ -111,7 +111,7 @@ public class ModelWindTurbine extends ModelBase BladeBaseA.mirror = true; setRotation(BladeBaseA, 0F, 0F, getRotation(240)); } - + public void render(float size, int angle) { Base.render(size); @@ -132,12 +132,12 @@ public class ModelWindTurbine extends ModelBase setRotation(BladeBaseA, 0.0F, 0.0F, getRotation(getAbsoluteAngle(240 + angle))); BladeBaseA.render(size); } - + public float getRotation(int angle) { return ((float)angle/(float)180)*(float)Math.PI; } - + public int getAbsoluteAngle(int angle) { return angle % 360; diff --git a/common/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java b/common/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java index bd91167ac..036cd9aff 100644 --- a/common/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java +++ b/common/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java @@ -16,7 +16,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderAdvancedSolarGenerator extends TileEntitySpecialRenderer { private ModelAdvancedSolarGenerator model = new ModelAdvancedSolarGenerator(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { @@ -24,22 +24,22 @@ public class RenderAdvancedSolarGenerator extends TileEntitySpecialRenderer } private void renderAModelAt(TileEntityAdvancedSolarGenerator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png")); + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - } - - GL11.glRotatef(180, 0F, 0F, 1F); - - model.render(0.0625F); - GL11.glPopMatrix(); + } + + GL11.glRotatef(180, 0F, 0F, 1F); + + model.render(0.0625F); + GL11.glPopMatrix(); } } diff --git a/common/mekanism/generators/client/render/RenderBioGenerator.java b/common/mekanism/generators/client/render/RenderBioGenerator.java index 1da931647..823f4b91d 100644 --- a/common/mekanism/generators/client/render/RenderBioGenerator.java +++ b/common/mekanism/generators/client/render/RenderBioGenerator.java @@ -25,49 +25,49 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderBioGenerator extends TileEntitySpecialRenderer { private ModelBioGenerator model = new ModelBioGenerator(); - + private Map energyDisplays = new HashMap(); - + private static final int stages = 40; - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityBioGenerator)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityBioGenerator tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180, 0F, 0F, 1F); model.render(0.0625F); GL11.glPopMatrix(); - + if(tileEntity.bioFuelSlot.fluidStored > 0) { push(); - + MekanismRenderer.glowOn(); GL11.glTranslatef((float)x, (float)y, (float)z); bindTexture(MekanismRenderer.getBlocksTexture()); getDisplayList(ForgeDirection.getOrientation(tileEntity.facing))[tileEntity.getScaledFuelLevel(stages-1)].render(); MekanismRenderer.glowOff(); - + pop(); } } - + @SuppressWarnings("incomplete-switch") private DisplayInteger[] getDisplayList(ForgeDirection side) { @@ -75,24 +75,24 @@ public class RenderBioGenerator extends TileEntitySpecialRenderer { return energyDisplays.get(side); } - + DisplayInteger[] displays = new DisplayInteger[stages]; - + Model3D model3D = new Model3D(); model3D.baseBlock = Block.waterStill; model3D.setTexture(MekanismRenderer.energyIcon); - + for(int i = 0; i < stages; i++) { displays[i] = DisplayInteger.createAndStart(); - + switch(side) { case NORTH: { model3D.minZ = 0.1875; model3D.maxZ = 0.4375; - + model3D.minX = 0.375; model3D.maxX = 0.625; model3D.minY = 0.125; @@ -103,7 +103,7 @@ public class RenderBioGenerator extends TileEntitySpecialRenderer { model3D.minZ = 0.5625; model3D.maxZ = 0.8125; - + model3D.minX = 0.375; model3D.maxX = 0.625; model3D.minY = 0.125; @@ -114,7 +114,7 @@ public class RenderBioGenerator extends TileEntitySpecialRenderer { model3D.minX = 0.1875; model3D.maxX = 0.4375; - + model3D.minZ = 0.375; model3D.maxZ = 0.625; model3D.minY = 0.125; @@ -125,7 +125,7 @@ public class RenderBioGenerator extends TileEntitySpecialRenderer { model3D.minX = 0.5625; model3D.maxX = 0.8125; - + model3D.minZ = 0.375; model3D.maxZ = 0.625; model3D.minY = 0.125; @@ -133,22 +133,22 @@ public class RenderBioGenerator extends TileEntitySpecialRenderer break; } } - + MekanismRenderer.renderObject(model3D); displays[i].endList(); } - + energyDisplays.put(side, displays); - + return displays; } - + private void pop() { GL11.glPopAttrib(); GL11.glPopMatrix(); } - + private void push() { GL11.glPushMatrix(); diff --git a/common/mekanism/generators/client/render/RenderHeatGenerator.java b/common/mekanism/generators/client/render/RenderHeatGenerator.java index 815a79231..af366eec4 100644 --- a/common/mekanism/generators/client/render/RenderHeatGenerator.java +++ b/common/mekanism/generators/client/render/RenderHeatGenerator.java @@ -16,27 +16,27 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderHeatGenerator extends TileEntitySpecialRenderer { private ModelHeatGenerator model = new ModelHeatGenerator(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityHeatGenerator)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityHeatGenerator tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, tileEntity.isActive ? "HeatGeneratorOn.png" : "HeatGenerator.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/generators/client/render/RenderHydrogenGenerator.java b/common/mekanism/generators/client/render/RenderHydrogenGenerator.java index 33cd02727..55b774665 100644 --- a/common/mekanism/generators/client/render/RenderHydrogenGenerator.java +++ b/common/mekanism/generators/client/render/RenderHydrogenGenerator.java @@ -16,27 +16,27 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderHydrogenGenerator extends TileEntitySpecialRenderer { private ModelHydrogenGenerator model = new ModelHydrogenGenerator(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntityHydrogenGenerator)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntityHydrogenGenerator tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HydrogenGenerator.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - } - + } + GL11.glRotatef(180F, 0.0F, 1.0F, 1.0F); GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); diff --git a/common/mekanism/generators/client/render/RenderSolarGenerator.java b/common/mekanism/generators/client/render/RenderSolarGenerator.java index a3b833c47..e4c90d06f 100644 --- a/common/mekanism/generators/client/render/RenderSolarGenerator.java +++ b/common/mekanism/generators/client/render/RenderSolarGenerator.java @@ -12,20 +12,20 @@ import org.lwjgl.opengl.GL11; public class RenderSolarGenerator extends TileEntitySpecialRenderer { private ModelSolarGenerator model = new ModelSolarGenerator(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { renderAModelAt((TileEntitySolarGenerator)tileEntity, x, y, z, partialTick); } - + private void renderAModelAt(TileEntitySolarGenerator tileEntity, double x, double y, double z, float partialTick) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png")); - + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); model.render(0.0625F); GL11.glPopMatrix(); diff --git a/common/mekanism/generators/client/render/RenderWindTurbine.java b/common/mekanism/generators/client/render/RenderWindTurbine.java index 64f19e842..dd17f34c5 100644 --- a/common/mekanism/generators/client/render/RenderWindTurbine.java +++ b/common/mekanism/generators/client/render/RenderWindTurbine.java @@ -13,7 +13,7 @@ import org.lwjgl.opengl.GL11; public class RenderWindTurbine extends TileEntitySpecialRenderer { private ModelWindTurbine model = new ModelWindTurbine(); - + @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) { @@ -21,28 +21,28 @@ public class RenderWindTurbine extends TileEntitySpecialRenderer } private void renderAModelAt(TileEntityWindTurbine tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindTurbine.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindTurbine.png")); + + switch(tileEntity.facing) + { + case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - - GL11.glRotatef(180, 0F, 0F, 1F); - - if(!Mekanism.proxy.isPaused() && - tileEntity.worldObj.canBlockSeeTheSky(tileEntity.xCoord, tileEntity.yCoord+4, tileEntity.zCoord)) - { - tileEntity.angle = (tileEntity.angle+((int)tileEntity.getMultiplier())) % 360; - } - - model.render(0.0625F, tileEntity.angle); - GL11.glPopMatrix(); + } + + GL11.glRotatef(180, 0F, 0F, 1F); + + if(!Mekanism.proxy.isPaused() && + tileEntity.worldObj.canBlockSeeTheSky(tileEntity.xCoord, tileEntity.yCoord+4, tileEntity.zCoord)) + { + tileEntity.angle = (tileEntity.angle+((int)tileEntity.getMultiplier())) % 360; + } + + model.render(0.0625F, tileEntity.angle); + GL11.glPopMatrix(); } } diff --git a/common/mekanism/generators/common/GeneratorsCommonProxy.java b/common/mekanism/generators/common/GeneratorsCommonProxy.java index b25ff5298..92a417563 100644 --- a/common/mekanism/generators/common/GeneratorsCommonProxy.java +++ b/common/mekanism/generators/common/GeneratorsCommonProxy.java @@ -19,7 +19,7 @@ public class GeneratorsCommonProxy /** * Register tile entities that have special models. Overwritten in client to register TESRs. */ - public void registerSpecialTileEntities() + public void registerSpecialTileEntities() { GameRegistry.registerTileEntity(TileEntityAdvancedSolarGenerator.class, "AdvancedSolarGenerator"); GameRegistry.registerTileEntity(TileEntitySolarGenerator.class, "SolarGenerator"); @@ -28,28 +28,28 @@ public class GeneratorsCommonProxy GameRegistry.registerTileEntity(TileEntityHydrogenGenerator.class, "HydrogenGenerator"); GameRegistry.registerTileEntity(TileEntityWindTurbine.class, "WindTurbine"); } - + /** * Register and load client-only render information. */ public void registerRenderInformation() {} - + /** * Set and load the mod's common configuration properties. */ public void loadConfiguration() { Mekanism.configuration.load(); - MekanismGenerators.generatorID = Mekanism.configuration.getBlock("Generator", 3010).getInt(); - MekanismGenerators.advancedSolarGeneration = Mekanism.configuration.get("generation", "AdvancedSolarGeneration", 400D).getDouble(400D); - MekanismGenerators.bioGeneration = Mekanism.configuration.get("generation", "BioGeneration", 250D).getDouble(250D); - MekanismGenerators.heatGeneration = Mekanism.configuration.get("generation", "HeatGeneration", 150D).getDouble(150D); - MekanismGenerators.hydrogenGeneration = Mekanism.configuration.get("generation", "HydrogenGeneration", 400D).getDouble(400D); - MekanismGenerators.solarGeneration = Mekanism.configuration.get("generation", "SolarGeneration", 50D).getDouble(50D); - MekanismGenerators.windGeneration = Mekanism.configuration.get("generation", "WindGeneration", 100D).getDouble(100D); + MekanismGenerators.generatorID = Mekanism.configuration.getBlock("Generator", 3010).getInt(); + MekanismGenerators.advancedSolarGeneration = Mekanism.configuration.get("generation", "AdvancedSolarGeneration", 400D).getDouble(400D); + MekanismGenerators.bioGeneration = Mekanism.configuration.get("generation", "BioGeneration", 250D).getDouble(250D); + MekanismGenerators.heatGeneration = Mekanism.configuration.get("generation", "HeatGeneration", 150D).getDouble(150D); + MekanismGenerators.hydrogenGeneration = Mekanism.configuration.get("generation", "HydrogenGeneration", 400D).getDouble(400D); + MekanismGenerators.solarGeneration = Mekanism.configuration.get("generation", "SolarGeneration", 50D).getDouble(50D); + MekanismGenerators.windGeneration = Mekanism.configuration.get("generation", "WindGeneration", 100D).getDouble(100D); Mekanism.configuration.save(); } - + /** * Get the actual interface for a GUI. Client-only. * @param ID - gui ID @@ -60,11 +60,11 @@ public class GeneratorsCommonProxy * @param z - gui's z position * @return the GuiScreen of the GUI */ - public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } - + /** * Get the container for a GUI. Common. * @param ID - gui ID @@ -75,10 +75,10 @@ public class GeneratorsCommonProxy * @param z - gui's z position * @return the Container of the GUI */ - public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) + public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + switch(ID) { case 0: diff --git a/common/mekanism/generators/common/GeneratorsGuiHandler.java b/common/mekanism/generators/common/GeneratorsGuiHandler.java index 90bfe620b..52ad81925 100644 --- a/common/mekanism/generators/common/GeneratorsGuiHandler.java +++ b/common/mekanism/generators/common/GeneratorsGuiHandler.java @@ -5,7 +5,7 @@ import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; /** - * Client and server GUI hander for Mekanism. + * Client and server GUI hander for Mekanism. * Uses CommonProxy to get the server GUI and ClientProxy for the client GUI. * @author AidanBrady * @@ -13,13 +13,13 @@ import cpw.mods.fml.common.network.IGuiHandler; public class GeneratorsGuiHandler implements IGuiHandler { @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return MekanismGenerators.proxy.getServerGui(ID, player, world, x, y, z); } @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return MekanismGenerators.proxy.getClientGui(ID, player, world, x, y, z); } diff --git a/common/mekanism/generators/common/MekanismGenerators.java b/common/mekanism/generators/common/MekanismGenerators.java index 784b6821c..1605a9bda 100644 --- a/common/mekanism/generators/common/MekanismGenerators.java +++ b/common/mekanism/generators/common/MekanismGenerators.java @@ -41,23 +41,23 @@ public class MekanismGenerators implements IModule { @SidedProxy(clientSide = "mekanism.generators.client.GeneratorsClientProxy", serverSide = "mekanism.generators.common.GeneratorsCommonProxy") public static GeneratorsCommonProxy proxy; - + @Instance("MekanismGenerators") public static MekanismGenerators instance; - + /** MekanismGenerators version number */ public static Version versionNumber = new Version(6, 0, 3); - + //Items public static Item BioFuel; public static Item SolarPanel; - + //Blocks public static Block Generator; - + //Block IDs public static int generatorID; - + //Generation Configuration public static double advancedSolarGeneration; public static double bioGeneration; @@ -70,32 +70,32 @@ public class MekanismGenerators implements IModule public void preInit(FMLPreInitializationEvent event) { //Register infuses - InfuseRegistry.registerInfuseType(new InfuseType("BIO", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 12, 0).setUnlocalizedName("infuse.bio")); + InfuseRegistry.registerInfuseType(new InfuseType("BIO", MekanismUtils.getResource(ResourceType.INFUSE, "Infusions.png"), 12, 0).setUnlocalizedName("infuse.bio")); } - + @EventHandler public void init(FMLInitializationEvent event) { //Add this module to the core list Mekanism.modulesLoaded.add(this); - + //Set up the GUI handler NetworkRegistry.instance().registerGuiHandler(this, new GeneratorsGuiHandler()); - + //Load the proxy proxy.loadConfiguration(); proxy.registerSpecialTileEntities(); proxy.registerRenderInformation(); - + //Load this module addBlocks(); addItems(); addRecipes(); - + //Finalization Mekanism.logger.info("[MekanismGenerators] Loaded module."); } - + @EventHandler public void postInit(FMLPostInitializationEvent event) { @@ -109,7 +109,7 @@ public class MekanismGenerators implements IModule } } catch(Exception e) {} } - + public void addRecipes() { CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Generator, 1, 0), new Object[] { @@ -133,30 +133,30 @@ public class MekanismGenerators implements IModule CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Generator, 1, 6), new Object[] { " O ", "OAO", "ECE", Character.valueOf('O'), "ingotOsmium", Character.valueOf('A'), Mekanism.EnrichedAlloy, Character.valueOf('E'), Mekanism.EnergyTablet.getUnchargedItem(), Character.valueOf('C'), "circuitBasic" })); - + //BioFuel Crusher Recipes - RecipeHandler.addCrusherRecipe(new ItemStack(Block.tallGrass), new ItemStack(BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.reed), new ItemStack(BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.seeds), new ItemStack(BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.wheat), new ItemStack(BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.pumpkinSeeds), new ItemStack(BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.melonSeeds), new ItemStack(BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.appleRed), new ItemStack(BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.bread), new ItemStack(BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.potato), new ItemStack(BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.carrot), new ItemStack(BioFuel, 4)); - - InfuseRegistry.registerInfuseObject(new ItemStack(BioFuel), new InfuseObject(InfuseRegistry.get("BIO"), 5)); + RecipeHandler.addCrusherRecipe(new ItemStack(Block.tallGrass), new ItemStack(BioFuel, 4)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.reed), new ItemStack(BioFuel, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.seeds), new ItemStack(BioFuel, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.wheat), new ItemStack(BioFuel, 4)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.pumpkinSeeds), new ItemStack(BioFuel, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.melonSeeds), new ItemStack(BioFuel, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.appleRed), new ItemStack(BioFuel, 4)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.bread), new ItemStack(BioFuel, 4)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.potato), new ItemStack(BioFuel, 4)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.carrot), new ItemStack(BioFuel, 4)); + + InfuseRegistry.registerInfuseObject(new ItemStack(BioFuel), new InfuseObject(InfuseRegistry.get("BIO"), 5)); } - + public void addBlocks() { //Declarations Generator = new BlockGenerator(generatorID).setUnlocalizedName("Generator"); - + Item.itemsList[generatorID] = new ItemBlockGenerator(generatorID - 256, Generator).setUnlocalizedName("Generator"); } - + public void addItems() { //Declarations @@ -164,7 +164,7 @@ public class MekanismGenerators implements IModule SolarPanel = new ItemMekanism(Mekanism.configuration.getItem("SolarPanel", 11300).getInt()).setUnlocalizedName("SolarPanel"); BioFuel = new ItemMekanism(Mekanism.configuration.getItem("BioFuel", 11301).getInt()).setUnlocalizedName("BioFuel"); Mekanism.configuration.save(); - + //Registrations GameRegistry.registerItem(SolarPanel, "SolarPanel"); GameRegistry.registerItem(BioFuel, "BioFuel"); @@ -174,7 +174,7 @@ public class MekanismGenerators implements IModule } @Override - public Version getVersion() + public Version getVersion() { return versionNumber; } @@ -184,7 +184,7 @@ public class MekanismGenerators implements IModule { return "Generators"; } - + @Override public void writeConfig(DataOutputStream dataStream) throws IOException { diff --git a/common/mekanism/generators/common/block/BlockGenerator.java b/common/mekanism/generators/common/block/BlockGenerator.java index 348ba868a..7b9d7498d 100644 --- a/common/mekanism/generators/common/block/BlockGenerator.java +++ b/common/mekanism/generators/common/block/BlockGenerator.java @@ -45,7 +45,7 @@ import java.util.Random; public class BlockGenerator extends BlockContainer implements ISpecialBounds { public Random machineRand = new Random(); - + public BlockGenerator(int id) { super(id, Material.iron); @@ -53,70 +53,70 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds setResistance(8F); setCreativeTab(Mekanism.tabMekanism); } - + @Override public void registerIcons(IconRegister register) {} - + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { if(!world.isRemote) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof TileEntityBasicBlock) { ((TileEntityBasicBlock)tileEntity).onNeighborChange(id); } } } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); - int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); - int change = 3; - - if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) - { - if(height >= 65) - { - change = 1; - } - else if(height <= -65) - { - change = 0; - } - } - - if(change != 0 && change != 1) - { - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - } - - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onPlace(); - } - } - + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) + { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getBlockTileEntity(x, y, z); + + int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int height = Math.round(entityliving.rotationPitch); + int change = 3; + + if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) + { + if(height >= 65) + { + change = 1; + } + else if(height <= -65) + { + change = 0; + } + } + + if(change != 0 && change != 1) + { + switch(side) + { + case 0: change = 2; break; + case 1: change = 5; break; + case 2: change = 3; break; + case 3: change = 4; break; + } + } + + tileEntity.setFacing((short)change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + + if(tileEntity instanceof IBoundingBlock) + { + ((IBoundingBlock)tileEntity).onPlace(); + } + } + @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - + if(tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator)) { if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate()) @@ -124,16 +124,16 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds return 15; } } - + return 0; } - + @Override - public int damageDropped(int i) - { - return i; - } - + public int damageDropped(int i) + { + return i; + } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(int i, CreativeTabs creativetabs, List list) @@ -145,94 +145,94 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds list.add(new ItemStack(i, 1, 5)); list.add(new ItemStack(i, 1, 6)); } - - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random random) - { - int metadata = world.getBlockMetadata(x, y, z); - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); - if(MekanismUtils.isActive(world, x, y, z)) - { - float xRandom = (float)x + 0.5F; - float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F; - float zRandom = (float)z + 0.5F; - float iRandom = 0.52F; - float jRandom = random.nextFloat() * 0.6F - 0.3F; - if(tileEntity.facing == 4) - { - switch(GeneratorType.getFromMetadata(metadata)) - { - case HEAT_GENERATOR: - world.spawnParticle("smoke", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); - break; - case BIO_GENERATOR: - world.spawnParticle("smoke", x+.25, y+.2, z+.5, 0.0D, 0.0D, 0.0D); - break; - default: - break; - } - } - else if(tileEntity.facing == 5) - { + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random random) + { + int metadata = world.getBlockMetadata(x, y, z); + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); + if(MekanismUtils.isActive(world, x, y, z)) + { + float xRandom = (float)x + 0.5F; + float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F; + float zRandom = (float)z + 0.5F; + float iRandom = 0.52F; + float jRandom = random.nextFloat() * 0.6F - 0.3F; + + if(tileEntity.facing == 4) + { switch(GeneratorType.getFromMetadata(metadata)) - { - case HEAT_GENERATOR: - world.spawnParticle("smoke", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); - break; - case BIO_GENERATOR: - world.spawnParticle("smoke", x+.75, y+.2, z+.5, 0.0D, 0.0D, 0.0D); - break; - default: - break; - } - } - else if(tileEntity.facing == 2) - { + { + case HEAT_GENERATOR: + world.spawnParticle("smoke", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); + break; + case BIO_GENERATOR: + world.spawnParticle("smoke", x+.25, y+.2, z+.5, 0.0D, 0.0D, 0.0D); + break; + default: + break; + } + } + else if(tileEntity.facing == 5) + { switch(GeneratorType.getFromMetadata(metadata)) - { - case HEAT_GENERATOR: - world.spawnParticle("smoke", (double)(xRandom - jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double)(xRandom - jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D); - break; - case BIO_GENERATOR: - world.spawnParticle("smoke", x+.5, y+.2, z+.25, 0.0D, 0.0D, 0.0D); - break; - default: - break; - } - } - else if(tileEntity.facing == 3) - { + { + case HEAT_GENERATOR: + world.spawnParticle("smoke", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", (double)(xRandom - iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); + break; + case BIO_GENERATOR: + world.spawnParticle("smoke", x+.75, y+.2, z+.5, 0.0D, 0.0D, 0.0D); + break; + default: + break; + } + } + else if(tileEntity.facing == 2) + { switch(GeneratorType.getFromMetadata(metadata)) - { - case HEAT_GENERATOR: - world.spawnParticle("smoke", (double)(xRandom - jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double)(xRandom - jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D); - break; - case BIO_GENERATOR: - world.spawnParticle("smoke", x+.5, y+.2, z+.75, 0.0D, 0.0D, 0.0D); - break; - default: - break; - } - } - } - } - + { + case HEAT_GENERATOR: + world.spawnParticle("smoke", (double)(xRandom - jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", (double)(xRandom - jRandom), (double)yRandom, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D); + break; + case BIO_GENERATOR: + world.spawnParticle("smoke", x+.5, y+.2, z+.25, 0.0D, 0.0D, 0.0D); + break; + default: + break; + } + } + else if(tileEntity.facing == 3) + { + switch(GeneratorType.getFromMetadata(metadata)) + { + case HEAT_GENERATOR: + world.spawnParticle("smoke", (double)(xRandom - jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", (double)(xRandom - jRandom), (double)yRandom, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D); + break; + case BIO_GENERATOR: + world.spawnParticle("smoke", x+.5, y+.2, z+.75, 0.0D, 0.0D, 0.0D); + break; + default: + break; + } + } + } + } + @Override public boolean canPlaceBlockAt(World world, int x, int y, int z) - { + { if(world.getBlockMetadata(x, y, z) == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) { - boolean canPlace = super.canPlaceBlockAt(world, x, y, z); - - int idSum = 0; - idSum += world.getBlockId(x, y, z); - + boolean canPlace = super.canPlaceBlockAt(world, x, y, z); + + int idSum = 0; + idSum += world.getBlockId(x, y, z); + for(int xPos=-1;xPos<=2;xPos++) { for(int zPos=-1;zPos<=2;zPos++) @@ -240,248 +240,248 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds idSum += world.getBlockId(x+xPos, y+2, z+zPos); } } - + return (idSum == 0) && canPlace; } else if(world.getBlockMetadata(x, y, z) == GeneratorType.WIND_TURBINE.meta) { - boolean canPlace = super.canPlaceBlockAt(world, x, y, z); - - int idSum = 0; - + boolean canPlace = super.canPlaceBlockAt(world, x, y, z); + + int idSum = 0; + for(int yPos = y+1; yPos <= y+4; yPos++) { idSum += world.getBlockId(x, yPos, z); } - + return (idSum == 0) && canPlace; } - - return super.canPlaceBlockAt(world, x, y, z); - } - - @Override - public void breakBlock(World world, int x, int y, int z, int i1, int i2) - { - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onBreak(); - } - - super.breakBlock(world, x, y, z, i1, i2); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) - { + return super.canPlaceBlockAt(world, x, y, z); + } + + @Override + public void breakBlock(World world, int x, int y, int z, int i1, int i2) + { + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); + + if(tileEntity instanceof IBoundingBlock) + { + ((IBoundingBlock)tileEntity).onBreak(); + } + + super.breakBlock(world, x, y, z, i1, i2); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) + { if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) { return false; } - - if(world.isRemote) - { - return true; - } - - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); - - if(entityplayer.getCurrentEquippedItem() != null) - { - if(entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench")) - { - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - return true; - } - - ((IToolWrench)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z); - - int change = 0; - - switch(tileEntity.facing) - { - case 3: - change = 5; - break; - case 5: - change = 2; - break; - case 2: - change = 4; - break; - case 4: - change = 3; - break; - } - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, blockID); - return true; - } - } - - if(metadata == 3 && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().isItemEqual(new ItemStack(MekanismGenerators.Generator, 1, 2))) - { - if(((TileEntityBasicBlock)world.getBlockTileEntity(x, y, z)).facing != facing) - { - return false; - } - } - - if(tileEntity != null) - { - if(!entityplayer.isSneaking()) - { - entityplayer.openGui(MekanismGenerators.instance, GeneratorType.getFromMetadata(metadata).guiId, world, x, y, z); - return true; - } - } - - return false; - } - - @Override - public int quantityDropped(Random random) - { - return 0; - } - - @Override - public TileEntity createTileEntity(World world, int metadata) - { - GeneratorType type = GeneratorType.getFromMetadata(metadata); - - if(type != null) - { - return type.create(); - } - - return null; - } - - @Override - public int idDropped(int i, Random random, int j) - { - return 0; - } - + + if(world.isRemote) + { + return true; + } + + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + + if(entityplayer.getCurrentEquippedItem() != null) + { + if(entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench")) + { + if(entityplayer.isSneaking()) + { + dismantleBlock(world, x, y, z, false); + return true; + } + + ((IToolWrench)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z); + + int change = 0; + + switch(tileEntity.facing) + { + case 3: + change = 5; + break; + case 5: + change = 2; + break; + case 2: + change = 4; + break; + case 4: + change = 3; + break; + } + + tileEntity.setFacing((short)change); + world.notifyBlocksOfNeighborChange(x, y, z, blockID); + return true; + } + } + + if(metadata == 3 && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().isItemEqual(new ItemStack(MekanismGenerators.Generator, 1, 2))) + { + if(((TileEntityBasicBlock)world.getBlockTileEntity(x, y, z)).facing != facing) + { + return false; + } + } + + if(tileEntity != null) + { + if(!entityplayer.isSneaking()) + { + entityplayer.openGui(MekanismGenerators.instance, GeneratorType.getFromMetadata(metadata).guiId, world, x, y, z); + return true; + } + } + + return false; + } + + @Override + public int quantityDropped(Random random) + { + return 0; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) + { + GeneratorType type = GeneratorType.getFromMetadata(metadata); + + if(type != null) + { + return type.create(); + } + + return null; + } + + @Override + public int idDropped(int i, Random random, int j) + { + return 0; + } + @Override public boolean renderAsNormalBlock() { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override @SideOnly(Side.CLIENT) public int getRenderType() { return GeneratorsClientProxy.GENERATOR_RENDER_ID; } - - /*This method is not used, metadata manipulation is required to create a Tile Entity.*/ - @Override + + /*This method is not used, metadata manipulation is required to create a Tile Entity.*/ + @Override public TileEntity createNewTileEntity(World world) { return null; } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) - { - int metadata = world.getBlockMetadata(x, y, z); - - if(metadata == GeneratorType.SOLAR_GENERATOR.meta) - { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.65F, 1.0F); - } - else { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } - - @Override - public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) - { - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); - - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); - - world.spawnEntityInWorld(entityItem); - } - - return world.setBlockToAir(x, y, z); - } - + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + + if(metadata == GeneratorType.SOLAR_GENERATOR.meta) + { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.65F, 1.0F); + } + else { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + @Override + public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) + { + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); + + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z)); + + world.spawnEntityInWorld(entityItem); + } + + return world.setBlockToAir(x, y, z); + } + @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); - ItemStack itemStack = new ItemStack(MekanismGenerators.Generator, 1, world.getBlockMetadata(x, y, z)); - + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); + ItemStack itemStack = new ItemStack(MekanismGenerators.Generator, 1, world.getBlockMetadata(x, y, z)); + if(tileEntity == null) { return null; } - IEnergizedItem electricItem = (IEnergizedItem)itemStack.getItem(); - electricItem.setEnergy(itemStack, tileEntity.electricityStored); - - ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); - inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); - - if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) - { - if(tileEntity instanceof ISustainedTank) - { - if(((ISustainedTank)tileEntity).getFluidStack() != null) - { - ((ISustainedTank)itemStack.getItem()).setFluidStack(((ISustainedTank)tileEntity).getFluidStack(), itemStack); - } - } - } - - return itemStack; + IEnergizedItem electricItem = (IEnergizedItem)itemStack.getItem(); + electricItem.setEnergy(itemStack, tileEntity.electricityStored); + + ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); + inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + + if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) + { + if(tileEntity instanceof ISustainedTank) + { + if(((ISustainedTank)tileEntity).getFluidStack() != null) + { + ((ISustainedTank)itemStack.getItem()).setFluidStack(((ISustainedTank)tileEntity).getFluidStack(), itemStack); + } + } + } + + return itemStack; } - - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) + + public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { ItemStack itemStack = getPickBlock(null, world, x, y, z); - - world.setBlockToAir(x, y, z); - - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - - return itemStack; + + world.setBlockToAir(x, y, z); + + if(!returnBlock) + { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; } - + @Override public void onBlockAdded(World world, int x, int y, int z) { @@ -495,20 +495,20 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds } } } - - @Override - public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) - { - int metadata = world.getBlockMetadata(x, y, z); - - if(metadata != GeneratorType.SOLAR_GENERATOR.meta && metadata != GeneratorType.ADVANCED_SOLAR_GENERATOR.meta && metadata != GeneratorType.WIND_TURBINE.meta) - { - return true; - } - - return false; - } - + + @Override + public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) + { + int metadata = world.getBlockMetadata(x, y, z); + + if(metadata != GeneratorType.SOLAR_GENERATOR.meta && metadata != GeneratorType.ADVANCED_SOLAR_GENERATOR.meta && metadata != GeneratorType.WIND_TURBINE.meta) + { + return true; + } + + return false; + } + public static enum GeneratorType { HEAT_GENERATOR(0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true), @@ -517,14 +517,14 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds BIO_GENERATOR(4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true), ADVANCED_SOLAR_GENERATOR(5, "AdvancedSolarGenerator", 1, 200000, TileEntityAdvancedSolarGenerator.class, true), WIND_TURBINE(6, "WindTurbine", 5, 200000, TileEntityWindTurbine.class, true); - + public int meta; public String name; public int guiId; public double maxEnergy; public Class tileEntityClass; public boolean hasModel; - + private GeneratorType(int i, String s, int j, double k, Class tileClass, boolean model) { meta = i; @@ -534,7 +534,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds tileEntityClass = tileClass; hasModel = model; } - + public static GeneratorType getFromMetadata(int meta) { for(GeneratorType type : values()) @@ -544,7 +544,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds } return null; } - + public TileEntity create() { try { @@ -555,7 +555,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds return null; } } - + @Override public String toString() { @@ -564,7 +564,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds } @Override - public void setRenderBounds(Block block, int metadata) + public void setRenderBounds(Block block, int metadata) { if(metadata == GeneratorType.SOLAR_GENERATOR.meta) { diff --git a/common/mekanism/generators/common/inventory/container/ContainerBioGenerator.java b/common/mekanism/generators/common/inventory/container/ContainerBioGenerator.java index 2721de72c..6a2fc6466 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerBioGenerator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerBioGenerator.java @@ -13,146 +13,146 @@ import net.minecraftforge.fluids.FluidRegistry; public class ContainerBioGenerator extends Container { - private TileEntityBioGenerator tileEntity; + private TileEntityBioGenerator tileEntity; - public ContainerBioGenerator(InventoryPlayer inventory, TileEntityBioGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 17, 35)); - addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); - int slotX; + public ContainerBioGenerator(InventoryPlayer inventory, TileEntityBioGenerator tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 17, 35)); + addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.openChest(); - tileEntity.open(inventory.player); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.closeChest(); - tileEntity.close(entityplayer); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.openChest(); + tileEntity.open(inventory.player); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.closeChest(); + tileEntity.close(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) - { - return null; - } - } - } - else if(tileEntity.getFuel(slotStack) > 0 || isBiofuel(slotStack)) - { - if(slotID != 0 && slotID != 1) - { - if (!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } - - private boolean isBiofuel(ItemStack itemStack) - { - if(FluidRegistry.isFluidRegistered("bioethanol")) - { - if(FluidContainerRegistry.getFluidForFilledItem(itemStack) != null) - { - if(FluidContainerRegistry.getFluidForFilledItem(itemStack).getFluid() == FluidRegistry.getFluid("bioethanol")) - { - return true; - } - } - } - - return false; - } + if(ChargeUtils.canBeCharged(slotStack)) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) + { + return null; + } + } + } + else if(tileEntity.getFuel(slotStack) > 0 || isBiofuel(slotStack)) + { + if(slotID != 0 && slotID != 1) + { + if (!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 2 && slotID <= 28) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 28) + { + if(!mergeItemStack(slotStack, 2, 28, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + private boolean isBiofuel(ItemStack itemStack) + { + if(FluidRegistry.isFluidRegistered("bioethanol")) + { + if(FluidContainerRegistry.getFluidForFilledItem(itemStack) != null) + { + if(FluidContainerRegistry.getFluidForFilledItem(itemStack).getFluid() == FluidRegistry.getFluid("bioethanol")) + { + return true; + } + } + } + + return false; + } } diff --git a/common/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java b/common/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java index 474c8a6fc..5c470d499 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java @@ -11,130 +11,130 @@ import net.minecraft.item.ItemStack; public class ContainerHeatGenerator extends Container { - private TileEntityHeatGenerator tileEntity; + private TileEntityHeatGenerator tileEntity; - public ContainerHeatGenerator(InventoryPlayer inventory, TileEntityHeatGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 17, 35)); - addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); - int slotX; + public ContainerHeatGenerator(InventoryPlayer inventory, TileEntityHeatGenerator tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 17, 35)); + addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.openChest(); - tileEntity.open(inventory.player); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.closeChest(); - tileEntity.close(entityplayer); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.openChest(); + tileEntity.open(inventory.player); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.closeChest(); + tileEntity.close(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) - { - return null; - } - } - } - else if(tileEntity.getFuel(slotStack) > 0) - { - if(slotID != 0 && slotID != 1) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if(ChargeUtils.canBeCharged(slotStack)) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) + { + return null; + } + } + } + else if(tileEntity.getFuel(slotStack) > 0) + { + if(slotID != 0 && slotID != 1) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 2 && slotID <= 28) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 28) + { + if(!mergeItemStack(slotStack, 2, 28, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/generators/common/inventory/container/ContainerHydrogenGenerator.java b/common/mekanism/generators/common/inventory/container/ContainerHydrogenGenerator.java index 64656c6c3..05a7cfd13 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerHydrogenGenerator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerHydrogenGenerator.java @@ -13,132 +13,132 @@ import net.minecraft.item.ItemStack; public class ContainerHydrogenGenerator extends Container { - private TileEntityHydrogenGenerator tileEntity; + private TileEntityHydrogenGenerator tileEntity; - public ContainerHydrogenGenerator(InventoryPlayer inventory, TileEntityHydrogenGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 17, 35)); - addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); - int slotX; + public ContainerHydrogenGenerator(InventoryPlayer inventory, TileEntityHydrogenGenerator tentity) + { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 17, 35)); + addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.openChest(); - tileEntity.open(inventory.player); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.openChest(); + tileEntity.open(inventory.player); + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) + { super.onContainerClosed(entityplayer); tileEntity.closeChest(); tileEntity.close(entityplayer); - } + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1) - { - if(((IGasItem)slotStack.getItem()).getGas(slotStack) != null && ((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("hydrogen")) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if(ChargeUtils.canBeCharged(slotStack)) + { + if(slotID != 1) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID == 1) + { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) + { + return null; + } + } + } + else if(slotStack.getItem() instanceof IGasItem) + { + if(slotID != 0 && slotID != 1) + { + if(((IGasItem)slotStack.getItem()).getGas(slotStack) != null && ((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("hydrogen")) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 2 && slotID <= 28) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 28) + { + if(!mergeItemStack(slotStack, 2, 28, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } - return stack; - } + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java b/common/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java index 64a18183c..92ce743ef 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java +++ b/common/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java @@ -11,113 +11,113 @@ import net.minecraft.item.ItemStack; public class ContainerSolarGenerator extends Container { - private TileEntitySolarGenerator tileEntity; + private TileEntitySolarGenerator tileEntity; - public ContainerSolarGenerator(InventoryPlayer inventory, TileEntitySolarGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); - int slotX; + public ContainerSolarGenerator(InventoryPlayer inventory, TileEntitySolarGenerator tentity) + { + tileEntity = tentity; + addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.openChest(); - tileEntity.open(inventory.player); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.closeChest(); - tileEntity.close(entityplayer); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.openChest(); + tileEntity.open(inventory.player); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.closeChest(); + tileEntity.close(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if(ChargeUtils.canBeCharged(slotStack)) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(slotID == 0) + { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) + { + return null; + } + } + } + else { + if(slotID >= 1 && slotID <= 27) + { + if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 27) + { + if(!mergeItemStack(slotStack, 1, 27, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/generators/common/inventory/container/ContainerWindTurbine.java b/common/mekanism/generators/common/inventory/container/ContainerWindTurbine.java index be832cbef..0d2075b37 100644 --- a/common/mekanism/generators/common/inventory/container/ContainerWindTurbine.java +++ b/common/mekanism/generators/common/inventory/container/ContainerWindTurbine.java @@ -11,113 +11,113 @@ import net.minecraft.item.ItemStack; public class ContainerWindTurbine extends Container { - private TileEntityWindTurbine tileEntity; + private TileEntityWindTurbine tileEntity; - public ContainerWindTurbine(InventoryPlayer inventory, TileEntityWindTurbine tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); - int slotX; + public ContainerWindTurbine(InventoryPlayer inventory, TileEntityWindTurbine tentity) + { + tileEntity = tentity; + addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - - tileEntity.openChest(); - tileEntity.open(inventory.player); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - - tileEntity.closeChest(); - tileEntity.close(entityplayer); - } + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + + tileEntity.openChest(); + tileEntity.open(inventory.player); + } @Override - public boolean canInteractWith(EntityPlayer entityplayer) + public void onContainerClosed(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); - } + super.onContainerClosed(entityplayer); - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.closeChest(); + tileEntity.close(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if(ChargeUtils.canBeCharged(slotStack)) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(slotID == 0) + { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) + { + return null; + } + } + } + else { + if(slotID >= 1 && slotID <= 27) + { + if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 27) + { + if(!mergeItemStack(slotStack, 1, 27, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) + { + return null; + } + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/common/mekanism/generators/common/item/ItemBlockGenerator.java b/common/mekanism/generators/common/item/ItemBlockGenerator.java index 4d63e4ca4..c910c3c9d 100644 --- a/common/mekanism/generators/common/item/ItemBlockGenerator.java +++ b/common/mekanism/generators/common/item/ItemBlockGenerator.java @@ -43,7 +43,7 @@ import java.util.List; public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, ISustainedTank, IEnergyContainerItem { public Block metaBlock; - + public ItemBlockGenerator(int id, Block block) { super(id); @@ -51,19 +51,19 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp setHasSubtypes(true); setMaxStackSize(1); } - + @Override public int getMetadata(int i) { return i; } - + @Override public Icon getIconFromDamage(int i) { return metaBlock.getIcon(2, i); } - + @Override public String getUnlocalizedName(ItemStack itemstack) { @@ -71,10 +71,10 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp { return "KillMe!"; } - + return getUnlocalizedName() + "." + GeneratorType.getFromMetadata(itemstack.getItemDamage()).name; } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) @@ -85,7 +85,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp } else { list.add(EnumColor.BRIGHT_GREEN + "Stored Energy: " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); - + if(hasTank(itemstack)) { if(getFluidStack(itemstack) != null) @@ -93,27 +93,27 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp list.add(EnumColor.PINK + FluidRegistry.getFluidName(getFluidStack(itemstack)) + ": " + EnumColor.GREY + getFluidStack(itemstack).amount + "mB"); } } - + list.add(EnumColor.AQUA + "Inventory: " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); } } - + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { boolean place = true; int blockID = world.getBlockId(x, y, z); - + if(stack.getItemDamage() == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) { if(blockID != 0 && !Block.blocksList[blockID].isBlockReplaceable(world, x, y, z)) return false; - + for(int xPos=-1;xPos<=1;xPos++) { for(int zPos=-1;zPos<=1;zPos++) { - if(world.getBlockId(x+xPos, y+2, z+zPos) != 0 || y+2 > 255) + if(world.getBlockId(x+xPos, y+2, z+zPos) != 0 || y+2 > 255) place = false; } } @@ -122,35 +122,35 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp { if(blockID != 0 && !Block.blocksList[blockID].isBlockReplaceable(world, x, y, z)) return false; - + for(int yPos = y+1; yPos <= y+4; yPos++) { - if(world.getBlockId(x, yPos, z) != 0 || yPos > 255) + if(world.getBlockId(x, yPos, z) != 0 || yPos > 255) place = false; } } - + if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) { - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); - tileEntity.electricityStored = getEnergy(stack); - - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); - - if(tileEntity instanceof ISustainedTank) - { - if(hasTank(stack) && getFluidStack(stack) != null) - { - ((ISustainedTank)tileEntity).setFluidStack(getFluidStack(stack), stack); - } - } - - return true; + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); + tileEntity.electricityStored = getEnergy(stack); + + ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); + + if(tileEntity instanceof ISustainedTank) + { + if(hasTank(stack) && getFluidStack(stack) != null) + { + ((ISustainedTank)tileEntity).setFluidStack(getFluidStack(stack), stack); + } + } + + return true; } - + return false; - } - + } + @Override public boolean canProvideEnergy(ItemStack itemStack) { @@ -186,102 +186,102 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp { return 0; } - + @Override - public void setInventory(NBTTagList nbtTags, Object... data) + public void setInventory(NBTTagList nbtTags, Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - + if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setTag("Items", nbtTags); } } @Override - public NBTTagList getInventory(Object... data) + public NBTTagList getInventory(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - - if(itemStack.stackTagCompound == null) - { - return null; + + if(itemStack.stackTagCompound == null) + { + return null; } - + return itemStack.stackTagCompound.getTagList("Items"); } - + return null; } - + @Override - public void setFluidStack(FluidStack fluidStack, Object... data) + public void setFluidStack(FluidStack fluidStack, Object... data) { if(fluidStack == null || fluidStack.amount == 0 || fluidStack.fluidID == 0) { return; } - + if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - + if(itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - + itemStack.stackTagCompound.setTag("fluidTank", fluidStack.writeToNBT(new NBTTagCompound())); } } @Override - public FluidStack getFluidStack(Object... data) + public FluidStack getFluidStack(Object... data) { if(data[0] instanceof ItemStack) { ItemStack itemStack = (ItemStack)data[0]; - - if(itemStack.stackTagCompound == null) - { - return null; + + if(itemStack.stackTagCompound == null) + { + return null; } - + if(itemStack.stackTagCompound.hasKey("fluidTank")) { return FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank")); } } - + return null; } @Override - public boolean hasTank(Object... data) + public boolean hasTank(Object... data) { return data[0] instanceof ItemStack && ((ItemStack)data[0]).getItem() instanceof ISustainedTank && (((ItemStack)data[0]).getItemDamage() == 2); } - + @Override - public double getEnergy(ItemStack itemStack) + public double getEnergy(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) - { - return 0; + if(itemStack.stackTagCompound == null) + { + return 0; } - + return itemStack.stackTagCompound.getDouble("electricity"); } @Override - public void setEnergy(ItemStack itemStack, double amount) + public void setEnergy(ItemStack itemStack, double amount) { if(itemStack.stackTagCompound == null) { @@ -293,19 +293,19 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp } @Override - public double getMaxEnergy(ItemStack itemStack) + public double getMaxEnergy(ItemStack itemStack) { return GeneratorType.getFromMetadata(itemStack.getItemDamage()).maxEnergy; } @Override - public double getMaxTransfer(ItemStack itemStack) + public double getMaxTransfer(ItemStack itemStack) { return getMaxEnergy(itemStack)*0.005; } @Override - public boolean canReceive(ItemStack itemStack) + public boolean canReceive(ItemStack itemStack) { return false; } @@ -315,7 +315,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp { return true; } - + @Override public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) { @@ -323,34 +323,34 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp { double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); double toReceive = Math.min(energy*Mekanism.FROM_TE, energyNeeded); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) + toReceive); } - + return (int)Math.round(toReceive*Mekanism.TO_TE); } - + return 0; } @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { if(canSend(theItem)) { double energyRemaining = getEnergy(theItem); double toSend = Math.min((energy*Mekanism.FROM_TE), energyRemaining); - + if(!simulate) { setEnergy(theItem, getEnergy(theItem) - toSend); } - + return (int)Math.round(toSend*Mekanism.TO_TE); } - + return 0; } @@ -365,15 +365,15 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp { return (int)(getMaxEnergy(theItem)*Mekanism.TO_TE); } - + @Override public boolean isMetadataSpecific() { return true; } - + @Override - public IElectricItemManager getManager(ItemStack itemStack) + public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); } diff --git a/common/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java b/common/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java index 9eb37d7da..f236202bf 100644 --- a/common/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java +++ b/common/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java @@ -16,7 +16,7 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i super("AdvancedSolarGenerator", 200000, 360, MekanismGenerators.advancedSolarGeneration*2); GENERATION_RATE = MekanismGenerators.advancedSolarGeneration; } - + @Override public EnumSet getOutputtingSides() { @@ -24,10 +24,10 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i } @Override - public void onPlace() + public void onPlace() { MekanismUtils.makeBoundingBlock(worldObj, xCoord, yCoord+1, zCoord, Coord4D.get(this)); - + for(int x = -1; x <= 1; x++) { for(int z = -1; z <= 1; z++) @@ -38,10 +38,10 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i } @Override - public void onBreak() + public void onBreak() { worldObj.setBlockToAir(xCoord, yCoord+1, zCoord); - + for(int x = -1; x <= 1; x++) { for(int z = -1; z <= 1; z++) @@ -49,7 +49,7 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i worldObj.setBlockToAir(xCoord+x, yCoord+2, zCoord+z); } } - + invalidate(); worldObj.setBlockToAir(xCoord, yCoord, zCoord); } diff --git a/common/mekanism/generators/common/tile/TileEntityBioGenerator.java b/common/mekanism/generators/common/tile/TileEntityBioGenerator.java index 6b9ce294b..80d61539b 100644 --- a/common/mekanism/generators/common/tile/TileEntityBioGenerator.java +++ b/common/mekanism/generators/common/tile/TileEntityBioGenerator.java @@ -60,7 +60,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui if(bioFuelSlot.fluidStored+fluidToAdd <= bioFuelSlot.MAX_FLUID) { bioFuelSlot.setFluid(bioFuelSlot.fluidStored+fluidToAdd); - + if(inventory[0].getItem().getContainerItemStack(inventory[0]) != null) { inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]); @@ -68,7 +68,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui else { inventory[0].stackSize--; } - + if(inventory[0].stackSize == 0) { inventory[0] = null; @@ -79,15 +79,15 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui else { int fuel = getFuel(inventory[0]); ItemStack prevStack = inventory[0].copy(); - + if(fuel > 0) { int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored; - + if(fuel <= fuelNeeded) { bioFuelSlot.fluidStored += fuel; - + if(inventory[0].getItem().getContainerItemStack(inventory[0]) != null) { inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]); @@ -95,7 +95,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui else { inventory[0].stackSize--; } - + if(inventory[0].stackSize == 0) { inventory[0] = null; @@ -106,12 +106,12 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } if(canOperate()) - { + { if(!worldObj.isRemote) { setActive(true); } - + bioFuelSlot.setFluid(bioFuelSlot.fluidStored - 1); setEnergy(electricityStored + MekanismGenerators.bioGeneration); } @@ -143,7 +143,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } } } - + return false; } } @@ -162,20 +162,20 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - bioFuelSlot.fluidStored = nbtTags.getInteger("bioFuelStored"); - } + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + bioFuelSlot.fluidStored = nbtTags.getInteger("bioFuelStored"); + } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("bioFuelStored", bioFuelSlot.fluidStored); - } + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("bioFuelStored", bioFuelSlot.fluidStored); + } public int getFuel(ItemStack itemstack) { @@ -191,7 +191,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui { return bioFuelSlot.fluidStored*i / bioFuelSlot.MAX_FLUID; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { @@ -218,7 +218,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui data.add(bioFuelSlot.fluidStored); return data; } - + @Override public EnumSet getOutputtingSides() { @@ -226,13 +226,13 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -255,7 +255,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { if(FluidRegistry.isFluidRegistered("bioethanol") && from != ForgeDirection.getOrientation(facing)) { @@ -286,7 +286,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { return null; } @@ -298,19 +298,19 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui } @Override - public boolean canFill(ForgeDirection from, Fluid fluid) + public boolean canFill(ForgeDirection from, Fluid fluid) { return FluidRegistry.isFluidRegistered("bioethanol") && fluid == FluidRegistry.getFluid("bioethanol"); } @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) + public boolean canDrain(ForgeDirection from, Fluid fluid) { return false; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) + public FluidTankInfo[] getTankInfo(ForgeDirection from) { return null; } diff --git a/common/mekanism/generators/common/tile/TileEntityGenerator.java b/common/mekanism/generators/common/tile/TileEntityGenerator.java index 064020706..5528785a7 100644 --- a/common/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/common/mekanism/generators/common/tile/TileEntityGenerator.java @@ -30,19 +30,19 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem { /** Output per tick this generator can transfer. */ public double output; - + /** Whether or not this block is in it's active state. */ public boolean isActive; - + /** The client's current active state. */ public boolean clientActive; - + /** How many ticks must pass until this block's active state can sync with the client. */ public int updateDelay; /** This machine's current RedstoneControl type. */ public RedstoneControl controlType; - + /** * Generator -- a block that produces energy. It has a certain amount of fuel it can store as well as an output rate. * @param name - full name of this generator @@ -52,27 +52,27 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem public TileEntityGenerator(String name, double maxEnergy, double out) { super(name, maxEnergy); - + powerHandler.configure(0, 0, 0, 0); - + output = out; isActive = false; controlType = RedstoneControl.DISABLED; } - + @Override public void onUpdate() - { + { super.onUpdate(); - + if(worldObj.isRemote) { Mekanism.proxy.registerSound(this); - + if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; @@ -80,90 +80,90 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem } } } - + if(!worldObj.isRemote) { if(updateDelay > 0) { updateDelay--; - + if(updateDelay == 0 && clientActive != isActive) { clientActive = isActive; PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); } } - + if(MekanismUtils.canFunction(this)) { CableUtils.emit(this); } } } - + @Override public double getMaxOutput() { return output; } - + @Override protected EnumSet getConsumingSides() { return EnumSet.noneOf(ForgeDirection.class); } - + @Override public EnumSet getOutputtingSides() { return EnumSet.of(ForgeDirection.getOrientation(facing)); } - + @Override public void invalidate() { super.invalidate(); - + if(worldObj.isRemote) { Mekanism.proxy.unregisterSound(this); } } - + /** * Whether or not this generator can operate. * @return if the generator can operate */ public abstract boolean canOperate(); - + @Override public boolean getActive() { return isActive; } - + @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); - - updateDelay = Mekanism.UPDATE_DELAY; - clientActive = active; - } - } - + public void setActive(boolean active) + { + isActive = active; + + if(clientActive != active && updateDelay == 0) + { + PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList()))); + + updateDelay = Mekanism.UPDATE_DELAY; + clientActive = active; + } + } + @Override - public String getType() + public String getType() { return getInvName(); } @Override - public boolean canAttachToSide(int side) + public boolean canAttachToSide(int side) { return true; } @@ -173,21 +173,21 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem @Override public void detach(IComputerAccess computer) {} - + @Override public boolean canSetFacing(int side) { return side != 0 && side != 1; } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + clientActive = dataStream.readBoolean(); controlType = RedstoneControl.values()[dataStream.readInt()]; - + if(updateDelay == 0 && clientActive != isActive) { updateDelay = Mekanism.UPDATE_DELAY; @@ -195,57 +195,57 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + data.add(isActive); data.add(controlType.ordinal()); - + return data; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + } + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { return INFINITE_EXTENT_AABB; } - + @Override public String getSoundPath() { return fullName.replace("Advanced", "") + ".ogg"; } - + @Override public float getVolumeMultiplier() { return 1; } - + @Override - public boolean renderUpdate() + public boolean renderUpdate() { return true; } @@ -255,20 +255,20 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem { return true; } - + @Override - public RedstoneControl getControlType() + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); } - + @Override protected void reconfigure() { diff --git a/common/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/common/mekanism/generators/common/tile/TileEntityHeatGenerator.java index 45b6a4e82..f793eb2f4 100644 --- a/common/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/common/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -27,32 +27,32 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { /** The FluidTank for this generator. */ public FluidTank lavaTank = new FluidTank(24000); - + public TileEntityHeatGenerator() { super("HeatGenerator", 160000, MekanismGenerators.heatGeneration*2); inventory = new ItemStack[2]; } - + @Override public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { ChargeUtils.charge(1, this); - + if(inventory[0] != null) { FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - + if(fluid != null && fluid.fluidID == FluidRegistry.LAVA.getID()) { if(lavaTank.getFluid() == null || lavaTank.getFluid().amount+fluid.amount <= lavaTank.getCapacity()) { lavaTank.fill(fluid, true); - + if(inventory[0].getItem().getContainerItemStack(inventory[0]) != null) { inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]); @@ -60,7 +60,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu else { inventory[0].stackSize--; } - + if(inventory[0].stackSize == 0) { inventory[0] = null; @@ -69,15 +69,15 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu } else { int fuel = getFuel(inventory[0]); - + if(fuel > 0) { int fuelNeeded = lavaTank.getCapacity() - (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0); - + if(fuel <= fuelNeeded) { lavaTank.fill(new FluidStack(FluidRegistry.LAVA, fuel), true); - + if(inventory[0].getItem().getContainerItemStack(inventory[0]) != null) { inventory[0] = inventory[0].getItem().getContainerItemStack(inventory[0]); @@ -85,7 +85,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu else { inventory[0].stackSize--; } - + if(inventory[0].stackSize == 0) { inventory[0] = null; @@ -94,13 +94,13 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu } } } - + setEnergy(electricityStored + getBoost()); - + if(canOperate()) - { + { setActive(true); - + lavaTank.drain(10, true); setEnergy(electricityStored + MekanismGenerators.heatGeneration); } @@ -109,7 +109,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu } } } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -121,38 +121,38 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { return ChargeUtils.canBeCharged(itemstack); } - + return true; } - + @Override public boolean canOperate() { return electricityStored < MAX_ELECTRICITY && lavaTank.getFluid() != null && lavaTank.getFluid().amount >= 10 && MekanismUtils.canFunction(this); } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - if(nbtTags.hasKey("lavaTank")) - { - lavaTank.readFromNBT(nbtTags.getCompoundTag("lavaTank")); - } - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - if(lavaTank.getFluid() != null) - { - nbtTags.setTag("lavaTank", lavaTank.writeToNBT(new NBTTagCompound())); - } - } - + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + if(nbtTags.hasKey("lavaTank")) + { + lavaTank.readFromNBT(nbtTags.getCompoundTag("lavaTank")); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + if(lavaTank.getFluid() != null) + { + nbtTags.setTag("lavaTank", lavaTank.writeToNBT(new NBTTagCompound())); + } + } + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -164,14 +164,14 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { return FluidContainerRegistry.isEmptyContainer(itemstack); } - + return false; } - + public double getBoost() { int boost = 0; - + if(worldObj.getBlockId(xCoord+1, yCoord, zCoord) == 10 || worldObj.getBlockId(xCoord+1, yCoord, zCoord) == 11) boost+=5; if(worldObj.getBlockId(xCoord-1, yCoord, zCoord) == 10 || worldObj.getBlockId(xCoord-1, yCoord, zCoord) == 11) @@ -184,7 +184,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu boost+=5; if(worldObj.getBlockId(xCoord, yCoord, zCoord-1) == 10 || worldObj.getBlockId(xCoord, yCoord, zCoord-1) == 11) boost+=5; - + return boost; } @@ -194,16 +194,16 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { return 1000; } - + return TileEntityFurnace.getItemBurnTime(itemstack); } - + @Override public int[] getAccessibleSlotsFromSide(int side) { return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) ? new int[] {1} : new int[] {0}; } - + /** * Gets the scaled fuel level for the GUI. * @param i - multiplier @@ -213,14 +213,14 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { return (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0)*i / lavaTank.getCapacity(); } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); - + int amount = dataStream.readInt(); - + if(amount != 0) { lavaTank.setFluid(new FluidStack(FluidRegistry.LAVA, amount)); @@ -229,12 +229,12 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu lavaTank.setFluid(null); } } - + @Override public ArrayList getNetworkedData(ArrayList data) { super.getNetworkedData(data); - + if(lavaTank.getFluid() != null) { data.add(lavaTank.getFluid().amount); @@ -242,18 +242,18 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu else { data.add(0); } - + return data; } - + @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getFuel", "getFuelNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -276,42 +276,42 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu } @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { if(resource.fluidID == FluidRegistry.LAVA.getID() && from != ForgeDirection.getOrientation(facing)) { return lavaTank.fill(resource, doFill); } - + return 0; } @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { return null; } @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { return null; } @Override - public boolean canFill(ForgeDirection from, Fluid fluid) + public boolean canFill(ForgeDirection from, Fluid fluid) { return fluid == FluidRegistry.LAVA; } @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) + public boolean canDrain(ForgeDirection from, Fluid fluid) { return false; } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) + public FluidTankInfo[] getTankInfo(ForgeDirection from) { return new FluidTankInfo[] {lavaTank.getInfo()}; } diff --git a/common/mekanism/generators/common/tile/TileEntityHydrogenGenerator.java b/common/mekanism/generators/common/tile/TileEntityHydrogenGenerator.java index f05601b11..51d71258d 100644 --- a/common/mekanism/generators/common/tile/TileEntityHydrogenGenerator.java +++ b/common/mekanism/generators/common/tile/TileEntityHydrogenGenerator.java @@ -25,35 +25,35 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements { /** The maximum amount of hydrogen this block can store. */ public int MAX_HYDROGEN = 18000; - + /** The amount of hydrogen this block is storing. */ public int hydrogenStored; - + public TileEntityHydrogenGenerator() { super("HydrogenGenerator", 40000, MekanismGenerators.hydrogenGeneration*2); inventory = new ItemStack[2]; } - + @Override public void onUpdate() { super.onUpdate(); - + if(!worldObj.isRemote) { ChargeUtils.charge(1, this); - + if(inventory[0] != null && hydrogenStored < MAX_HYDROGEN) { GasStack removed = GasTransmission.removeGas(inventory[0], GasRegistry.getGas("hydrogen"), MAX_HYDROGEN-hydrogenStored); hydrogenStored += removed != null ? removed.amount : 0; } - + if(canOperate()) { setActive(true); - + hydrogenStored-=2; setEnergy(electricityStored + MekanismGenerators.hydrogenGeneration); } @@ -62,7 +62,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements } } } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -74,10 +74,10 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements { return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null); } - + return false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -90,22 +90,22 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements { return ChargeUtils.canBeCharged(itemstack); } - + return true; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) ? new int[] {1} : new int[] {0}; } - + @Override public boolean canOperate() { return electricityStored < MAX_ELECTRICITY && hydrogenStored-2 >= 0 && MekanismUtils.canFunction(this); } - + /** * Gets the scaled hydrogen level for the GUI. * @param i - multiplier @@ -117,13 +117,13 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getHydrogen", "getHydrogenNeeded"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -151,7 +151,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements super.handlePacketData(dataStream); hydrogenStored = dataStream.readInt(); } - + @Override public ArrayList getNetworkedData(ArrayList data) { @@ -161,40 +161,40 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements } @Override - public int receiveGas(ForgeDirection side, GasStack stack) + public int receiveGas(ForgeDirection side, GasStack stack) { if(stack.getGas() == GasRegistry.getGas("hydrogen")) { int toUse = Math.min(MAX_HYDROGEN-hydrogenStored, stack.amount); hydrogenStored += toUse; - return toUse; + return toUse; } - + return 0; } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - hydrogenStored = nbtTags.getInteger("hydrogenStored"); - } @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("hydrogenStored", hydrogenStored); - } + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + hydrogenStored = nbtTags.getInteger("hydrogenStored"); + } @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("hydrogenStored", hydrogenStored); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { return type == GasRegistry.getGas("hydrogen") && side != ForgeDirection.getOrientation(facing); } - + @Override public GasStack drawGas(ForgeDirection side, int amount) { @@ -208,7 +208,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements } @Override - public boolean canTubeConnect(ForgeDirection side) + public boolean canTubeConnect(ForgeDirection side) { return side != ForgeDirection.getOrientation(facing); } diff --git a/common/mekanism/generators/common/tile/TileEntitySolarGenerator.java b/common/mekanism/generators/common/tile/TileEntitySolarGenerator.java index c58ecc60e..020407626 100644 --- a/common/mekanism/generators/common/tile/TileEntitySolarGenerator.java +++ b/common/mekanism/generators/common/tile/TileEntitySolarGenerator.java @@ -23,49 +23,49 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { /** Whether or not this generator sees the sun. */ public boolean seesSun = false; - + /** How fast this tile entity generates energy. */ public double GENERATION_RATE; - + public TileEntitySolarGenerator() { super("SolarGenerator", 96000, MekanismGenerators.solarGeneration*2); GENERATION_RATE = MekanismGenerators.solarGeneration; inventory = new ItemStack[1]; } - + public TileEntitySolarGenerator(String name, double maxEnergy, double output, double generation) { super(name, maxEnergy, output); GENERATION_RATE = generation; inventory = new ItemStack[1]; } - + @Override public int[] getAccessibleSlotsFromSide(int side) { return new int[] {0}; } - + @Override public float getVolumeMultiplier() { return 0.05F; } - + @Override public boolean canSetFacing(int facing) { return facing != 0 && facing != 1; } - + @Override public void onUpdate() { super.onUpdate(); - + ChargeUtils.charge(0, this); - + if(!worldObj.isRemote) { if(worldObj.isDaytime() && ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord+1, zCoord)) @@ -86,12 +86,12 @@ public class TileEntitySolarGenerator extends TileEntityGenerator } } } - + public boolean isDesert() { return worldObj.provider.getBiomeGenForCoords(xCoord >> 4, zCoord >> 4) instanceof BiomeGenDesert; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { @@ -99,10 +99,10 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { return ChargeUtils.canBeOutputted(itemstack, true); } - + return false; } - + @Override public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { @@ -110,48 +110,48 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { return ChargeUtils.canBeCharged(itemstack); } - + return true; } - + @Override public boolean canOperate() { return getEnergy() < getMaxEnergy() && seesSun && MekanismUtils.canFunction(this); } - + public double getProduction() { double ret = 0; - + if(seesSun) { ret = GENERATION_RATE; - + if(worldObj.provider instanceof ISolarLevel) { ret *= ((ISolarLevel)worldObj.provider).getSolarEnergyMultiplier(); } - + if(isDesert()) { ret *= 1.5; } - + return ret; } - + return 0; } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getSeesSun"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -170,14 +170,14 @@ public class TileEntitySolarGenerator extends TileEntityGenerator return null; } } - + @Override public void handlePacketData(ByteArrayDataInput dataStream) { super.handlePacketData(dataStream); seesSun = dataStream.readBoolean(); } - + @Override public ArrayList getNetworkedData(ArrayList data) { @@ -185,15 +185,15 @@ public class TileEntitySolarGenerator extends TileEntityGenerator data.add(seesSun); return data; } - + @Override public EnumSet getOutputtingSides() { return EnumSet.of(ForgeDirection.getOrientation(0)); } - + @Override - public boolean renderUpdate() + public boolean renderUpdate() { return false; } diff --git a/common/mekanism/generators/common/tile/TileEntityWindTurbine.java b/common/mekanism/generators/common/tile/TileEntityWindTurbine.java index 4aebaac8e..f56870246 100644 --- a/common/mekanism/generators/common/tile/TileEntityWindTurbine.java +++ b/common/mekanism/generators/common/tile/TileEntityWindTurbine.java @@ -13,20 +13,20 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound { /** The angle the blades of this Wind Turbine are currently at. */ public int angle; - - public TileEntityWindTurbine() + + public TileEntityWindTurbine() { super("WindTurbine", 200000, (MekanismGenerators.windGeneration*8)*2); inventory = new ItemStack[1]; } - + @Override public void onUpdate() { super.onUpdate(); - + ChargeUtils.charge(0, this); - + if(!worldObj.isRemote) { if(canOperate()) @@ -39,13 +39,13 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound } } } - + /** 0 - 8 **/ public float getMultiplier() { return worldObj.canBlockSeeTheSky(xCoord, yCoord+4, zCoord) ? (((float)yCoord+4)/(float)256)*8 : 0; } - + @Override public float getVolumeMultiplier() { @@ -53,13 +53,13 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound } @Override - public String[] getMethodNames() + public String[] getMethodNames() { return new String[] {"getStored", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier"}; } @Override - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception + public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { switch(method) { @@ -80,13 +80,13 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound } @Override - public boolean canOperate() + public boolean canOperate() { return electricityStored < MAX_ELECTRICITY && getMultiplier() > 0 && MekanismUtils.canFunction(this); } @Override - public void onPlace() + public void onPlace() { MekanismUtils.makeBoundingBlock(worldObj, xCoord, yCoord+1, zCoord, Coord4D.get(this)); MekanismUtils.makeBoundingBlock(worldObj, xCoord, yCoord+2, zCoord, Coord4D.get(this)); @@ -95,18 +95,18 @@ public class TileEntityWindTurbine extends TileEntityGenerator implements IBound } @Override - public void onBreak() + public void onBreak() { worldObj.setBlockToAir(xCoord, yCoord+1, zCoord); worldObj.setBlockToAir(xCoord, yCoord+2, zCoord); worldObj.setBlockToAir(xCoord, yCoord+3, zCoord); worldObj.setBlockToAir(xCoord, yCoord+4, zCoord); - + worldObj.setBlockToAir(xCoord, yCoord, zCoord); } - + @Override - public boolean renderUpdate() + public boolean renderUpdate() { return false; } diff --git a/common/mekanism/tools/common/MekanismTools.java b/common/mekanism/tools/common/MekanismTools.java index 52950b114..ed8361f72 100644 --- a/common/mekanism/tools/common/MekanismTools.java +++ b/common/mekanism/tools/common/MekanismTools.java @@ -41,7 +41,7 @@ public class MekanismTools implements IModule { @Instance("MekanismTools") public static MekanismTools instance; - + /** MekanismTools version number */ public static Version versionNumber = new Version(6, 0, 3); @@ -73,7 +73,7 @@ public class MekanismTools implements IModule public static Item IronPaxel; public static Item DiamondPaxel; public static Item GoldPaxel; - + //Glowstone Items public static Item GlowstonePaxel; public static Item GlowstonePickaxe; @@ -85,7 +85,7 @@ public class MekanismTools implements IModule public static Item GlowstoneChestplate; public static Item GlowstoneLeggings; public static Item GlowstoneBoots; - + //Redstone Items public static Item BronzePaxel; public static Item BronzePickaxe; @@ -97,7 +97,7 @@ public class MekanismTools implements IModule public static Item BronzeChestplate; public static Item BronzeLeggings; public static Item BronzeBoots; - + //Osmium Items public static Item OsmiumPaxel; public static Item OsmiumPickaxe; @@ -109,7 +109,7 @@ public class MekanismTools implements IModule public static Item OsmiumChestplate; public static Item OsmiumLeggings; public static Item OsmiumBoots; - + //Obsidian Items public static Item ObsidianHelmet; public static Item ObsidianChestplate; @@ -121,7 +121,7 @@ public class MekanismTools implements IModule public static Item ObsidianShovel; public static Item ObsidianHoe; public static Item ObsidianSword; - + //Lazuli Items public static Item LazuliPaxel; public static Item LazuliPickaxe; @@ -133,7 +133,7 @@ public class MekanismTools implements IModule public static Item LazuliChestplate; public static Item LazuliLeggings; public static Item LazuliBoots; - + //Steel Items public static Item SteelPaxel; public static Item SteelPickaxe; @@ -145,24 +145,24 @@ public class MekanismTools implements IModule public static Item SteelChestplate; public static Item SteelLeggings; public static Item SteelBoots; - + @EventHandler public void init(FMLInitializationEvent event) { //Add this module to the core list Mekanism.modulesLoaded.add(this); - + //Register this class to the event bus for special mob spawning (mobs with Mekanism armor/tools) MinecraftForge.EVENT_BUS.register(this); - + //Load this module addItems(); addRecipes(); - + //Finalization Mekanism.logger.info("[MekanismTools] Loaded module."); } - + public void addRecipes() { //Crafting Recipes @@ -182,7 +182,7 @@ public class MekanismTools implements IModule CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(GoldPaxel, 1), new Object[] { "XYZ", " T ", " T ", Character.valueOf('X'), Item.axeGold, Character.valueOf('Y'), Item.pickaxeGold, Character.valueOf('Z'), Item.shovelGold, Character.valueOf('T'), Item.stick })); - + //Obsidian CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(ObsidianHelmet, 1), new Object[] { "***", "* *", Character.valueOf('*'), "ingotRefinedObsidian" @@ -214,7 +214,7 @@ public class MekanismTools implements IModule CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(ObsidianSword, 1), new Object[] { "X", "X", "T", Character.valueOf('X'), "ingotRefinedObsidian", Character.valueOf('T'), Item.stick })); - + //Glowstone CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(GlowstonePaxel, 1), new Object[] { "XYZ", " T ", " T ", Character.valueOf('X'), GlowstoneAxe, Character.valueOf('Y'), GlowstonePickaxe, Character.valueOf('Z'), GlowstoneShovel, Character.valueOf('T'), Item.stick @@ -246,7 +246,7 @@ public class MekanismTools implements IModule CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(GlowstoneBoots, 1), new Object[] { "* *", "* *", Character.valueOf('*'), "ingotRefinedGlowstone" })); - + //Lazuli CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(LazuliHelmet, 1), new Object[] { "***", "* *", Character.valueOf('*'), new ItemStack(Item.dyePowder, 1, 4) @@ -278,7 +278,7 @@ public class MekanismTools implements IModule CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(LazuliSword, 1), new Object[] { "X", "X", "T", Character.valueOf('X'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('T'), Item.stick })); - + //Osmium CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(OsmiumPaxel, 1), new Object[] { "XYZ", " T ", " T ", Character.valueOf('X'), OsmiumAxe, Character.valueOf('Y'), OsmiumPickaxe, Character.valueOf('Z'), OsmiumShovel, Character.valueOf('T'), Item.stick @@ -310,7 +310,7 @@ public class MekanismTools implements IModule CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(OsmiumBoots, 1), new Object[] { "* *", "* *", Character.valueOf('*'), "ingotOsmium" })); - + //Bronze CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(BronzePaxel, 1), new Object[] { "XYZ", " T ", " T ", Character.valueOf('X'), BronzeAxe, Character.valueOf('Y'), BronzePickaxe, Character.valueOf('Z'), BronzeShovel, Character.valueOf('T'), Item.stick @@ -342,7 +342,7 @@ public class MekanismTools implements IModule CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(BronzeBoots, 1), new Object[] { "* *", "* *", Character.valueOf('*'), "ingotBronze" })); - + //Steel CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(SteelPaxel, 1), new Object[] { "XYZ", " I ", " I ", Character.valueOf('X'), SteelAxe, Character.valueOf('Y'), SteelPickaxe, Character.valueOf('Z'), SteelShovel, Character.valueOf('I'), Item.ingotIron @@ -375,7 +375,7 @@ public class MekanismTools implements IModule "I *", "* I", Character.valueOf('*'), "ingotSteel", Character.valueOf('I'), Item.ingotIron })); } - + public void addItems() { //Declarations @@ -546,12 +546,12 @@ public class MekanismTools implements IModule BronzeShovel = new ItemMekanismShovel(Mekanism.configuration.getItem("BronzeShovel", 11407).getInt(), toolBRONZE).setUnlocalizedName("BronzeShovel"); BronzeHoe = new ItemMekanismHoe(Mekanism.configuration.getItem("BronzeHoe", 11408).getInt(), toolBRONZE).setUnlocalizedName("BronzeHoe"); BronzeSword = new ItemMekanismSword(Mekanism.configuration.getItem("BronzeSword", 11409).getInt(), toolBRONZE).setUnlocalizedName("BronzeSword"); - + MinecraftForge.setToolClass(BronzePaxel, "paxel", toolBRONZE2.getHarvestLevel()); MinecraftForge.setToolClass(BronzePickaxe, "pickaxe", toolBRONZE.getHarvestLevel()); MinecraftForge.setToolClass(BronzeAxe, "axe", toolBRONZE.getHarvestLevel()); MinecraftForge.setToolClass(BronzeShovel, "shovel", toolBRONZE.getHarvestLevel()); - + //Osmium OsmiumHelmet = (new ItemMekanismArmor(Mekanism.configuration.getItem("OsmiumHelmet", 11410).getInt(), armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 0)).setUnlocalizedName("OsmiumHelmet"); OsmiumChestplate = (new ItemMekanismArmor(Mekanism.configuration.getItem("OsmiumChestplate", 11411).getInt(), armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 1)).setUnlocalizedName("OsmiumChestplate"); @@ -563,12 +563,12 @@ public class MekanismTools implements IModule OsmiumShovel = new ItemMekanismShovel(Mekanism.configuration.getItem("OsmiumShovel", 11417).getInt(), toolOSMIUM).setUnlocalizedName("OsmiumShovel"); OsmiumHoe = new ItemMekanismHoe(Mekanism.configuration.getItem("OsmiumHoe", 11418).getInt(), toolOSMIUM).setUnlocalizedName("OsmiumHoe"); OsmiumSword = new ItemMekanismSword(Mekanism.configuration.getItem("OsmiumSword", 11419).getInt(), toolOSMIUM).setUnlocalizedName("OsmiumSword"); - + MinecraftForge.setToolClass(OsmiumPaxel, "paxel", toolOSMIUM2.getHarvestLevel()); MinecraftForge.setToolClass(OsmiumPickaxe, "pickaxe", toolOSMIUM.getHarvestLevel()); MinecraftForge.setToolClass(OsmiumAxe, "axe", toolOSMIUM.getHarvestLevel()); MinecraftForge.setToolClass(OsmiumShovel, "shovel", toolOSMIUM.getHarvestLevel()); - + //Obsidian ObsidianHelmet = (new ItemMekanismArmor(Mekanism.configuration.getItem("ObsidianHelmet", 11420).getInt(), armorOBSIDIAN, Mekanism.proxy.getArmorIndex("obsidian"), 0)).setUnlocalizedName("ObsidianHelmet"); ObsidianChestplate = (new ItemMekanismArmor(Mekanism.configuration.getItem("ObsidianChestplate", 11421).getInt(), armorOBSIDIAN, Mekanism.proxy.getArmorIndex("obsidian"), 1)).setUnlocalizedName("ObsidianChestplate"); @@ -580,12 +580,12 @@ public class MekanismTools implements IModule ObsidianShovel = new ItemMekanismShovel(Mekanism.configuration.getItem("ObsidianShovel", 11427).getInt(), toolOBSIDIAN).setUnlocalizedName("ObsidianShovel"); ObsidianHoe = new ItemMekanismHoe(Mekanism.configuration.getItem("ObsidianHoe", 11428).getInt(), toolOBSIDIAN).setUnlocalizedName("ObsidianHoe"); ObsidianSword = new ItemMekanismSword(Mekanism.configuration.getItem("ObsidianSword", 11429).getInt(), toolOBSIDIAN).setUnlocalizedName("ObsidianSword"); - + MinecraftForge.setToolClass(ObsidianPaxel, "paxel", toolOBSIDIAN2.getHarvestLevel()); MinecraftForge.setToolClass(ObsidianPickaxe, "pickaxe", toolOBSIDIAN.getHarvestLevel()); MinecraftForge.setToolClass(ObsidianAxe, "axe", toolOBSIDIAN.getHarvestLevel()); MinecraftForge.setToolClass(ObsidianShovel, "shovel", toolOBSIDIAN.getHarvestLevel()); - + //Lazuli LazuliPaxel = new ItemMekanismPaxel(Mekanism.configuration.getItem("LazuliPaxel", 11430).getInt(), toolLAZULI2).setUnlocalizedName("LazuliPaxel"); LazuliPickaxe = new ItemMekanismPickaxe(Mekanism.configuration.getItem("LazuliPickaxe", 11431).getInt(), toolLAZULI).setUnlocalizedName("LazuliPickaxe"); @@ -597,12 +597,12 @@ public class MekanismTools implements IModule LazuliChestplate = (new ItemMekanismArmor(Mekanism.configuration.getItem("LazuliChestplate", 11437).getInt(), armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 1)).setUnlocalizedName("LazuliChestplate"); LazuliLeggings = (new ItemMekanismArmor(Mekanism.configuration.getItem("LazuliLeggings", 11438).getInt(), armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 2)).setUnlocalizedName("LazuliLeggings"); LazuliBoots = (new ItemMekanismArmor(Mekanism.configuration.getItem("LazuliBoots", 11439).getInt(), armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 3)).setUnlocalizedName("LazuliBoots"); - + MinecraftForge.setToolClass(LazuliPaxel, "paxel", toolLAZULI2.getHarvestLevel()); MinecraftForge.setToolClass(LazuliPickaxe, "pickaxe", toolLAZULI.getHarvestLevel()); MinecraftForge.setToolClass(LazuliAxe, "axe", toolLAZULI.getHarvestLevel()); MinecraftForge.setToolClass(LazuliShovel, "shovel", toolLAZULI.getHarvestLevel()); - + //Glowstone GlowstonePaxel = new ItemMekanismPaxel(Mekanism.configuration.getItem("GlowstonePaxel", 11440).getInt(), toolGLOWSTONE2).setUnlocalizedName("GlowstonePaxel"); GlowstonePickaxe = new ItemMekanismPickaxe(Mekanism.configuration.getItem("GlowstonePickaxe", 11441).getInt(), toolGLOWSTONE).setUnlocalizedName("GlowstonePickaxe"); @@ -614,25 +614,25 @@ public class MekanismTools implements IModule GlowstoneChestplate = new ItemMekanismArmor(Mekanism.configuration.getItem("GlowstoneChestplate", 11447).getInt(), armorGLOWSTONE, Mekanism.proxy.getArmorIndex("glowstone"), 1).setUnlocalizedName("GlowstoneChestplate"); GlowstoneLeggings = new ItemMekanismArmor(Mekanism.configuration.getItem("GlowstoneLeggings", 11448).getInt(), armorGLOWSTONE, Mekanism.proxy.getArmorIndex("glowstone"), 2).setUnlocalizedName("GlowstoneLeggings"); GlowstoneBoots = new ItemMekanismArmor(Mekanism.configuration.getItem("GlowstoneBoots", 11449).getInt(), armorGLOWSTONE, Mekanism.proxy.getArmorIndex("glowstone"), 3).setUnlocalizedName("GlowstoneBoots"); - + MinecraftForge.setToolClass(GlowstonePaxel, "paxel", toolGLOWSTONE2.getHarvestLevel()); MinecraftForge.setToolClass(GlowstonePickaxe, "pickaxe", toolGLOWSTONE.getHarvestLevel()); MinecraftForge.setToolClass(GlowstoneAxe, "axe", toolGLOWSTONE.getHarvestLevel()); MinecraftForge.setToolClass(GlowstoneShovel, "shovel", toolGLOWSTONE.getHarvestLevel()); - + //Base Paxels WoodPaxel = new ItemMekanismPaxel(Mekanism.configuration.getItem("WoodPaxel", 11450).getInt(), EnumToolMaterial.WOOD).setUnlocalizedName("WoodPaxel"); StonePaxel = new ItemMekanismPaxel(Mekanism.configuration.getItem("StonePaxel", 11451).getInt(), EnumToolMaterial.STONE).setUnlocalizedName("StonePaxel"); IronPaxel = new ItemMekanismPaxel(Mekanism.configuration.getItem("IronPaxel", 11452).getInt(), EnumToolMaterial.IRON).setUnlocalizedName("IronPaxel"); DiamondPaxel = new ItemMekanismPaxel(Mekanism.configuration.getItem("DiamondPaxel", 11453).getInt(), EnumToolMaterial.EMERALD).setUnlocalizedName("DiamondPaxel"); GoldPaxel = new ItemMekanismPaxel(Mekanism.configuration.getItem("GoldPaxel", 11454).getInt(), EnumToolMaterial.GOLD).setUnlocalizedName("GoldPaxel"); - + MinecraftForge.setToolClass(WoodPaxel, "paxel", EnumToolMaterial.WOOD.getHarvestLevel()); MinecraftForge.setToolClass(StonePaxel, "paxel", EnumToolMaterial.STONE.getHarvestLevel()); MinecraftForge.setToolClass(IronPaxel, "paxel", EnumToolMaterial.IRON.getHarvestLevel()); MinecraftForge.setToolClass(DiamondPaxel, "paxel", EnumToolMaterial.EMERALD.getHarvestLevel()); MinecraftForge.setToolClass(GoldPaxel, "paxel", EnumToolMaterial.GOLD.getHarvestLevel()); - + //Steel SteelPaxel = new ItemMekanismPaxel(Mekanism.configuration.getItem("SteelPaxel", 11455).getInt(), toolSTEEL2).setUnlocalizedName("SteelPaxel"); SteelPickaxe = new ItemMekanismPickaxe(Mekanism.configuration.getItem("SteelPickaxe", 11456).getInt(), toolSTEEL).setUnlocalizedName("SteelPickaxe"); @@ -644,14 +644,14 @@ public class MekanismTools implements IModule SteelChestplate = new ItemMekanismArmor(Mekanism.configuration.getItem("SteelChestplate", 11462).getInt(), armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 1).setUnlocalizedName("SteelChestplate"); SteelLeggings = new ItemMekanismArmor(Mekanism.configuration.getItem("SteelLeggings", 11463).getInt(), armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 2).setUnlocalizedName("SteelLeggings"); SteelBoots = new ItemMekanismArmor(Mekanism.configuration.getItem("SteelBoots", 11464).getInt(), armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 3).setUnlocalizedName("SteelBoots"); - + MinecraftForge.setToolClass(SteelPaxel, "paxel", toolSTEEL2.getHarvestLevel()); MinecraftForge.setToolClass(SteelPickaxe, "pickaxe", toolSTEEL.getHarvestLevel()); MinecraftForge.setToolClass(SteelAxe, "axe", toolSTEEL.getHarvestLevel()); MinecraftForge.setToolClass(SteelShovel, "shovel", toolSTEEL.getHarvestLevel()); - + Mekanism.configuration.save(); - + //Registrations //Base GameRegistry.registerItem(WoodPaxel, "WoodPaxel"); @@ -659,7 +659,7 @@ public class MekanismTools implements IModule GameRegistry.registerItem(IronPaxel, "IronPaxel"); GameRegistry.registerItem(DiamondPaxel, "DiamondPaxel"); GameRegistry.registerItem(GoldPaxel, "GoldPaxel"); - + //Obsidian GameRegistry.registerItem(ObsidianHelmet, "ObsidianHelmet"); GameRegistry.registerItem(ObsidianChestplate, "ObsidianChestplate"); @@ -671,7 +671,7 @@ public class MekanismTools implements IModule GameRegistry.registerItem(ObsidianShovel, "ObsidianShovel"); GameRegistry.registerItem(ObsidianHoe, "ObsidianHoe"); GameRegistry.registerItem(ObsidianSword, "ObsidianSword"); - + //Lazuli GameRegistry.registerItem(LazuliHelmet, "LapisLazuliHelmet"); GameRegistry.registerItem(LazuliChestplate, "LapisLazuliChestplate"); @@ -683,7 +683,7 @@ public class MekanismTools implements IModule GameRegistry.registerItem(LazuliShovel, "LapisLazuliShovel"); GameRegistry.registerItem(LazuliHoe, "LapisLazuliHoe"); GameRegistry.registerItem(LazuliSword, "LapisLazuliSword"); - + //Osmium GameRegistry.registerItem(OsmiumHelmet, "OsmiumHelmet"); GameRegistry.registerItem(OsmiumChestplate, "OsmiumChestplate"); @@ -695,7 +695,7 @@ public class MekanismTools implements IModule GameRegistry.registerItem(OsmiumShovel, "OsmiumShovel"); GameRegistry.registerItem(OsmiumHoe, "OsmiumHoe"); GameRegistry.registerItem(OsmiumSword, "OsmiumSword"); - + //Redstone GameRegistry.registerItem(BronzeHelmet, "BronzeHelmet"); GameRegistry.registerItem(BronzeChestplate, "BronzeChestplate"); @@ -707,7 +707,7 @@ public class MekanismTools implements IModule GameRegistry.registerItem(BronzeShovel, "BronzeShovel"); GameRegistry.registerItem(BronzeHoe, "BronzeHoe"); GameRegistry.registerItem(BronzeSword, "BronzeSword"); - + //Glowstone GameRegistry.registerItem(GlowstonePaxel, "GlowstonePaxel"); GameRegistry.registerItem(GlowstonePickaxe, "GlowstonePickaxe"); @@ -719,7 +719,7 @@ public class MekanismTools implements IModule GameRegistry.registerItem(GlowstoneChestplate, "GlowstoneChestplate"); GameRegistry.registerItem(GlowstoneLeggings, "GlowstoneLeggings"); GameRegistry.registerItem(GlowstoneBoots, "GlowstoneBoots"); - + //Steel GameRegistry.registerItem(SteelPaxel, "SteelPaxel"); GameRegistry.registerItem(SteelPickaxe, "SteelPickaxe"); @@ -732,13 +732,13 @@ public class MekanismTools implements IModule GameRegistry.registerItem(SteelLeggings, "SteelLeggings"); GameRegistry.registerItem(SteelBoots, "SteelBoots"); } - + @ForgeSubscribe public void onLivingSpecialSpawn(LivingSpawnEvent event) { int chance = event.world.rand.nextInt(100); int armorType = event.world.rand.nextInt(4); - + if(chance < 3) { if(event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntitySkeleton) @@ -748,7 +748,7 @@ public class MekanismTools implements IModule int chestplate = event.world.rand.nextInt(100); int leggings = event.world.rand.nextInt(100); int boots = event.world.rand.nextInt(100); - + if(armorType == 0) { if(event.entityLiving instanceof EntityZombie && sword < 50) event.entityLiving.setCurrentItemOrArmor(0, new ItemStack(GlowstoneSword)); @@ -800,7 +800,7 @@ public class MekanismTools implements IModule } @Override - public String getName() + public String getName() { return "Tools"; } diff --git a/common/mekanism/tools/item/ItemMekanismArmor.java b/common/mekanism/tools/item/ItemMekanismArmor.java index b77714847..08dbe585f 100644 --- a/common/mekanism/tools/item/ItemMekanismArmor.java +++ b/common/mekanism/tools/item/ItemMekanismArmor.java @@ -18,40 +18,40 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemMekanismArmor extends ItemArmor { - public ItemMekanismArmor(int id, EnumArmorMaterial enumarmormaterial, int renderIndex, int armorType) - { - super(id, enumarmormaterial, renderIndex, armorType); - setCreativeTab(Mekanism.tabMekanism); - } - - @Override + public ItemMekanismArmor(int id, EnumArmorMaterial enumarmormaterial, int renderIndex, int armorType) + { + super(id, enumarmormaterial, renderIndex, armorType); + setCreativeTab(Mekanism.tabMekanism); + } + + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); } - + @Override public void registerIcons(IconRegister register) { itemIcon = register.registerIcon("mekanism:" + getUnlocalizedName().replace("item.", "")); } - + @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) - { + public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) + { return "mekanism:armor/" + getArmorMaterial().name().toLowerCase() + "_" + layer + ".png"; - } - + } + @Override @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) + { if(itemStack.itemID == MekanismTools.GlowstoneHelmet.itemID || itemStack.itemID == MekanismTools.GlowstoneChestplate.itemID || itemStack.itemID == MekanismTools.GlowstoneLeggings.itemID || itemStack.itemID == MekanismTools.GlowstoneBoots.itemID) { return ModelCustomArmor.getGlow(armorSlot); } - + return super.getArmorModel(entityLiving, itemStack, armorSlot); - } + } } diff --git a/common/mekanism/tools/item/ItemMekanismAxe.java b/common/mekanism/tools/item/ItemMekanismAxe.java index 18bdaaca7..5fa13a9c9 100644 --- a/common/mekanism/tools/item/ItemMekanismAxe.java +++ b/common/mekanism/tools/item/ItemMekanismAxe.java @@ -7,30 +7,30 @@ import net.minecraft.item.ItemStack; public class ItemMekanismAxe extends ItemMekanismTool { - private static Block blocksEffectiveAgainst[]; + private static Block blocksEffectiveAgainst[]; - public ItemMekanismAxe(int id, EnumToolMaterial enumtoolmaterial) - { - super(id, 3, enumtoolmaterial, blocksEffectiveAgainst); - } + public ItemMekanismAxe(int id, EnumToolMaterial enumtoolmaterial) + { + super(id, 3, enumtoolmaterial, blocksEffectiveAgainst); + } - @Override - public float getStrVsBlock(ItemStack itemstack, Block block) - { - if(block != null && block.blockMaterial == Material.wood) - { - return efficiencyOnProperMaterial; - } - else { - return super.getStrVsBlock(itemstack, block); - } - } + @Override + public float getStrVsBlock(ItemStack itemstack, Block block) + { + if(block != null && block.blockMaterial == Material.wood) + { + return efficiencyOnProperMaterial; + } + else { + return super.getStrVsBlock(itemstack, block); + } + } - static - { - blocksEffectiveAgainst = (new Block[] - { - Block.planks, Block.bookShelf, Block.wood, Block.chest, Block.woodSingleSlab, Block.woodDoubleSlab, Block.pumpkin, Block.pumpkinLantern - }); - } + static + { + blocksEffectiveAgainst = (new Block[] + { + Block.planks, Block.bookShelf, Block.wood, Block.chest, Block.woodSingleSlab, Block.woodDoubleSlab, Block.pumpkin, Block.pumpkinLantern + }); + } } diff --git a/common/mekanism/tools/item/ItemMekanismHoe.java b/common/mekanism/tools/item/ItemMekanismHoe.java index e7480bf6a..962b702f4 100644 --- a/common/mekanism/tools/item/ItemMekanismHoe.java +++ b/common/mekanism/tools/item/ItemMekanismHoe.java @@ -17,72 +17,72 @@ import cpw.mods.fml.relauncher.SideOnly; public class ItemMekanismHoe extends ItemMekanism { - protected EnumToolMaterial toolMaterial; + protected EnumToolMaterial toolMaterial; - public ItemMekanismHoe(int id, EnumToolMaterial enumtoolmaterial) - { - super(id); - toolMaterial = enumtoolmaterial; - maxStackSize = 1; - setMaxDamage(enumtoolmaterial.getMaxUses()); - setCreativeTab(CreativeTabs.tabTools); - } - - @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float entityX, float entityY, float entityZ) - { - if(!entityplayer.canPlayerEdit(x, y, z, side, itemstack)) - { - return false; - } - else { - UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z); - - if(MinecraftForge.EVENT_BUS.post(event)) - { - return false; - } - - if(event.getResult() == Result.ALLOW) - { - itemstack.damageItem(1, entityplayer); - return true; - } - - int blockID = world.getBlockId(x, y, z); - int aboveBlockID = world.getBlockId(x, y + 1, z); - - if((side == 0 || aboveBlockID != 0 || blockID != Block.grass.blockID) && blockID != Block.dirt.blockID) - { - return false; - } - else { - Block block = Block.tilledField; - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); - - if(world.isRemote) - { - return true; - } - else { - world.setBlock(x, y, z, block.blockID); - itemstack.damageItem(1, entityplayer); - return true; - } - } - } - } - - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) + public ItemMekanismHoe(int id, EnumToolMaterial enumtoolmaterial) { - list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); + super(id); + toolMaterial = enumtoolmaterial; + maxStackSize = 1; + setMaxDamage(enumtoolmaterial.getMaxUses()); + setCreativeTab(CreativeTabs.tabTools); } - @Override - @SideOnly(Side.CLIENT) - public boolean isFull3D() - { - return true; - } + @Override + public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float entityX, float entityY, float entityZ) + { + if(!entityplayer.canPlayerEdit(x, y, z, side, itemstack)) + { + return false; + } + else { + UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z); + + if(MinecraftForge.EVENT_BUS.post(event)) + { + return false; + } + + if(event.getResult() == Result.ALLOW) + { + itemstack.damageItem(1, entityplayer); + return true; + } + + int blockID = world.getBlockId(x, y, z); + int aboveBlockID = world.getBlockId(x, y + 1, z); + + if((side == 0 || aboveBlockID != 0 || blockID != Block.grass.blockID) && blockID != Block.dirt.blockID) + { + return false; + } + else { + Block block = Block.tilledField; + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + + if(world.isRemote) + { + return true; + } + else { + world.setBlock(x, y, z, block.blockID); + itemstack.damageItem(1, entityplayer); + return true; + } + } + } + } + + @Override + public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) + { + list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return true; + } } diff --git a/common/mekanism/tools/item/ItemMekanismPaxel.java b/common/mekanism/tools/item/ItemMekanismPaxel.java index 3b873f222..c0df4cf7f 100644 --- a/common/mekanism/tools/item/ItemMekanismPaxel.java +++ b/common/mekanism/tools/item/ItemMekanismPaxel.java @@ -8,66 +8,66 @@ import net.minecraftforge.common.ForgeHooks; public class ItemMekanismPaxel extends ItemMekanismTool { - public ItemMekanismPaxel(int i, EnumToolMaterial enumtoolmaterial) - { - super(i, 3, enumtoolmaterial, new Block[256]); - } - - @Override - public float getStrVsBlock(ItemStack itemstack, Block block) - { - return block.blockID != Block.bedrock.blockID ? efficiencyOnProperMaterial : 1.0F; - } - - @Override - public float getStrVsBlock(ItemStack stack, Block block, int meta) - { - if(ForgeHooks.isToolEffective(stack, block, meta)) - { - return efficiencyOnProperMaterial; - } - - return getStrVsBlock(stack, block); - } + public ItemMekanismPaxel(int i, EnumToolMaterial enumtoolmaterial) + { + super(i, 3, enumtoolmaterial, new Block[256]); + } - @Override - public boolean canHarvestBlock(Block block) - { - if(block == Block.obsidian) - { - return toolMaterial.getHarvestLevel() == 3; - } - - if(block == Block.blockDiamond || block == Block.oreDiamond) - { - return toolMaterial.getHarvestLevel() >= 2; - } - - if(block == Block.blockGold || block == Block.oreGold) - { - return toolMaterial.getHarvestLevel() >= 2; - } - - if(block == Block.blockIron || block == Block.oreIron) - { - return toolMaterial.getHarvestLevel() >= 1; - } - - if(block == Block.blockLapis || block == Block.oreLapis) - { - return toolMaterial.getHarvestLevel() >= 1; - } - - if(block == Block.oreRedstone || block == Block.oreRedstoneGlowing) - { - return toolMaterial.getHarvestLevel() >= 2; - } - - if(block.blockMaterial == Material.rock) - { - return true; - } - - return block.blockMaterial == Material.iron; - } + @Override + public float getStrVsBlock(ItemStack itemstack, Block block) + { + return block.blockID != Block.bedrock.blockID ? efficiencyOnProperMaterial : 1.0F; + } + + @Override + public float getStrVsBlock(ItemStack stack, Block block, int meta) + { + if(ForgeHooks.isToolEffective(stack, block, meta)) + { + return efficiencyOnProperMaterial; + } + + return getStrVsBlock(stack, block); + } + + @Override + public boolean canHarvestBlock(Block block) + { + if(block == Block.obsidian) + { + return toolMaterial.getHarvestLevel() == 3; + } + + if(block == Block.blockDiamond || block == Block.oreDiamond) + { + return toolMaterial.getHarvestLevel() >= 2; + } + + if(block == Block.blockGold || block == Block.oreGold) + { + return toolMaterial.getHarvestLevel() >= 2; + } + + if(block == Block.blockIron || block == Block.oreIron) + { + return toolMaterial.getHarvestLevel() >= 1; + } + + if(block == Block.blockLapis || block == Block.oreLapis) + { + return toolMaterial.getHarvestLevel() >= 1; + } + + if(block == Block.oreRedstone || block == Block.oreRedstoneGlowing) + { + return toolMaterial.getHarvestLevel() >= 2; + } + + if(block.blockMaterial == Material.rock) + { + return true; + } + + return block.blockMaterial == Material.iron; + } } diff --git a/common/mekanism/tools/item/ItemMekanismPickaxe.java b/common/mekanism/tools/item/ItemMekanismPickaxe.java index db8620fdc..e7c0f4f22 100644 --- a/common/mekanism/tools/item/ItemMekanismPickaxe.java +++ b/common/mekanism/tools/item/ItemMekanismPickaxe.java @@ -7,73 +7,73 @@ import net.minecraft.item.ItemStack; public class ItemMekanismPickaxe extends ItemMekanismTool { - private static Block blocksEffectiveAgainst[]; + private static Block blocksEffectiveAgainst[]; - public ItemMekanismPickaxe(int id, EnumToolMaterial enumtoolmaterial) - { - super(id, 2, enumtoolmaterial, blocksEffectiveAgainst); - } + public ItemMekanismPickaxe(int id, EnumToolMaterial enumtoolmaterial) + { + super(id, 2, enumtoolmaterial, blocksEffectiveAgainst); + } - @Override - public boolean canHarvestBlock(Block block) - { - if(block == Block.obsidian) - { - return toolMaterial.getHarvestLevel() == 3; - } + @Override + public boolean canHarvestBlock(Block block) + { + if(block == Block.obsidian) + { + return toolMaterial.getHarvestLevel() == 3; + } - if(block == Block.blockDiamond || block == Block.oreDiamond) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if(block == Block.blockDiamond || block == Block.oreDiamond) + { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block == Block.blockGold || block == Block.oreGold) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if(block == Block.blockGold || block == Block.oreGold) + { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block == Block.blockIron || block == Block.oreIron) - { - return toolMaterial.getHarvestLevel() >= 1; - } + if(block == Block.blockIron || block == Block.oreIron) + { + return toolMaterial.getHarvestLevel() >= 1; + } - if(block == Block.blockLapis || block == Block.oreLapis) - { - return toolMaterial.getHarvestLevel() >= 1; - } + if(block == Block.blockLapis || block == Block.oreLapis) + { + return toolMaterial.getHarvestLevel() >= 1; + } - if(block == Block.oreRedstone || block == Block.oreRedstoneGlowing) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if(block == Block.oreRedstone || block == Block.oreRedstoneGlowing) + { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block.blockMaterial == Material.rock) - { - return true; - } + if(block.blockMaterial == Material.rock) + { + return true; + } - return block.blockMaterial == Material.iron; - } + return block.blockMaterial == Material.iron; + } - @Override - public float getStrVsBlock(ItemStack itemstack, Block block) - { - if(block != null && (block.blockMaterial == Material.iron || block.blockMaterial == Material.anvil || block.blockMaterial == Material.rock)) - { - return efficiencyOnProperMaterial; - } - else { - return super.getStrVsBlock(itemstack, block); - } - } + @Override + public float getStrVsBlock(ItemStack itemstack, Block block) + { + if(block != null && (block.blockMaterial == Material.iron || block.blockMaterial == Material.anvil || block.blockMaterial == Material.rock)) + { + return efficiencyOnProperMaterial; + } + else { + return super.getStrVsBlock(itemstack, block); + } + } - static - { - blocksEffectiveAgainst = (new Block[] - { - Block.cobblestone, Block.stoneSingleSlab, Block.stoneDoubleSlab, Block.stone, Block.sandStone, Block.cobblestoneMossy, Block.oreIron, Block.blockIron, Block.oreCoal, Block.blockGold, - Block.oreGold, Block.oreDiamond, Block.blockDiamond, Block.ice, Block.netherrack, Block.oreLapis, Block.blockLapis, Block.oreRedstone, Block.oreRedstoneGlowing, Block.rail, - Block.railDetector, Block.railPowered, Block.railActivator - }); - } + static + { + blocksEffectiveAgainst = (new Block[] + { + Block.cobblestone, Block.stoneSingleSlab, Block.stoneDoubleSlab, Block.stone, Block.sandStone, Block.cobblestoneMossy, Block.oreIron, Block.blockIron, Block.oreCoal, Block.blockGold, + Block.oreGold, Block.oreDiamond, Block.blockDiamond, Block.ice, Block.netherrack, Block.oreLapis, Block.blockLapis, Block.oreRedstone, Block.oreRedstoneGlowing, Block.rail, + Block.railDetector, Block.railPowered, Block.railActivator + }); + } } diff --git a/common/mekanism/tools/item/ItemMekanismShovel.java b/common/mekanism/tools/item/ItemMekanismShovel.java index d3fbb8903..8199919e2 100644 --- a/common/mekanism/tools/item/ItemMekanismShovel.java +++ b/common/mekanism/tools/item/ItemMekanismShovel.java @@ -5,29 +5,29 @@ import net.minecraft.item.EnumToolMaterial; public class ItemMekanismShovel extends ItemMekanismTool { - private static Block blocksEffectiveAgainst[]; + private static Block blocksEffectiveAgainst[]; - public ItemMekanismShovel(int id, EnumToolMaterial enumtoolmaterial) - { - super(id, 1, enumtoolmaterial, blocksEffectiveAgainst); - } + public ItemMekanismShovel(int id, EnumToolMaterial enumtoolmaterial) + { + super(id, 1, enumtoolmaterial, blocksEffectiveAgainst); + } - @Override - public boolean canHarvestBlock(Block block) - { - if(block == Block.snow) - { - return true; - } + @Override + public boolean canHarvestBlock(Block block) + { + if(block == Block.snow) + { + return true; + } - return block == Block.blockSnow; - } + return block == Block.blockSnow; + } - static - { - blocksEffectiveAgainst = (new Block[] - { - Block.grass, Block.dirt, Block.sand, Block.gravel, Block.snow, Block.blockSnow, Block.blockClay, Block.tilledField, Block.slowSand, Block.mycelium - }); - } + static + { + blocksEffectiveAgainst = (new Block[] + { + Block.grass, Block.dirt, Block.sand, Block.gravel, Block.snow, Block.blockSnow, Block.blockClay, Block.tilledField, Block.slowSand, Block.mycelium + }); + } } diff --git a/common/mekanism/tools/item/ItemMekanismSword.java b/common/mekanism/tools/item/ItemMekanismSword.java index 24f9f1ccb..d67ca90d1 100644 --- a/common/mekanism/tools/item/ItemMekanismSword.java +++ b/common/mekanism/tools/item/ItemMekanismSword.java @@ -11,18 +11,18 @@ import net.minecraft.item.ItemSword; public class ItemMekanismSword extends ItemSword { - public ItemMekanismSword(int id, EnumToolMaterial enumtoolmaterial) - { - super(id, enumtoolmaterial); - setCreativeTab(Mekanism.tabMekanism); - } - - @Override + public ItemMekanismSword(int id, EnumToolMaterial enumtoolmaterial) + { + super(id, enumtoolmaterial); + setCreativeTab(Mekanism.tabMekanism); + } + + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); + list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); } - + @Override public void registerIcons(IconRegister register) { diff --git a/common/mekanism/tools/item/ItemMekanismTool.java b/common/mekanism/tools/item/ItemMekanismTool.java index c19c0aebf..5606e714a 100644 --- a/common/mekanism/tools/item/ItemMekanismTool.java +++ b/common/mekanism/tools/item/ItemMekanismTool.java @@ -12,18 +12,18 @@ import net.minecraft.item.ItemTool; public class ItemMekanismTool extends ItemTool { - public ItemMekanismTool(int id, int mobBoost, EnumToolMaterial enumtoolmaterial, Block effectiveBlocks[]) - { - super(id, mobBoost, enumtoolmaterial, effectiveBlocks); - setCreativeTab(Mekanism.tabMekanism); - } - - @Override + public ItemMekanismTool(int id, int mobBoost, EnumToolMaterial enumtoolmaterial, Block effectiveBlocks[]) + { + super(id, mobBoost, enumtoolmaterial, effectiveBlocks); + setCreativeTab(Mekanism.tabMekanism); + } + + @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); + list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); } - + @Override public void registerIcons(IconRegister register) {